[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.21, Mon Mar 7 17:23:31 2005 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 124  Line 131 
131    
132      my $fig = "$fig_disk/FIG";      my $fig = "$fig_disk/FIG";
133      my $data = "$fig/Data";      my $data = "$fig/Data";
134        my $sproutData = "$fig/SproutData";
135    
136      my $hostname = `hostname`;      my $hostname = `hostname`;
137      chomp $hostname;      chomp $hostname;
138    
139      push(@$Config, ["fig_disk", $fig_disk, 1]);      push(@$Config, ["fig_disk", $fig_disk, 1]);
140      push(@$Config, ["blastmast", "$fig_disk/BLASTMAT", 1]);      push(@$Config, ["blastmat", "$fig_disk/BLASTMAT", 1]);
141      push(@$Config, ["fig", $fig, 1]);      push(@$Config, ["fig", $fig, 1]);
142      push(@$Config, ["bin", $dist_bin, 1]);      push(@$Config, ["bin", $fig_bin, 1]);
143      push(@$Config, ["ext_bin", $env_bin, 1]);      push(@$Config, ["ext_bin", $env_bin, 1]);
144        push(@$Config, ["common_runtime", $env_dir, 1]);
145        push(@$Config, ["arch", $ENV{FIGCONFIG_ENV}, 1]);
146      push(@$Config, ["data", $data, 1]);      push(@$Config, ["data", $data, 1]);
147      push(@$Config, ["global", "$data/Global", 1]);      push(@$Config, ["global", "$data/Global", 1]);
148      push(@$Config, ["organisms", "$data/Organisms", 1]);      push(@$Config, ["organisms", "$data/Organisms", 1]);
149      push(@$Config, ["RC", "$fig_disk/FIG/ResolutionCenter", 1]);      push(@$Config, ["RC", "$fig_disk/FIG/ResolutionCenter", 1]);
150      push(@$Config, ["NR", "$fig_disk/FIG/NR", 1]);      push(@$Config, ["NR", "$fig_disk/FIG/NR", 1]);
151      push(@$Config, ["temp", "$fig_disk/FIG/Tmp", 1]);      push(@$Config, ["temp", "$fig_disk/FIG/Tmp", 1]);
152      push(@$Config, ["temp_url", "http://$hostname/FIG-Tmp", 1]);      push(@$Config, ["sproutData", $sproutData, 1]);
153      push(@$Config, ["cgi_url", "http://$hostname/FIG", 1]);  
154        my $sandbox;
155        if ($ENV{FIGCONFIG_SANDBOX})
156        {
157            $sandbox = "/$ENV{FIGCONFIG_SANDBOX}";
158        }
159    
160        push(@$Config, ["temp_url", "http://$hostname$sandbox/FIG-Tmp", 1]);
161        push(@$Config, ["cgi_url", "http://$hostname$sandbox/FIG", 1]);
162    
163        #
164        # Add values for a relative base href of temp and CGI pages.  The latter
165        # is used by HHTP.pm to write common page start.  It would make the most
166        # sense to derive the above 2 values from these.  -- GJO
167        #
168    
169        push(@$Config, ["temp_base", "$sandbox/FIG-Tmp/", 1]);
170        push(@$Config, ["cgi_base", "$sandbox/FIG/", 1]);
171  }  }
172    
173  sub compute_environment  sub compute_environment
# Line 152  Line 179 
179      push(@$Env, ["RTROOT", $ENV{FIG_HOME}, 0]);      push(@$Env, ["RTROOT", $ENV{FIG_HOME}, 0]);
180      push(@$Env, ["RTDIST", "\$RTROOT/dist", 0]);      push(@$Env, ["RTDIST", "\$RTROOT/dist", 0]);
181      push(@$Env, ["RTARCH", $ENV{FIGCONFIG_ENV}, 0]);      push(@$Env, ["RTARCH", $ENV{FIGCONFIG_ENV}, 0]);
182      push(@$Env, ["RTCURRENT", $ENV{FIGCONFIG_RELEASE}, 0]);      push(@$Env, ["RTCURRENT", "`cat \$RTROOT/CURRENT_RELEASE`", 0]);
183      push(@$Env, ["FIG_HOME", $ENV{FIG_HOME}, 0]);      push(@$Env, ["FIG_HOME", $ENV{FIG_HOME}, 0]);
184    
185      push(@$Env, ["BLASTMAT", "$ENV{FIG_HOME}/BLASTMAT", 0]);      push(@$Env, ["BLASTMAT", "$ENV{FIG_HOME}/BLASTMAT", 0]);
# Line 166  Line 193 
193    
194      my @path = ();      my @path = ();
195      push(@path, $env_bin);      push(@path, $env_bin);
196      push(@path, $dist_bin);      push(@path, $fig_bin);
197      push(@path, "$fig_disk/bin");      push(@path, "$fig_disk/bin");
198    
199      push(@$Env, ["PATH", join(":", @path), 1]);      push(@$Env, ["PATH", join(":", @path), 1]);
200    
201      push(@$Env, ["LD_LIBRARY_PATH", "${env_lib}:${dist_lib}", 1]);      push(@$Env, ["LD_LIBRARY_PATH", "${env_lib}", 1]);
202    
203        my @perllib = grep({ $_ ne "." } @INC, "$fig_disk/config", $release_lib,
204                          "$release_lib/FigKernelPackages");
205    
206        push(@$Env, ["PERL5LIB", join(":", @perllib), 1]);
207  }  }
208    
209  sub configure_python  sub configure_python
# Line 194  Line 226 
226      chomp $py_version;      chomp $py_version;
227      print "Python version $py_version\n";      print "Python version $py_version\n";
228    
229        $OtherConfig->{python_site_path} = "$ENV{FIGCONFIG_ENV_DIR}/lib/python$py_version/site-packages";
230    
231      my @path = ();      my @path = ();
232      push(@path, "$ENV{FIGCONFIG_ENV_DIR}/lib/python$py_version/site-packages");      push(@path, $OtherConfig->{python_site_path});
233      push(@path, "$ENV{FIGCONFIG_RELEASE_DIR}/lib/$ENV{FIGCONFIG_ENV}");      push(@path, "$release_lib");
234      push(@path, "$fig_disk/config");      push(@path, "$fig_disk/config");
235      push(@$Env, ["PYTHONPATH", join(":", @path), 1]);      push(@$Env, ["PYTHONPATH", join(":", @path), 1]);
236    
# Line 205  Line 239 
239    
240  sub find_in_path  sub find_in_path
241  {  {
242      my($file) = @_;      my($file, @extra) = @_;
243      my(@path) = split(":", $ENV{PATH});      my(@path) = split(":", $ENV{PATH});
244    
245      for my $p (@path)      for my $p (@path, @extra)
246      {      {
247          my $x = "$p/$file";          my $x = "$p/$file";
248          if (-x $x)          if (-x $x)
# Line 229  Line 263 
263      #      #
264      # Special case for the mac.      # Special case for the mac.
265      #      #
266        # RDO 20040603 - don't do this any more; we want to pick up
267        # the python we ship.
268        #
269    
270      if ($ENV{FIGCONFIG_ENV} eq "mac")      if (0 && $ENV{FIGCONFIG_ENV} eq "mac")
271      {      {
272          if ($python = find_in_path("pythonw"))          #
273            # We'd like to use the MacPython that is installed
274            # as pythonw.
275            #
276            if ($python = find_in_path("pythonw", "/usr/local/bin"))
277          {          {
278                $OtherConfig->{python_require_poundbang_env} = 1;
279              return $python;              return $python;
280          }          }
281    
282          #          #
283          # Didn't find it in the path; we require the          # Otherwise, we can live with the regular python.
284          # MacPython build, and that installs into          # Fall thru to the generic case.
         # /usr/local/bin/pythonw by default.  
285          #          #
   
         return "/usr/local/bin/pythonw";  
286      }      }
     else  
     {  
287          #          #
288          # Non-mac, just look in the env dir or the path.          # Non-mac, just look in the env dir or the path.
289          #          #
# Line 254  Line 291 
291          $python = "$ENV{FIGCONFIG_ENV_DIR}/bin/python";          $python = "$ENV{FIGCONFIG_ENV_DIR}/bin/python";
292          if (-x $python)          if (-x $python)
293          {          {
294            #
295            # The mac doesn't seem to like the long #! lines, so we'll use poundbang env.
296            #
297            if ($ENV{FIGCONFIG_ENV} =~ /^mac/)
298            {
299                $OtherConfig->{python_require_poundbang_env} = 1;
300            }
301              return $python;              return $python;
302          }          }
303    
304          return find_in_path("python");          return find_in_path("python");
305      }      }
 }  
306    
307  #  #
308  # 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 340 
340  if [ -n "\$$name" ] ; then  if [ -n "\$$name" ] ; then
341      DELIM=:      DELIM=:
342  fi  fi
343  $name=\${$name}\${DELIM}$value  $name=$value\${DELIM}\${$name}
344  export $name  export $name
345  END  END
346          }          }
# Line 307  Line 350 
350              print $fh "export $name\n";              print $fh "export $name\n";
351          }          }
352      }      }
353        print $fh "alias rtpath='source \$RTDIST/releases/\$RTCURRENT/ReleaseTools/RTPath.sh'\n";
354  }  }
355    
356  sub write_csh_init  sub write_csh_init
# Line 325  Line 369 
369    
370              print $fh <<END;              print $fh <<END;
371  if (\$?$name) then  if (\$?$name) then
372      setenv $name \${$name}:$value      setenv $name $value:\${$name}
373  else  else
374      setenv $name $value      setenv $name $value
375  endif  endif
# Line 337  Line 381 
381          }          }
382      }      }
383    
384        #
385        # Alias for RT stuff.
386        #
387        print $fh "alias rtpath 'source \$RTDIST/releases/\$RTCURRENT/ReleaseTools/RTPath.csh'\n";
388  }  }
389    
390  sub run_script  sub run_script
# Line 415  Line 463 
463    
464  }  }
465    
466    sub finalize_server_scripts
467    {
468        #
469        # After any environment-specific stuff, call start_services and stop_services.
470        #
471    
472        open(F, ">>$start_servers") or die "Cannot write $start_servers: $!";
473        print F "\n$fig_bin/start_services\n";
474        close(F);
475        chmod(0775, $start_servers);
476    
477        open(F, ">>$stop_servers") or die "Cannot write $stop_servers: $!";
478        print F "\n$fig_bin/stop_services\n";
479        close(F);
480        chmod(0775, $stop_servers);
481    
482    }
483    
484  sub write_config_pm  sub write_config_pm
485  {  {
486      my($fh, $config) = @_;      my($fh, $config) = @_;
# Line 473  Line 539 
539              next if $inc eq '.';              next if $inc eq '.';
540              print $fh "\t$inc\n";              print $fh "\t$inc\n";
541          }          }
542          print $fh ")\n";          print $fh ");\n";
543          print $fh "}\n";          print $fh "}\n";
544      }      }
545    
546      print $fh "use Data::Dumper;\n";      print $fh "use Data::Dumper;\n";
547      print $fh "use Carp;\n";      print $fh "use Carp;\n";
548    
549      print $fh "use lib \"$dist_lib\";\n";      #
550      print $fh "use lib \"$dist_lib/FigKernelPackages\";\n";      # We generate a comment here that gets expanded by switch_to_release
551        # This is part of the effort in making the environment bootstrapping
552        # code independent of releases.
553        #
554    
555        #print $fh "use lib \"$release_lib\";\n";
556        #print $fh "use lib \"$release_lib/FigKernelPackages\";\n";
557    
558        print $fh "# Following block is expanded by switch_to_release to add use lib directives\n";
559        print $fh "# to point at the correct locations in the release directory.\n";
560        print $fh "#BEGIN switch_to_release generated code\n";
561        print $fh "#END switch_to_release generated code\n";
562        print $fh "\n";
563    
564      print $fh "use lib \"$fig_disk/config\";\n";      print $fh "use lib \"$fig_disk/config\";\n";
565    
566      print $fh "use FIG_Config;\n";      print $fh "use FIG_Config;\n";
567      print $fh "\n";      print $fh "\n";
568        print $fh "#### END tool_hdr ####\n\n"
569  }  }
570    
571  sub write_tool_hdr_python  sub write_tool_hdr_python
# Line 494  Line 574 
574    
575      my $python = find_python();      my $python = find_python();
576    
577        if ($OtherConfig->{python_require_poundbang_env})
578        {
579            print $fh "#!/usr/bin/env $python\n";
580        }
581        else
582        {
583      print $fh "#!$python\n";      print $fh "#!$python\n";
584        }
585        print $fh "\n";
586    
587        print $fh "import sys, os\n";
588    
589    
590        print $fh "sys.path.append('$OtherConfig->{python_site_path}')\n";
591    
592        #
593        # Append the perl path to the environment, for use later with CallPerl.
594        #
595    
596        my $perlpath = join(":", @INC, "$fig_disk/config", $release_lib, "$release_lib/FigKernelPackages");
597        print $fh <<END;
598    if os.getenv("PERL5LIB", "") != "":
599        _delim = ":"
600    else:
601        _delim = ""
602    os.environ["PERL5LIB"] = "$perlpath" + _delim + os.getenv("PERL5LIB", "")
603    
604    END
605    
606        print $fh "# Following block is expanded by switch_to_release to add use lib directives\n";
607        print $fh "# to point at the correct locations in the release directory.\n";
608        print $fh "#BEGIN switch_to_release generated code\n";
609        print $fh "#END switch_to_release generated code\n";
610      print $fh "\n";      print $fh "\n";
611    
612      print $fh "import sys\n";      print $fh "sys.path.append('$fig_disk/config')\n";
613      my $pp = join(", ", map({ '"' . $_ . '"'} split(":", $OtherConfig->{pythonpath})));  
     print $fh "sys.path.extend(($pp))\n";  
614      print $fh "import FIG_Config\n";      print $fh "import FIG_Config\n";
615      print $fh "\n";      print $fh "\n";
616        print $fh "#### END tool_hdr_py ####\n\n"
617  }  }
618    
619  setup_directories("$fig_disk/bin",  setup_directories("$fig_disk/bin",
# Line 516  Line 628 
628  configure_std_fig_environment();  configure_std_fig_environment();
629  configure_python();  configure_python();
630  configure_environment_specific();  configure_environment_specific();
631    # configure_database();
632    
633    finalize_server_scripts();
634    
635  #  #
636  # Write the shell startup to the figdisk.  # Write the shell startup to the figdisk.
# Line 544  Line 659 
659  # Write the tool headers  # Write the tool headers
660  #  #
661    
662  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: $!";
663  write_tool_hdr_perl(\*FH);  write_tool_hdr_perl(\*FH);
664  close(FH);  close(FH);
665    
666  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: $!";
667  write_tool_hdr_python(\*FH);  write_tool_hdr_python(\*FH);
668  close(FH);  close(FH);
669    
670    unshift(@INC, "$ENV{FIGCONFIG_RELEASE_DIR}");
671    
672    require FigCommon::SwitchRelease;
673    
674  #  #
675  # We have enough environment configured now to do a make.  # We need to tweak the current path and PERL5LIB environment to get bootstrapping to
676  #  # work correctly.
 # We use system and manually load the environment config so that it will  
 # work properly despite any user settings.  
677  #  #
678    
679  system("source $fig_disk/config/fig-user-env.sh; cd $ENV{FIGCONFIG_RELEASE_DIR}; make clean; make");  $ENV{PATH} = "$ENV{FIGCONFIG_ENVDIR}/bin:$ENV{PATH}";
680    
681    $ENV{PERL5LIB} = (map { $_->[1] } grep { $_->[0] eq "PERL5LIB"} @$Env)[0];
682    
683    &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.21

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3