[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.29, Wed May 10 03:01:06 2006 UTC
# Line 1  Line 1 
1  #  #
2    # Copyright (c) 2003-2006 University of Chicago and Fellowship
3    # for Interpretations of Genomes. All Rights Reserved.
4    #
5    # This file is part of the SEED Toolkit.
6    #
7    # The SEED Toolkit is free software. You can redistribute
8    # it and/or modify it under the terms of the SEED Toolkit
9    # Public License.
10    #
11    # You should have received a copy of the SEED Toolkit Public License
12    # along with this program; if not write to the University of Chicago
13    # at info@ci.uchicago.edu or the Fellowship for Interpretation of
14    # Genomes at veronika@thefig.info or download a copy from
15    # http://www.theseed.org/LICENSE.TXT.
16    #
17    
18    #
19  # FIG bootstrap script.  # FIG bootstrap script.
20  #  #
21  # Control is passed here from the toplevel configure (or dists/releases/install depending  # Control is passed here from the toplevel configure (or dists/releases/install depending
# Line 36  Line 53 
53    
54      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";
55    
56      my $my_prefix, $prefix, $inc, @newInc;      my ($my_prefix, $prefix, $inc, @newInc);
57    
58      $my_prefix = $ENV{FIGCONFIG_ENV_DIR};      $my_prefix = $ENV{FIGCONFIG_ENV_DIR};
59      open(P, "<$my_prefix/PREFIX");      open(P, "<$my_prefix/PREFIX");
# Line 102  Line 119 
119    
120  our $fig_disk = $ENV{FIG_HOME};  our $fig_disk = $ENV{FIG_HOME};
121  our $env_name = $ENV{FIGCONFIG_ENV};  our $env_name = $ENV{FIGCONFIG_ENV};
122    our $env_dir = "$ENV{FIGCONFIG_ENV_DIR}";
123  our $env_bin = "$ENV{FIGCONFIG_ENV_DIR}/bin";  our $env_bin = "$ENV{FIGCONFIG_ENV_DIR}/bin";
124  our $env_lib = "$ENV{FIGCONFIG_ENV_DIR}/lib";  our $env_lib = "$ENV{FIGCONFIG_ENV_DIR}/lib";
125  #  #
# Line 111  Line 129 
129  #our $release_bin = "$ENV{FIGCONFIG_RELEASE_DIR}/bin/$ENV{FIGCONFIG_ENV}";  #our $release_bin = "$ENV{FIGCONFIG_RELEASE_DIR}/bin/$ENV{FIGCONFIG_ENV}";
130  #our $release_lib = "$ENV{FIGCONFIG_RELEASE_DIR}/lib/$ENV{FIGCONFIG_ENV}";  #our $release_lib = "$ENV{FIGCONFIG_RELEASE_DIR}/lib/$ENV{FIGCONFIG_ENV}";
131    
132  our $release_bin = "$fig_disk/dist/releases/current/bin/$ENV{FIGCONFIG_ENV}";  our $release_bin = "$fig_disk/dist/releases/current/$ENV{FIGCONFIG_ENV}/bin";
133  our $release_lib = "$fig_disk/dist/releases/current/lib/$ENV{FIGCONFIG_ENV}";  our $release_lib = "$fig_disk/dist/releases/current/$ENV{FIGCONFIG_ENV}/lib";
134    
135  our $fig_bin = "$fig_disk/FIG/bin";  our $fig_bin = "$fig_disk/FIG/bin";
136    
# Line 130  Line 148 
148    
149      my $fig = "$fig_disk/FIG";      my $fig = "$fig_disk/FIG";
150      my $data = "$fig/Data";      my $data = "$fig/Data";
151        my $sproutData = "$fig/SproutData";
152    
153      my $hostname = `hostname`;      my $hostname = `hostname`;
154      chomp $hostname;      chomp $hostname;
155    
156      push(@$Config, ["fig_disk", $fig_disk, 1]);      push(@$Config, ["fig_disk", $fig_disk, 1]);
157      push(@$Config, ["blastmast", "$fig_disk/BLASTMAT", 1]);      push(@$Config, ["blastmat", "$fig_disk/BLASTMAT", 1]);
158      push(@$Config, ["fig", $fig, 1]);      push(@$Config, ["fig", $fig, 1]);
159      push(@$Config, ["bin", $fig_bin, 1]);      push(@$Config, ["bin", $fig_bin, 1]);
160      push(@$Config, ["ext_bin", $env_bin, 1]);      push(@$Config, ["ext_bin", $env_bin, 1]);
161        push(@$Config, ["common_runtime", $env_dir, 1]);
162        push(@$Config, ["arch", $ENV{FIGCONFIG_ENV}, 1]);
163        push(@$Config, ["var", "$fig/var", 1]);
164      push(@$Config, ["data", $data, 1]);      push(@$Config, ["data", $data, 1]);
165      push(@$Config, ["global", "$data/Global", 1]);      push(@$Config, ["global", "$data/Global", 1]);
166      push(@$Config, ["organisms", "$data/Organisms", 1]);      push(@$Config, ["organisms", "$data/Organisms", 1]);
167      push(@$Config, ["RC", "$fig_disk/FIG/ResolutionCenter", 1]);      push(@$Config, ["RC", "$fig_disk/FIG/ResolutionCenter", 1]);
168      push(@$Config, ["NR", "$fig_disk/FIG/NR", 1]);      push(@$Config, ["NR", "$fig_disk/FIG/NR", 1]);
169      push(@$Config, ["temp", "$fig_disk/FIG/Tmp", 1]);      push(@$Config, ["temp", "$fig_disk/FIG/Tmp", 1]);
170      push(@$Config, ["temp_url", "http://$hostname/FIG-Tmp", 1]);      push(@$Config, ["sproutData", $sproutData, 1]);
171      push(@$Config, ["cgi_url", "http://$hostname/FIG", 1]);  
172        my $sandbox;
173        if ($ENV{FIGCONFIG_SANDBOX})
174        {
175            $sandbox = "/$ENV{FIGCONFIG_SANDBOX}";
176        }
177    
178        push(@$Config, ["temp_url", "http://$hostname$sandbox/FIG-Tmp", 1]);
179        push(@$Config, ["cgi_url", "http://$hostname$sandbox/FIG", 1]);
180    
181        #
182        # Add values for a relative base href of temp and CGI pages.  The latter
183        # is used by HHTP.pm to write common page start.  It would make the most
184        # sense to derive the above 2 values from these.  -- GJO
185        #
186    
187        push(@$Config, ["temp_base", "$sandbox/FIG-Tmp/", 1]);
188        push(@$Config, ["cgi_base", "$sandbox/FIG/", 1]);
189    
190  }  }
191    
192  sub compute_environment  sub compute_environment
# Line 157  Line 197 
197    
198      push(@$Env, ["RTROOT", $ENV{FIG_HOME}, 0]);      push(@$Env, ["RTROOT", $ENV{FIG_HOME}, 0]);
199      push(@$Env, ["RTDIST", "\$RTROOT/dist", 0]);      push(@$Env, ["RTDIST", "\$RTROOT/dist", 0]);
200        push(@$Env, ["RTSITECONFIGDIR", "\$RTROOT/config", 0]);
201      push(@$Env, ["RTARCH", $ENV{FIGCONFIG_ENV}, 0]);      push(@$Env, ["RTARCH", $ENV{FIGCONFIG_ENV}, 0]);
202      push(@$Env, ["RTCURRENT", "`cat \$RTROOT/CURRENT_RELEASE`", 0]);      push(@$Env, ["RTCURRENT", "`cat \$RTROOT/CURRENT_RELEASE`", 0]);
203      push(@$Env, ["FIG_HOME", $ENV{FIG_HOME}, 0]);      push(@$Env, ["FIG_HOME", $ENV{FIG_HOME}, 0]);
# Line 171  Line 212 
212      #      #
213    
214      my @path = ();      my @path = ();
     push(@path, $env_bin);  
215      push(@path, $fig_bin);      push(@path, $fig_bin);
216        push(@path, $env_bin);
217      push(@path, "$fig_disk/bin");      push(@path, "$fig_disk/bin");
218    
219      push(@$Env, ["PATH", join(":", @path), 1]);      push(@$Env, ["PATH", join(":", @path), 1]);
220    
221      push(@$Env, ["LD_LIBRARY_PATH", "${env_lib}", 1]);      #
222        # Compute  LD_LIBRARY_PATH.
223        #
224        # Some packages, like mysql, place their shared libs in subdirectories
225        # of the libdir.
226        #
227    
228        my @ld_path = ($env_lib);
229    
230        my $dh;
231        if (!opendir($dh, $env_lib))
232        {
233            warn "Could not opendir $env_lib: $!";
234        }
235    
236        while ($_ = readdir($dh))
237        {
238            next if /^\./;
239    
240            my $path = "$env_lib/$_";
241            next unless -d $path;
242    
243            #
244            # See if there are any .so's in here.
245            #
246    
247            my @solist = <$path/*.so*>;
248            if (@solist > 0)
249            {
250                push(@ld_path, $path);
251            }
252        }
253        closedir($dh);
254    
255        #
256        # And if perl is dynamically linked, we need to add the perl core directory
257        # to the path too.
258        #
259    
260        my @coredir = <$env_lib/perl5/*/*/CORE>;
261        if (@coredir)
262        {
263            if ( -f "$coredir[0]/libperl.so" )
264            {
265                print "Found libperl in $coredir[0]\n";
266                push(@ld_path, $coredir[0]);
267            }
268        }
269    
270        my $ld_path = join(":", @ld_path);
271        $OtherConfig->{ld_library_path} = $ld_path;
272    
273        push(@$Env, ["LD_LIBRARY_PATH", $ld_path, 1]);
274    
275        my @perllib = grep({ $_ ne "." } @INC,
276                           $release_lib,
277                           "$release_lib/FigKernelPackages",
278                           "$fig_disk/config");
279    
280        push(@$Env, ["PERL5LIB", join(":", @perllib), 1]);
281  }  }
282    
283  sub configure_python  sub configure_python
# Line 200  Line 300 
300      chomp $py_version;      chomp $py_version;
301      print "Python version $py_version\n";      print "Python version $py_version\n";
302    
303      $OtherConfig->{python_site_path} = "$ENV{FIGCONFIG_ENV_DIR}/lib/python$py_version/site-packages";      #
304        # Python figures this out for us.
305        #$OtherConfig->{python_site_path} = "$ENV{FIGCONFIG_ENV_DIR}/lib/python$py_version/site-packages";
306    
307      my @path = ();      my @path = ();
308      push(@path, $OtherConfig->{python_site_path});      #push(@path, $OtherConfig->{python_site_path});
309      push(@path, "$release_lib");      push(@path, "$release_lib");
310      push(@path, "$fig_disk/config");      push(@path, "$fig_disk/config");
311      push(@$Env, ["PYTHONPATH", join(":", @path), 1]);      push(@$Env, ["PYTHONPATH", join(":", @path), 1]);
# Line 213  Line 315 
315    
316  sub find_in_path  sub find_in_path
317  {  {
318      my($file) = @_;      my($file, @extra) = @_;
319      my(@path) = split(":", $ENV{PATH});      my(@path) = split(":", $ENV{PATH});
320    
321      for my $p (@path)      for my $p (@path, @extra)
322      {      {
323          my $x = "$p/$file";          my $x = "$p/$file";
324          if (-x $x)          if (-x $x)
# Line 237  Line 339 
339      #      #
340      # Special case for the mac.      # Special case for the mac.
341      #      #
342        # RDO 20040603 - don't do this any more; we want to pick up
343        # the python we ship.
344        #
345    
346      if ($ENV{FIGCONFIG_ENV} eq "mac")      if (0 && $ENV{FIGCONFIG_ENV} eq "mac")
347      {      {
348          if ($python = find_in_path("pythonw"))          #
349            # We'd like to use the MacPython that is installed
350            # as pythonw.
351            #
352            if ($python = find_in_path("pythonw", "/usr/local/bin"))
353          {          {
354                $OtherConfig->{python_require_poundbang_env} = 1;
355              return $python;              return $python;
356          }          }
357    
358          #          #
359          # Didn't find it in the path; we require the          # Otherwise, we can live with the regular python.
360          # MacPython build, and that installs into          # Fall thru to the generic case.
         # /usr/local/bin/pythonw by default.  
361          #          #
   
         return "/usr/local/bin/pythonw";  
362      }      }
     else  
     {  
363          #          #
364          # Non-mac, just look in the env dir or the path.          # Non-mac, just look in the env dir or the path.
365          #          #
# Line 262  Line 367 
367          $python = "$ENV{FIGCONFIG_ENV_DIR}/bin/python";          $python = "$ENV{FIGCONFIG_ENV_DIR}/bin/python";
368          if (-x $python)          if (-x $python)
369          {          {
370            #
371            # The mac doesn't seem to like the long #! lines, so we'll use poundbang env.
372            #
373            if ($ENV{FIGCONFIG_ENV} =~ /^mac/)
374            {
375                $OtherConfig->{python_require_poundbang_env} = 1;
376            }
377              return $python;              return $python;
378          }          }
379    
380          return find_in_path("python");          return find_in_path("python");
381      }      }
 }  
382    
383  #  #
384  # 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 416 
416  if [ -n "\$$name" ] ; then  if [ -n "\$$name" ] ; then
417      DELIM=:      DELIM=:
418  fi  fi
419  $name=\${$name}\${DELIM}$value  $name=$value\${DELIM}\${$name}
420  export $name  export $name
421  END  END
422          }          }
# Line 315  Line 426 
426              print $fh "export $name\n";              print $fh "export $name\n";
427          }          }
428      }      }
429        print $fh "alias rtpath='source \$RTDIST/releases/\$RTCURRENT/ReleaseTools/RTPath.sh'\n";
430  }  }
431    
432  sub write_csh_init  sub write_csh_init
# Line 333  Line 445 
445    
446              print $fh <<END;              print $fh <<END;
447  if (\$?$name) then  if (\$?$name) then
448      setenv $name \${$name}:$value      setenv $name $value:\${$name}
449  else  else
450      setenv $name $value      setenv $name $value
451  endif  endif
# Line 345  Line 457 
457          }          }
458      }      }
459    
460        #
461        # Alias for RT stuff.
462        #
463        print $fh "alias rtpath 'source \$RTDIST/releases/\$RTCURRENT/ReleaseTools/RTPath.csh'\n";
464  }  }
465    
466  sub run_script  sub run_script
# Line 423  Line 539 
539    
540  }  }
541    
542    sub finalize_server_scripts
543    {
544        #
545        # After any environment-specific stuff, call start_services and stop_services.
546        #
547    
548        open(F, ">>$start_servers") or die "Cannot write $start_servers: $!";
549        print F "\n$fig_bin/start_services\n";
550        close(F);
551        chmod(0775, $start_servers);
552    
553        open(F, ">>$stop_servers") or die "Cannot write $stop_servers: $!";
554        print F "\n$fig_bin/stop_services\n";
555        close(F);
556        chmod(0775, $stop_servers);
557    
558    }
559    
560  sub write_config_pm  sub write_config_pm
561  {  {
562      my($fh, $config) = @_;      my($fh, $config) = @_;
# Line 507  Line 641 
641    
642      print $fh "use FIG_Config;\n";      print $fh "use FIG_Config;\n";
643      print $fh "\n";      print $fh "\n";
644        print $fh "#### END tool_hdr ####\n\n"
645  }  }
646    
647  sub write_tool_hdr_python  sub write_tool_hdr_python
# Line 515  Line 650 
650    
651      my $python = find_python();      my $python = find_python();
652    
653        if ($OtherConfig->{python_require_poundbang_env})
654        {
655            print $fh "#!/usr/bin/env $python\n";
656        }
657        else
658        {
659      print $fh "#!$python\n";      print $fh "#!$python\n";
660        }
661      print $fh "\n";      print $fh "\n";
662    
663      print $fh "import sys\n";      print $fh "import sys, os\n";
664    
665    
666      print $fh "sys.path.append('$OtherConfig->{python_site_path}')\n";      print $fh "sys.path.append('$OtherConfig->{python_site_path}')\n";
667    
668        #
669        # Append the perl path to the environment, for use later with CallPerl.
670        #
671    
672        my $perlpath = join(":", @INC, $release_lib, "$release_lib/FigKernelPackages", "$fig_disk/config");
673        print $fh <<END;
674    if os.getenv("PERL5LIB", "") != "":
675        _delim = ":"
676    else:
677        _delim = ""
678    os.environ["PERL5LIB"] = "$perlpath" + _delim + os.getenv("PERL5LIB", "")
679    
680    END
681    
682      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";
683      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";
684      print $fh "#BEGIN switch_to_release generated code\n";      print $fh "#BEGIN switch_to_release generated code\n";
# Line 533  Line 689 
689    
690      print $fh "import FIG_Config\n";      print $fh "import FIG_Config\n";
691      print $fh "\n";      print $fh "\n";
692        print $fh "#### END tool_hdr_py ####\n\n"
693    }
694    
695    sub write_rtconfig
696    {
697        my($fh) = @_;
698    
699        my $python = find_python();
700        my $perl = find_perl();
701    
702        print $fh "RTPYTHON=$python\n";
703        print $fh "RTPERL=$perl\n";
704        print $fh "RTPYTHONPATH=$OtherConfig->{pythonpath}\n";
705    
706        my %seen;
707        my @perlpath;
708        for (@INC, "$fig_disk/config")
709        {
710            next if $seen{$_};
711            push(@perlpath, $_);
712            $seen{$_}++;
713        }
714        my $perlpath = join(":", @perlpath);
715    
716        print $fh "RTPERL5LIB=$perlpath\n";
717    
718        print $fh "RTPYTHONIMPORTS=FIG_Config\n";
719        print $fh "RTPERLIMPORTS=FIG_Config\n";
720        print $fh "RTSETENV=BLASTMAT=$fig_disk/BLASTMAT\n";
721        print $fh "RTSETENV=FIG_HOME=$fig_disk\n";
722        print $fh "#RTLD_LDPATH=$OtherConfig->{ld_library_path}\n";
723  }  }
724    
725  setup_directories("$fig_disk/bin",  setup_directories("$fig_disk/bin",
# Line 547  Line 734 
734  configure_std_fig_environment();  configure_std_fig_environment();
735  configure_python();  configure_python();
736  configure_environment_specific();  configure_environment_specific();
737    # configure_database();
738    
739    finalize_server_scripts();
740    
741  #  #
742  # Write the shell startup to the figdisk.  # Write the shell startup to the figdisk.
# Line 583  Line 773 
773  write_tool_hdr_python(\*FH);  write_tool_hdr_python(\*FH);
774  close(FH);  close(FH);
775    
776    open(FH, ">$fig_disk/config/RTConfig") or die "Cannot write $fig_disk/config/RTConfig: $!";
777    write_rtconfig(\*FH);
778    close(FH);
779    
780  unshift(@INC, "$ENV{FIGCONFIG_RELEASE_DIR}");  unshift(@INC, "$ENV{FIGCONFIG_RELEASE_DIR}");
781    
782  require FigCommon::SwitchRelease;  require FigCommon::SwitchRelease;
783    
784    #
785    # We need to tweak the current path and PERL5LIB environment to get bootstrapping to
786    # work correctly.
787    #
788    
789    $ENV{PATH} = "$ENV{FIGCONFIG_ENVDIR}/bin:$ENV{PATH}";
790    
791    $ENV{PERL5LIB} = (map { $_->[1] } grep { $_->[0] eq "PERL5LIB"} @$Env)[0];
792    
793  &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.29

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3