[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.3, Tue Dec 23 17:56:32 2003 UTC revision 1.23, Fri May 6 22:03:03 2005 UTC
# Line 102  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  #  #
# Line 111  Line 112 
112  #our $release_bin = "$ENV{FIGCONFIG_RELEASE_DIR}/bin/$ENV{FIGCONFIG_ENV}";  #our $release_bin = "$ENV{FIGCONFIG_RELEASE_DIR}/bin/$ENV{FIGCONFIG_ENV}";
113  #our $release_lib = "$ENV{FIGCONFIG_RELEASE_DIR}/lib/$ENV{FIGCONFIG_ENV}";  #our $release_lib = "$ENV{FIGCONFIG_RELEASE_DIR}/lib/$ENV{FIGCONFIG_ENV}";
114    
115  our $release_bin = "$fig_disk/dist/releases/current/bin/$ENV{FIGCONFIG_ENV}";  our $release_bin = "$fig_disk/dist/releases/current/$ENV{FIGCONFIG_ENV}/bin";
116  our $release_lib = "$fig_disk/dist/releases/current/lib/$ENV{FIGCONFIG_ENV}";  our $release_lib = "$fig_disk/dist/releases/current/$ENV{FIGCONFIG_ENV}/lib";
117    
118  our $fig_bin = "$fig_disk/FIG/bin";  our $fig_bin = "$fig_disk/FIG/bin";
119    
# Line 130  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", $fig_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, ["var", "$fig/var", 1]);
147      push(@$Config, ["data", $data, 1]);      push(@$Config, ["data", $data, 1]);
148      push(@$Config, ["global", "$data/Global", 1]);      push(@$Config, ["global", "$data/Global", 1]);
149      push(@$Config, ["organisms", "$data/Organisms", 1]);      push(@$Config, ["organisms", "$data/Organisms", 1]);
150      push(@$Config, ["RC", "$fig_disk/FIG/ResolutionCenter", 1]);      push(@$Config, ["RC", "$fig_disk/FIG/ResolutionCenter", 1]);
151      push(@$Config, ["NR", "$fig_disk/FIG/NR", 1]);      push(@$Config, ["NR", "$fig_disk/FIG/NR", 1]);
152      push(@$Config, ["temp", "$fig_disk/FIG/Tmp", 1]);      push(@$Config, ["temp", "$fig_disk/FIG/Tmp", 1]);
153      push(@$Config, ["temp_url", "http://$hostname/FIG-Tmp", 1]);      push(@$Config, ["sproutData", $sproutData, 1]);
154      push(@$Config, ["cgi_url", "http://$hostname/FIG", 1]);  
155        my $sandbox;
156        if ($ENV{FIGCONFIG_SANDBOX})
157        {
158            $sandbox = "/$ENV{FIGCONFIG_SANDBOX}";
159        }
160    
161        push(@$Config, ["temp_url", "http://$hostname$sandbox/FIG-Tmp", 1]);
162        push(@$Config, ["cgi_url", "http://$hostname$sandbox/FIG", 1]);
163    
164        #
165        # Add values for a relative base href of temp and CGI pages.  The latter
166        # is used by HHTP.pm to write common page start.  It would make the most
167        # sense to derive the above 2 values from these.  -- GJO
168        #
169    
170        push(@$Config, ["temp_base", "$sandbox/FIG-Tmp/", 1]);
171        push(@$Config, ["cgi_base", "$sandbox/FIG/", 1]);
172  }  }
173    
174  sub compute_environment  sub compute_environment
# Line 157  Line 179 
179    
180      push(@$Env, ["RTROOT", $ENV{FIG_HOME}, 0]);      push(@$Env, ["RTROOT", $ENV{FIG_HOME}, 0]);
181      push(@$Env, ["RTDIST", "\$RTROOT/dist", 0]);      push(@$Env, ["RTDIST", "\$RTROOT/dist", 0]);
182        push(@$Env, ["RTSITECONFIGDIR", "\$RTROOT/config", 0]);
183      push(@$Env, ["RTARCH", $ENV{FIGCONFIG_ENV}, 0]);      push(@$Env, ["RTARCH", $ENV{FIGCONFIG_ENV}, 0]);
184      push(@$Env, ["RTCURRENT", "`cat \$RTROOT/CURRENT_RELEASE`", 0]);      push(@$Env, ["RTCURRENT", "`cat \$RTROOT/CURRENT_RELEASE`", 0]);
185      push(@$Env, ["FIG_HOME", $ENV{FIG_HOME}, 0]);      push(@$Env, ["FIG_HOME", $ENV{FIG_HOME}, 0]);
# Line 178  Line 201 
201      push(@$Env, ["PATH", join(":", @path), 1]);      push(@$Env, ["PATH", join(":", @path), 1]);
202    
203      push(@$Env, ["LD_LIBRARY_PATH", "${env_lib}", 1]);      push(@$Env, ["LD_LIBRARY_PATH", "${env_lib}", 1]);
204    
205        my @perllib = grep({ $_ ne "." } @INC,
206                           $release_lib,
207                           "$release_lib/FigKernelPackages",
208                           "$fig_disk/config");
209    
210        push(@$Env, ["PERL5LIB", join(":", @perllib), 1]);
211  }  }
212    
213  sub configure_python  sub configure_python
# Line 200  Line 230 
230      chomp $py_version;      chomp $py_version;
231      print "Python version $py_version\n";      print "Python version $py_version\n";
232    
233      $OtherConfig->{python_site_path} = "$ENV{FIGCONFIG_ENV_DIR}/lib/python$py_version/site-packages";      #
234        # Python figures this out for us.
235        #$OtherConfig->{python_site_path} = "$ENV{FIGCONFIG_ENV_DIR}/lib/python$py_version/site-packages";
236    
237      my @path = ();      my @path = ();
238      push(@path, $OtherConfig->{python_site_path});      #push(@path, $OtherConfig->{python_site_path});
239      push(@path, "$release_lib");      push(@path, "$release_lib");
240      push(@path, "$fig_disk/config");      push(@path, "$fig_disk/config");
241      push(@$Env, ["PYTHONPATH", join(":", @path), 1]);      push(@$Env, ["PYTHONPATH", join(":", @path), 1]);
# Line 213  Line 245 
245    
246  sub find_in_path  sub find_in_path
247  {  {
248      my($file) = @_;      my($file, @extra) = @_;
249      my(@path) = split(":", $ENV{PATH});      my(@path) = split(":", $ENV{PATH});
250    
251      for my $p (@path)      for my $p (@path, @extra)
252      {      {
253          my $x = "$p/$file";          my $x = "$p/$file";
254          if (-x $x)          if (-x $x)
# Line 237  Line 269 
269      #      #
270      # Special case for the mac.      # Special case for the mac.
271      #      #
272        # RDO 20040603 - don't do this any more; we want to pick up
273        # the python we ship.
274        #
275    
276      if ($ENV{FIGCONFIG_ENV} eq "mac")      if (0 && $ENV{FIGCONFIG_ENV} eq "mac")
277      {      {
278          if ($python = find_in_path("pythonw"))          #
279            # We'd like to use the MacPython that is installed
280            # as pythonw.
281            #
282            if ($python = find_in_path("pythonw", "/usr/local/bin"))
283          {          {
284                $OtherConfig->{python_require_poundbang_env} = 1;
285              return $python;              return $python;
286          }          }
287    
288          #          #
289          # Didn't find it in the path; we require the          # Otherwise, we can live with the regular python.
290          # MacPython build, and that installs into          # Fall thru to the generic case.
         # /usr/local/bin/pythonw by default.  
291          #          #
   
         return "/usr/local/bin/pythonw";  
292      }      }
     else  
     {  
293          #          #
294          # Non-mac, just look in the env dir or the path.          # Non-mac, just look in the env dir or the path.
295          #          #
# Line 262  Line 297 
297          $python = "$ENV{FIGCONFIG_ENV_DIR}/bin/python";          $python = "$ENV{FIGCONFIG_ENV_DIR}/bin/python";
298          if (-x $python)          if (-x $python)
299          {          {
300            #
301            # The mac doesn't seem to like the long #! lines, so we'll use poundbang env.
302            #
303            if ($ENV{FIGCONFIG_ENV} =~ /^mac/)
304            {
305                $OtherConfig->{python_require_poundbang_env} = 1;
306            }
307              return $python;              return $python;
308          }          }
309    
310          return find_in_path("python");          return find_in_path("python");
311      }      }
 }  
312    
313  #  #
314  # Find the name of the perl executable we are to use.  # Find the name of the perl executable we are to use.
# Line 305  Line 346 
346  if [ -n "\$$name" ] ; then  if [ -n "\$$name" ] ; then
347      DELIM=:      DELIM=:
348  fi  fi
349  $name=\${$name}\${DELIM}$value  $name=$value\${DELIM}\${$name}
350  export $name  export $name
351  END  END
352          }          }
# Line 315  Line 356 
356              print $fh "export $name\n";              print $fh "export $name\n";
357          }          }
358      }      }
359        print $fh "alias rtpath='source \$RTDIST/releases/\$RTCURRENT/ReleaseTools/RTPath.sh'\n";
360  }  }
361    
362  sub write_csh_init  sub write_csh_init
# Line 333  Line 375 
375    
376              print $fh <<END;              print $fh <<END;
377  if (\$?$name) then  if (\$?$name) then
378      setenv $name \${$name}:$value      setenv $name $value:\${$name}
379  else  else
380      setenv $name $value      setenv $name $value
381  endif  endif
# Line 345  Line 387 
387          }          }
388      }      }
389    
390        #
391        # Alias for RT stuff.
392        #
393        print $fh "alias rtpath 'source \$RTDIST/releases/\$RTCURRENT/ReleaseTools/RTPath.csh'\n";
394  }  }
395    
396  sub run_script  sub run_script
# Line 423  Line 469 
469    
470  }  }
471    
472    sub finalize_server_scripts
473    {
474        #
475        # After any environment-specific stuff, call start_services and stop_services.
476        #
477    
478        open(F, ">>$start_servers") or die "Cannot write $start_servers: $!";
479        print F "\n$fig_bin/start_services\n";
480        close(F);
481        chmod(0775, $start_servers);
482    
483        open(F, ">>$stop_servers") or die "Cannot write $stop_servers: $!";
484        print F "\n$fig_bin/stop_services\n";
485        close(F);
486        chmod(0775, $stop_servers);
487    
488    }
489    
490  sub write_config_pm  sub write_config_pm
491  {  {
492      my($fh, $config) = @_;      my($fh, $config) = @_;
# Line 507  Line 571 
571    
572      print $fh "use FIG_Config;\n";      print $fh "use FIG_Config;\n";
573      print $fh "\n";      print $fh "\n";
574        print $fh "#### END tool_hdr ####\n\n"
575  }  }
576    
577  sub write_tool_hdr_python  sub write_tool_hdr_python
# Line 515  Line 580 
580    
581      my $python = find_python();      my $python = find_python();
582    
583        if ($OtherConfig->{python_require_poundbang_env})
584        {
585            print $fh "#!/usr/bin/env $python\n";
586        }
587        else
588        {
589      print $fh "#!$python\n";      print $fh "#!$python\n";
590        }
591      print $fh "\n";      print $fh "\n";
592    
593      print $fh "import sys\n";      print $fh "import sys, os\n";
594    
595    
596      print $fh "sys.path.append('$OtherConfig->{python_site_path}')\n";      print $fh "sys.path.append('$OtherConfig->{python_site_path}')\n";
597    
598        #
599        # Append the perl path to the environment, for use later with CallPerl.
600        #
601    
602        my $perlpath = join(":", @INC, $release_lib, "$release_lib/FigKernelPackages", "$fig_disk/config");
603        print $fh <<END;
604    if os.getenv("PERL5LIB", "") != "":
605        _delim = ":"
606    else:
607        _delim = ""
608    os.environ["PERL5LIB"] = "$perlpath" + _delim + os.getenv("PERL5LIB", "")
609    
610    END
611    
612      print $fh "# Following block is expanded by switch_to_release to add use lib directives\n";      print $fh "# Following block is expanded by switch_to_release to add use lib directives\n";
613      print $fh "# to point at the correct locations in the release directory.\n";      print $fh "# to point at the correct locations in the release directory.\n";
614      print $fh "#BEGIN switch_to_release generated code\n";      print $fh "#BEGIN switch_to_release generated code\n";
# Line 533  Line 619 
619    
620      print $fh "import FIG_Config\n";      print $fh "import FIG_Config\n";
621      print $fh "\n";      print $fh "\n";
622        print $fh "#### END tool_hdr_py ####\n\n"
623    }
624    
625    sub write_rtconfig
626    {
627        my($fh) = @_;
628    
629        my $python = find_python();
630        my $perl = find_perl();
631    
632        print $fh "RTPYTHON=$python\n";
633        print $fh "RTPERL=$perl\n";
634        print $fh "RTPYTHONPATH=$OtherConfig->{pythonpath}\n";
635    
636        my $perlpath = join(":", @INC, "$fig_disk/config");
637    
638        print $fh "RTPERL5LIB=$perlpath\n";
639    
640        print $fh "RTPYTHONIMPORTS=FIG_Config\n";
641        print $fh "RTPERLIMPORTS=FIG_Config\n";
642    
643  }  }
644    
645  setup_directories("$fig_disk/bin",  setup_directories("$fig_disk/bin",
# Line 547  Line 654 
654  configure_std_fig_environment();  configure_std_fig_environment();
655  configure_python();  configure_python();
656  configure_environment_specific();  configure_environment_specific();
657    # configure_database();
658    
659    finalize_server_scripts();
660    
661  #  #
662  # Write the shell startup to the figdisk.  # Write the shell startup to the figdisk.
# Line 583  Line 693 
693  write_tool_hdr_python(\*FH);  write_tool_hdr_python(\*FH);
694  close(FH);  close(FH);
695    
696    open(FH, ">$fig_disk/config/RTConfig") or die "Cannot write $fig_disk/config/RTConfig: $!";
697    write_rtconfig(\*FH);
698    close(FH);
699    
700  unshift(@INC, "$ENV{FIGCONFIG_RELEASE_DIR}");  unshift(@INC, "$ENV{FIGCONFIG_RELEASE_DIR}");
701    
702  require FigCommon::SwitchRelease;  require FigCommon::SwitchRelease;
703    
704    #
705    # We need to tweak the current path and PERL5LIB environment to get bootstrapping to
706    # work correctly.
707    #
708    
709    $ENV{PATH} = "$ENV{FIGCONFIG_ENVDIR}/bin:$ENV{PATH}";
710    
711    $ENV{PERL5LIB} = (map { $_->[1] } grep { $_->[0] eq "PERL5LIB"} @$Env)[0];
712    
713  &FigCommon::SwitchRelease::switch_to_release($fig_disk, $ENV{FIGCONFIG_ENV}, $ENV{FIGCONFIG_RELEASE});  &FigCommon::SwitchRelease::switch_to_release($fig_disk, $ENV{FIGCONFIG_ENV}, $ENV{FIGCONFIG_RELEASE});

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.23

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3