[Bio] / FigCommon / bootstrap.pl Repository:
ViewVC logotype

Diff of /FigCommon/bootstrap.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Fri Dec 19 22:57:48 2003 UTC revision 1.11, Thu Jun 3 18:25:21 2004 UTC
# Line 34  Line 34 
34    
35  BEGIN {  BEGIN {
36    
37      # print "Here in the perl bootstrap. inc is:\n" . join("\n", @INC), "\n";      print "Here in the perl bootstrap. inc is:\n" . join("\n", @INC), "\n";
38    
39      my $my_prefix, $prefix, $inc, @newInc;      my $my_prefix, $prefix, $inc, @newInc;
40    
# Line 56  Line 56 
56          }          }
57    
58          $::perlenv_override = 1;          $::perlenv_override = 1;
     }  
   
     # print "New inc is:\n" . join("\n", @newInc), "\n";  
   
59      @INC = @newInc;      @INC = @newInc;
60  }  }
61    }
62    
63    
64  use FileHandle;  use FileHandle;
# Line 105  Line 102 
102    
103  our $fig_disk = $ENV{FIG_HOME};  our $fig_disk = $ENV{FIG_HOME};
104  our $env_name = $ENV{FIGCONFIG_ENV};  our $env_name = $ENV{FIGCONFIG_ENV};
105    our $env_dir = "$ENV{FIGCONFIG_ENV_DIR}";
106  our $env_bin = "$ENV{FIGCONFIG_ENV_DIR}/bin";  our $env_bin = "$ENV{FIGCONFIG_ENV_DIR}/bin";
107  our $env_lib = "$ENV{FIGCONFIG_ENV_DIR}/lib";  our $env_lib = "$ENV{FIGCONFIG_ENV_DIR}/lib";
108  our $dist_bin = "$ENV{FIGCONFIG_RELEASE_DIR}/bin/$ENV{FIGCONFIG_ENV}";  #
109  our $dist_lib = "$ENV{FIGCONFIG_RELEASE_DIR}/lib/$ENV{FIGCONFIG_ENV}";  # We are moving to use a symlink in dist/releases/current for these.
110    # This symlink is managed by switch_to_release.
111    #
112    #our $release_bin = "$ENV{FIGCONFIG_RELEASE_DIR}/bin/$ENV{FIGCONFIG_ENV}";
113    #our $release_lib = "$ENV{FIGCONFIG_RELEASE_DIR}/lib/$ENV{FIGCONFIG_ENV}";
114    
115    our $release_bin = "$fig_disk/dist/releases/current/$ENV{FIGCONFIG_ENV}/bin";
116    our $release_lib = "$fig_disk/dist/releases/current/$ENV{FIGCONFIG_ENV}/lib";
117    
118    our $fig_bin = "$fig_disk/FIG/bin";
119    
120  #  #
121  # Location of start/stop servers scripts.  # Location of start/stop servers scripts.
# Line 129  Line 136 
136      chomp $hostname;      chomp $hostname;
137    
138      push(@$Config, ["fig_disk", $fig_disk, 1]);      push(@$Config, ["fig_disk", $fig_disk, 1]);
139      push(@$Config, ["blastmast", "$fig_disk/BLASTMAT", 1]);      push(@$Config, ["blastmat", "$fig_disk/BLASTMAT", 1]);
140      push(@$Config, ["fig", $fig, 1]);      push(@$Config, ["fig", $fig, 1]);
141      push(@$Config, ["bin", $dist_bin, 1]);      push(@$Config, ["bin", $fig_bin, 1]);
142      push(@$Config, ["ext_bin", $env_bin, 1]);      push(@$Config, ["ext_bin", $env_bin, 1]);
143      push(@$Config, ["data", $data, 1]);      push(@$Config, ["data", $data, 1]);
144      push(@$Config, ["global", "$data/Global", 1]);      push(@$Config, ["global", "$data/Global", 1]);
# Line 139  Line 146 
146      push(@$Config, ["RC", "$fig_disk/FIG/ResolutionCenter", 1]);      push(@$Config, ["RC", "$fig_disk/FIG/ResolutionCenter", 1]);
147      push(@$Config, ["NR", "$fig_disk/FIG/NR", 1]);      push(@$Config, ["NR", "$fig_disk/FIG/NR", 1]);
148      push(@$Config, ["temp", "$fig_disk/FIG/Tmp", 1]);      push(@$Config, ["temp", "$fig_disk/FIG/Tmp", 1]);
149      push(@$Config, ["temp_url", "http://$hostname/FIG-Tmp", 1]);  
150      push(@$Config, ["cgi_url", "http://$hostname/FIG", 1]);      my $sandbox;
151        if ($ENV{FIGCONFIG_SANDBOX})
152        {
153            $sandbox = "/$ENV{FIGCONFIG_SANDBOX}";
154        }
155    
156        push(@$Config, ["temp_url", "http://$hostname$sandbox/FIG-Tmp", 1]);
157        push(@$Config, ["cgi_url", "http://$hostname$sandbox/FIG", 1]);
158    
159        #
160        # Add values for a relative base href of temp and CGI pages.  The latter
161        # is used by HHTP.pm to write common page start.  It would make the most
162        # sense to derive the above 2 values from these.  -- GJO
163        #
164    
165        push(@$Config, ["temp_base", "$sandbox/FIG-Tmp/", 1]);
166        push(@$Config, ["cgi_base", "$sandbox/FIG/", 1]);
167  }  }
168    
169  sub compute_environment  sub compute_environment
# Line 152  Line 175 
175      push(@$Env, ["RTROOT", $ENV{FIG_HOME}, 0]);      push(@$Env, ["RTROOT", $ENV{FIG_HOME}, 0]);
176      push(@$Env, ["RTDIST", "\$RTROOT/dist", 0]);      push(@$Env, ["RTDIST", "\$RTROOT/dist", 0]);
177      push(@$Env, ["RTARCH", $ENV{FIGCONFIG_ENV}, 0]);      push(@$Env, ["RTARCH", $ENV{FIGCONFIG_ENV}, 0]);
178      push(@$Env, ["RTCURRENT", $ENV{FIGCONFIG_RELEASE}, 0]);      push(@$Env, ["RTCURRENT", "`cat \$RTROOT/CURRENT_RELEASE`", 0]);
179      push(@$Env, ["FIG_HOME", $ENV{FIG_HOME}, 0]);      push(@$Env, ["FIG_HOME", $ENV{FIG_HOME}, 0]);
180    
181      push(@$Env, ["BLASTMAT", "$ENV{FIG_HOME}/BLASTMAT", 0]);      push(@$Env, ["BLASTMAT", "$ENV{FIG_HOME}/BLASTMAT", 0]);
# Line 166  Line 189 
189    
190      my @path = ();      my @path = ();
191      push(@path, $env_bin);      push(@path, $env_bin);
192      push(@path, $dist_bin);      push(@path, $fig_bin);
193      push(@path, "$fig_disk/bin");      push(@path, "$fig_disk/bin");
194    
195      push(@$Env, ["PATH", join(":", @path), 1]);      push(@$Env, ["PATH", join(":", @path), 1]);
196    
197      push(@$Env, ["LD_LIBRARY_PATH", "${env_lib}:${dist_lib}", 1]);      push(@$Env, ["LD_LIBRARY_PATH", "${env_lib}", 1]);
198    
199        push(@$Env, ["PERL5LIB", join(":", grep({ $_ ne "." } @INC)), 1]);
200  }  }
201    
202  sub configure_python  sub configure_python
# Line 194  Line 219 
219      chomp $py_version;      chomp $py_version;
220      print "Python version $py_version\n";      print "Python version $py_version\n";
221    
222        $OtherConfig->{python_site_path} = "$ENV{FIGCONFIG_ENV_DIR}/lib/python$py_version/site-packages";
223    
224      my @path = ();      my @path = ();
225      push(@path, "$ENV{FIGCONFIG_ENV_DIR}/lib/python$py_version/site-packages");      push(@path, $OtherConfig->{python_site_path});
226      push(@path, "$ENV{FIGCONFIG_RELEASE_DIR}/lib/$ENV{FIGCONFIG_ENV}");      push(@path, "$release_lib");
227      push(@path, "$fig_disk/config");      push(@path, "$fig_disk/config");
228      push(@$Env, ["PYTHONPATH", join(":", @path), 1]);      push(@$Env, ["PYTHONPATH", join(":", @path), 1]);
229    
# Line 205  Line 232 
232    
233  sub find_in_path  sub find_in_path
234  {  {
235      my($file) = @_;      my($file, @extra) = @_;
236      my(@path) = split(":", $ENV{PATH});      my(@path) = split(":", $ENV{PATH});
237    
238      for my $p (@path)      for my $p (@path, @extra)
239      {      {
240          my $x = "$p/$file";          my $x = "$p/$file";
241          if (-x $x)          if (-x $x)
# Line 229  Line 256 
256      #      #
257      # Special case for the mac.      # Special case for the mac.
258      #      #
259        # RDO 20040603 - don't do this any more; we want to pick up
260        # the python we ship.
261        #
262    
263      if ($ENV{FIGCONFIG_ENV} eq "mac")      if (0 && $ENV{FIGCONFIG_ENV} eq "mac")
264      {      {
265          if ($python = find_in_path("pythonw"))          #
266            # We'd like to use the MacPython that is installed
267            # as pythonw.
268            #
269            if ($python = find_in_path("pythonw", "/usr/local/bin"))
270          {          {
271                $OtherConfig->{python_require_poundbang_env} = 1;
272              return $python;              return $python;
273          }          }
274    
275          #          #
276          # Didn't find it in the path; we require the          # Otherwise, we can live with the regular python.
277          # MacPython build, and that installs into          # Fall thru to the generic case.
         # /usr/local/bin/pythonw by default.  
278          #          #
   
         return "/usr/local/bin/pythonw";  
279      }      }
     else  
     {  
280          #          #
281          # Non-mac, just look in the env dir or the path.          # Non-mac, just look in the env dir or the path.
282          #          #
# Line 259  Line 289 
289    
290          return find_in_path("python");          return find_in_path("python");
291      }      }
 }  
292    
293  #  #
294  # Find the name of the perl executable we are to use.  # Find the name of the perl executable we are to use.
# Line 297  Line 326 
326  if [ -n "\$$name" ] ; then  if [ -n "\$$name" ] ; then
327      DELIM=:      DELIM=:
328  fi  fi
329  $name=\${$name}\${DELIM}$value  $name=$value\${DELIM}\${$name}
330  export $name  export $name
331  END  END
332          }          }
# Line 325  Line 354 
354    
355              print $fh <<END;              print $fh <<END;
356  if (\$?$name) then  if (\$?$name) then
357      setenv $name \${$name}:$value      setenv $name $value:\${$name}
358  else  else
359      setenv $name $value      setenv $name $value
360  endif  endif
# Line 415  Line 444 
444    
445  }  }
446    
447    sub finalize_server_scripts
448    {
449        #
450        # After any environment-specific stuff, call start_services and stop_services.
451        #
452    
453        open(F, ">>$start_servers") or die "Cannot write $start_servers: $!";
454        print F "\n$fig_bin/start_services\n";
455        close(F);
456        chmod(0775, $start_servers);
457    
458        open(F, ">>$stop_servers") or die "Cannot write $stop_servers: $!";
459        print F "\n$fig_bin/stop_services\n";
460        close(F);
461        chmod(0775, $stop_servers);
462    
463    }
464    
465  sub write_config_pm  sub write_config_pm
466  {  {
467      my($fh, $config) = @_;      my($fh, $config) = @_;
# Line 473  Line 520 
520              next if $inc eq '.';              next if $inc eq '.';
521              print $fh "\t$inc\n";              print $fh "\t$inc\n";
522          }          }
523          print $fh ")\n";          print $fh ");\n";
524          print $fh "}\n";          print $fh "}\n";
525      }      }
526    
527      print $fh "use Data::Dumper;\n";      print $fh "use Data::Dumper;\n";
528      print $fh "use Carp;\n";      print $fh "use Carp;\n";
529    
530      print $fh "use lib \"$dist_lib\";\n";      #
531      print $fh "use lib \"$dist_lib/FigKernelPackages\";\n";      # We generate a comment here that gets expanded by switch_to_release
532        # This is part of the effort in making the environment bootstrapping
533        # code independent of releases.
534        #
535    
536        #print $fh "use lib \"$release_lib\";\n";
537        #print $fh "use lib \"$release_lib/FigKernelPackages\";\n";
538    
539        print $fh "# Following block is expanded by switch_to_release to add use lib directives\n";
540        print $fh "# to point at the correct locations in the release directory.\n";
541        print $fh "#BEGIN switch_to_release generated code\n";
542        print $fh "#END switch_to_release generated code\n";
543        print $fh "\n";
544    
545      print $fh "use lib \"$fig_disk/config\";\n";      print $fh "use lib \"$fig_disk/config\";\n";
546    
547      print $fh "use FIG_Config;\n";      print $fh "use FIG_Config;\n";
548      print $fh "\n";      print $fh "\n";
549        print $fh "#### END tool_hdr ####\n\n"
550  }  }
551    
552  sub write_tool_hdr_python  sub write_tool_hdr_python
# Line 494  Line 555 
555    
556      my $python = find_python();      my $python = find_python();
557    
558        if ($OtherConfig->{python_require_poundbang_env})
559        {
560            print $fh "#!/usr/bin/env $python\n";
561        }
562        else
563        {
564      print $fh "#!$python\n";      print $fh "#!$python\n";
565        }
566        print $fh "\n";
567    
568        print $fh "import sys, os\n";
569    
570    
571        print $fh "sys.path.append('$OtherConfig->{python_site_path}')\n";
572    
573        #
574        # Append the perl path to the environment, for use later with CallPerl.
575        #
576    
577        my $perlpath = join(":", @INC, "$fig_disk/config");
578        print $fh <<END;
579    if os.getenv("PERL5LIB", "") != "":
580        _delim = ":"
581    else:
582        _delim = ""
583    os.environ["PERL5LIB"] = "$perlpath" + _delim + os.getenv("PERL5LIB", "")
584    
585    END
586    
587        print $fh "# Following block is expanded by switch_to_release to add use lib directives\n";
588        print $fh "# to point at the correct locations in the release directory.\n";
589        print $fh "#BEGIN switch_to_release generated code\n";
590        print $fh "#END switch_to_release generated code\n";
591      print $fh "\n";      print $fh "\n";
592    
593      print $fh "import sys\n";      print $fh "sys.path.append('$fig_disk/config')\n";
594      my $pp = join(", ", map({ '"' . $_ . '"'} split(":", $OtherConfig->{pythonpath})));  
     print $fh "sys.path.extend(($pp))\n";  
595      print $fh "import FIG_Config\n";      print $fh "import FIG_Config\n";
596      print $fh "\n";      print $fh "\n";
597        print $fh "#### END tool_hdr_py ####\n\n"
598  }  }
599    
600  setup_directories("$fig_disk/bin",  setup_directories("$fig_disk/bin",
# Line 517  Line 610 
610  configure_python();  configure_python();
611  configure_environment_specific();  configure_environment_specific();
612    
613    finalize_server_scripts();
614    
615  #  #
616  # Write the shell startup to the figdisk.  # Write the shell startup to the figdisk.
617  #  #
# Line 544  Line 639 
639  # Write the tool headers  # Write the tool headers
640  #  #
641    
642  open(FH, ">$fig_disk/config/tool_hdr") or die "Cannot write $fig_disk/config/tool_hdr: $!";  open(FH, ">$fig_disk/config/base_tool_hdr") or die "Cannot write $fig_disk/config/tool_hdr: $!";
643  write_tool_hdr_perl(\*FH);  write_tool_hdr_perl(\*FH);
644  close(FH);  close(FH);
645    
646  open(FH, ">$fig_disk/config/tool_hdr_py") or die "Cannot write $fig_disk/config/tool_hdr_py: $!";  open(FH, ">$fig_disk/config/base_tool_hdr_py") or die "Cannot write $fig_disk/config/tool_hdr_py: $!";
647  write_tool_hdr_python(\*FH);  write_tool_hdr_python(\*FH);
648  close(FH);  close(FH);
649    
650  #  unshift(@INC, "$ENV{FIGCONFIG_RELEASE_DIR}");
651  # We have enough environment configured now to do a make.  
652  #  require FigCommon::SwitchRelease;
 # We use system and manually load the environment config so that it will  
 # work properly despite any user settings.  
 #  
653    
654  system("source $fig_disk/config/fig-user-env.sh; cd $ENV{FIGCONFIG_RELEASE_DIR}; make clean; make");  &FigCommon::SwitchRelease::switch_to_release($fig_disk, $ENV{FIGCONFIG_ENV}, $ENV{FIGCONFIG_RELEASE});

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.11

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3