[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.10, Thu Apr 1 12:59:40 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 141  Line 148 
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]);      push(@$Config, ["temp_url", "http://$hostname/FIG-Tmp", 1]);
150      push(@$Config, ["cgi_url", "http://$hostname/FIG", 1]);      push(@$Config, ["cgi_url", "http://$hostname/FIG", 1]);
151    
152        #
153        # Add values for a relative base href of temp and CGI pages.  The latter
154        # is used by HHTP.pm to write common page start.  It would make the most
155        # sense to derive the above 2 values from these.  -- GJO
156        #
157    
158        push(@$Config, ["temp_base", "/FIG-Tmp/", 1]);
159        push(@$Config, ["cgi_base", "/FIG/", 1]);
160  }  }
161    
162  sub compute_environment  sub compute_environment
# Line 152  Line 168 
168      push(@$Env, ["RTROOT", $ENV{FIG_HOME}, 0]);      push(@$Env, ["RTROOT", $ENV{FIG_HOME}, 0]);
169      push(@$Env, ["RTDIST", "\$RTROOT/dist", 0]);      push(@$Env, ["RTDIST", "\$RTROOT/dist", 0]);
170      push(@$Env, ["RTARCH", $ENV{FIGCONFIG_ENV}, 0]);      push(@$Env, ["RTARCH", $ENV{FIGCONFIG_ENV}, 0]);
171      push(@$Env, ["RTCURRENT", $ENV{FIGCONFIG_RELEASE}, 0]);      push(@$Env, ["RTCURRENT", "`cat \$RTROOT/CURRENT_RELEASE`", 0]);
172      push(@$Env, ["FIG_HOME", $ENV{FIG_HOME}, 0]);      push(@$Env, ["FIG_HOME", $ENV{FIG_HOME}, 0]);
173    
174      push(@$Env, ["BLASTMAT", "$ENV{FIG_HOME}/BLASTMAT", 0]);      push(@$Env, ["BLASTMAT", "$ENV{FIG_HOME}/BLASTMAT", 0]);
# Line 166  Line 182 
182    
183      my @path = ();      my @path = ();
184      push(@path, $env_bin);      push(@path, $env_bin);
185      push(@path, $dist_bin);      push(@path, $fig_bin);
186      push(@path, "$fig_disk/bin");      push(@path, "$fig_disk/bin");
187    
188      push(@$Env, ["PATH", join(":", @path), 1]);      push(@$Env, ["PATH", join(":", @path), 1]);
189    
190      push(@$Env, ["LD_LIBRARY_PATH", "${env_lib}:${dist_lib}", 1]);      push(@$Env, ["LD_LIBRARY_PATH", "${env_lib}", 1]);
191  }  }
192    
193  sub configure_python  sub configure_python
# Line 194  Line 210 
210      chomp $py_version;      chomp $py_version;
211      print "Python version $py_version\n";      print "Python version $py_version\n";
212    
213        $OtherConfig->{python_site_path} = "$ENV{FIGCONFIG_ENV_DIR}/lib/python$py_version/site-packages";
214    
215      my @path = ();      my @path = ();
216      push(@path, "$ENV{FIGCONFIG_ENV_DIR}/lib/python$py_version/site-packages");      push(@path, $OtherConfig->{python_site_path});
217      push(@path, "$ENV{FIGCONFIG_RELEASE_DIR}/lib/$ENV{FIGCONFIG_ENV}");      push(@path, "$release_lib");
218      push(@path, "$fig_disk/config");      push(@path, "$fig_disk/config");
219      push(@$Env, ["PYTHONPATH", join(":", @path), 1]);      push(@$Env, ["PYTHONPATH", join(":", @path), 1]);
220    
# Line 205  Line 223 
223    
224  sub find_in_path  sub find_in_path
225  {  {
226      my($file) = @_;      my($file, @extra) = @_;
227      my(@path) = split(":", $ENV{PATH});      my(@path) = split(":", $ENV{PATH});
228    
229      for my $p (@path)      for my $p (@path, @extra)
230      {      {
231          my $x = "$p/$file";          my $x = "$p/$file";
232          if (-x $x)          if (-x $x)
# Line 232  Line 250 
250    
251      if ($ENV{FIGCONFIG_ENV} eq "mac")      if ($ENV{FIGCONFIG_ENV} eq "mac")
252      {      {
253          if ($python = find_in_path("pythonw"))          #
254            # We'd like to use the MacPython that is installed
255            # as pythonw.
256            #
257            if ($python = find_in_path("pythonw", "/usr/local/bin"))
258          {          {
259                $OtherConfig->{python_require_poundbang_env} = 1;
260              return $python;              return $python;
261          }          }
262    
263          #          #
264          # Didn't find it in the path; we require the          # Otherwise, we can live with the regular python.
265          # MacPython build, and that installs into          # Fall thru to the generic case.
         # /usr/local/bin/pythonw by default.  
266          #          #
   
         return "/usr/local/bin/pythonw";  
267      }      }
     else  
     {  
268          #          #
269          # Non-mac, just look in the env dir or the path.          # Non-mac, just look in the env dir or the path.
270          #          #
# Line 259  Line 277 
277    
278          return find_in_path("python");          return find_in_path("python");
279      }      }
 }  
280    
281  #  #
282  # 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 314 
314  if [ -n "\$$name" ] ; then  if [ -n "\$$name" ] ; then
315      DELIM=:      DELIM=:
316  fi  fi
317  $name=\${$name}\${DELIM}$value  $name=$value\${DELIM}\${$name}
318  export $name  export $name
319  END  END
320          }          }
# Line 325  Line 342 
342    
343              print $fh <<END;              print $fh <<END;
344  if (\$?$name) then  if (\$?$name) then
345      setenv $name \${$name}:$value      setenv $name $value:\${$name}
346  else  else
347      setenv $name $value      setenv $name $value
348  endif  endif
# Line 415  Line 432 
432    
433  }  }
434    
435    sub finalize_server_scripts
436    {
437        #
438        # After any environment-specific stuff, call start_services and stop_services.
439        #
440    
441        open(F, ">>$start_servers") or die "Cannot write $start_servers: $!";
442        print F "\n$fig_bin/start_services\n";
443        close(F);
444        chmod(0775, $start_servers);
445    
446        open(F, ">>$stop_servers") or die "Cannot write $stop_servers: $!";
447        print F "\n$fig_bin/stop_services\n";
448        close(F);
449        chmod(0775, $stop_servers);
450    
451    }
452    
453  sub write_config_pm  sub write_config_pm
454  {  {
455      my($fh, $config) = @_;      my($fh, $config) = @_;
# Line 473  Line 508 
508              next if $inc eq '.';              next if $inc eq '.';
509              print $fh "\t$inc\n";              print $fh "\t$inc\n";
510          }          }
511          print $fh ")\n";          print $fh ");\n";
512          print $fh "}\n";          print $fh "}\n";
513      }      }
514    
515      print $fh "use Data::Dumper;\n";      print $fh "use Data::Dumper;\n";
516      print $fh "use Carp;\n";      print $fh "use Carp;\n";
517    
518      print $fh "use lib \"$dist_lib\";\n";      #
519      print $fh "use lib \"$dist_lib/FigKernelPackages\";\n";      # We generate a comment here that gets expanded by switch_to_release
520        # This is part of the effort in making the environment bootstrapping
521        # code independent of releases.
522        #
523    
524        #print $fh "use lib \"$release_lib\";\n";
525        #print $fh "use lib \"$release_lib/FigKernelPackages\";\n";
526    
527        print $fh "# Following block is expanded by switch_to_release to add use lib directives\n";
528        print $fh "# to point at the correct locations in the release directory.\n";
529        print $fh "#BEGIN switch_to_release generated code\n";
530        print $fh "#END switch_to_release generated code\n";
531        print $fh "\n";
532    
533      print $fh "use lib \"$fig_disk/config\";\n";      print $fh "use lib \"$fig_disk/config\";\n";
534    
535      print $fh "use FIG_Config;\n";      print $fh "use FIG_Config;\n";
# Line 494  Line 542 
542    
543      my $python = find_python();      my $python = find_python();
544    
545        if ($OtherConfig->{python_require_poundbang_env})
546        {
547            print $fh "#!/usr/bin/env $python\n";
548        }
549        else
550        {
551      print $fh "#!$python\n";      print $fh "#!$python\n";
552        }
553      print $fh "\n";      print $fh "\n";
554    
555      print $fh "import sys\n";      print $fh "import sys\n";
556      my $pp = join(", ", map({ '"' . $_ . '"'} split(":", $OtherConfig->{pythonpath})));  
557      print $fh "sys.path.extend(($pp))\n";  
558        print $fh "sys.path.append('$OtherConfig->{python_site_path}')\n";
559    
560        print $fh "# Following block is expanded by switch_to_release to add use lib directives\n";
561        print $fh "# to point at the correct locations in the release directory.\n";
562        print $fh "#BEGIN switch_to_release generated code\n";
563        print $fh "#END switch_to_release generated code\n";
564        print $fh "\n";
565    
566        print $fh "sys.path.append('$fig_disk/config')\n";
567    
568      print $fh "import FIG_Config\n";      print $fh "import FIG_Config\n";
569      print $fh "\n";      print $fh "\n";
570  }  }
# Line 517  Line 582 
582  configure_python();  configure_python();
583  configure_environment_specific();  configure_environment_specific();
584    
585    finalize_server_scripts();
586    
587  #  #
588  # Write the shell startup to the figdisk.  # Write the shell startup to the figdisk.
589  #  #
# Line 544  Line 611 
611  # Write the tool headers  # Write the tool headers
612  #  #
613    
614  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: $!";
615  write_tool_hdr_perl(\*FH);  write_tool_hdr_perl(\*FH);
616  close(FH);  close(FH);
617    
618  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: $!";
619  write_tool_hdr_python(\*FH);  write_tool_hdr_python(\*FH);
620  close(FH);  close(FH);
621    
622  #  unshift(@INC, "$ENV{FIGCONFIG_RELEASE_DIR}");
623  # We have enough environment configured now to do a make.  
624  #  require FigCommon::SwitchRelease;
 # We use system and manually load the environment config so that it will  
 # work properly despite any user settings.  
 #  
625    
626  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.10

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3