[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.30, Tue Jan 16 22:07:49 2007 UTC revision 1.31, Tue Nov 27 23:16:21 2007 UTC
# Line 24  Line 24 
24  # The configure has set the following environment variables for our use:  # The configure has set the following environment variables for our use:
25  #  #
26  #  FIG_HOME             Root of the FIGdisk tree we're setting up  #  FIG_HOME             Root of the FIGdisk tree we're setting up
27    #  FIGCONFIG_ENV_TYPE   Type of configuration environment - "config_file"  for config file with host-type->directory
28    #                       mappings, or "dir" tranditional single-environment configuration.
29  #  FIGCONFIG_ENV        Name of the environment we're configuring for  #  FIGCONFIG_ENV        Name of the environment we're configuring for
30    #  FIGCONFIG_ENV_CONFIG Location of enviroment configuration file.
31  #  FIGCONFIG_ENV_DIR    Directory in which the binary install tree for $FIGCONFIG_ENV lives  #  FIGCONFIG_ENV_DIR    Directory in which the binary install tree for $FIGCONFIG_ENV lives
32  #  FIGCONFIG_RELEASE    Release number we're configuring  #  FIGCONFIG_RELEASE    Release number we're configuring
33  #  FIGCONFIG_RELEASE_DIR Directory in which that release lives  #  FIGCONFIG_RELEASE_DIR Directory in which that release lives
# Line 118  Line 121 
121  #  #
122    
123  our $fig_disk = $ENV{FIG_HOME};  our $fig_disk = $ENV{FIG_HOME};
124    our $env_config_type = $ENV{FIGCONFIG_ENV_CONFIG_TYPE};
125    our $env_config_file = $ENV{FIGCONFIG_ENV_CONFIG_FILE};
126  our $env_name = $ENV{FIGCONFIG_ENV};  our $env_name = $ENV{FIGCONFIG_ENV};
127  our $env_dir = "$ENV{FIGCONFIG_ENV_DIR}";  our $env_dir = "$ENV{FIGCONFIG_ENV_DIR}";
128  our $env_bin = "$ENV{FIGCONFIG_ENV_DIR}/bin";  our $env_bin = "$ENV{FIGCONFIG_ENV_DIR}/bin";
# Line 139  Line 144 
144  #  #
145  our $start_servers = "$fig_disk/bin/start-servers";  our $start_servers = "$fig_disk/bin/start-servers";
146  our $stop_servers = "$fig_disk/bin/stop-servers";  our $stop_servers = "$fig_disk/bin/stop-servers";
147    our $run_perl = "$fig_disk/bin/run_perl";
148    
149  sub configure_std_fig_environment  sub configure_std_fig_environment
150  {  {
# Line 157  Line 163 
163      push(@$Config, ["blastmat", "$fig_disk/BLASTMAT", 1]);      push(@$Config, ["blastmat", "$fig_disk/BLASTMAT", 1]);
164      push(@$Config, ["fig", $fig, 1]);      push(@$Config, ["fig", $fig, 1]);
165      push(@$Config, ["bin", $fig_bin, 1]);      push(@$Config, ["bin", $fig_bin, 1]);
166        push(@$Config, ["env_config_type", $env_config_type, 1]);
167        if ($env_config_type eq 'config_file')
168        {
169            push(@$Config, ["env_config_file", $env_config_file, 1]);
170            push(@$Config, [{ perl => '&compute_env_values; ', python => '' }]);
171        }
172        else
173        {
174      push(@$Config, ["ext_bin", $env_bin, 1]);      push(@$Config, ["ext_bin", $env_bin, 1]);
175      push(@$Config, ["common_runtime", $env_dir, 1]);      push(@$Config, ["common_runtime", $env_dir, 1]);
176        }
177      push(@$Config, ["arch", $ENV{FIGCONFIG_ENV}, 1]);      push(@$Config, ["arch", $ENV{FIGCONFIG_ENV}, 1]);
178      push(@$Config, ["var", "$fig/var", 1]);      push(@$Config, ["var", "$fig/var", 1]);
179      push(@$Config, ["data", $data, 1]);      push(@$Config, ["data", $data, 1]);
# Line 187  Line 202 
202      push(@$Config, ["temp_base", "$sandbox/FIG-Tmp/", 1]);      push(@$Config, ["temp_base", "$sandbox/FIG-Tmp/", 1]);
203      push(@$Config, ["cgi_base", "$sandbox/FIG/", 1]);      push(@$Config, ["cgi_base", "$sandbox/FIG/", 1]);
204    
205        push(@$Config, [ { perl => <<'END' }]);
206    sub compute_env_values
207    {
208        return if defined($FIG_Config::hosttype);
209    
210        my $hosttype = `bash -c 'echo \$HOSTTYPE'`;
211        if ($hosttype eq '')
212        {
213            die "Error retrieving hosttype; bash failed with rc=$?";
214        }
215        chomp $hosttype;
216        open(CF, "<$FIG_Config::env_config_file") or
217            die "Cannot open $FIG_Config::env_config_file: $!";
218        my $found;
219        while (<CF>)
220        {
221            if (/^$hosttype\t(\S+)/)
222            {
223                $found++;
224                $FIG_Config::common_runtime = $1;
225                $FIG_Config::env_bin = "$1/bin";
226                $FIG_Config::hosttype = $hosttype;
227                $found++;
228                last;
229            }
230        }
231        $found or die "Could not find binary directory for hosttype $hosttype in $FIG_Config::env_config_file";
232    }
233    END
234  }  }
235    
236  sub compute_environment  sub compute_environment
# Line 213  Line 257 
257    
258      my @path = ();      my @path = ();
259      push(@path, $fig_bin);      push(@path, $fig_bin);
260        if ($env_config_type eq 'dir')
261        {
262      push(@path, $env_bin);      push(@path, $env_bin);
263        }
264      push(@path, "$fig_disk/bin");      push(@path, "$fig_disk/bin");
265    
266      push(@$Env, ["PATH", join(":", @path), 1]);      push(@$Env, ["PATH", join(":", @path), 1]);
# Line 224  Line 271 
271      # Some packages, like mysql, place their shared libs in subdirectories      # Some packages, like mysql, place their shared libs in subdirectories
272      # of the libdir.      # of the libdir.
273      #      #
274        # We can only do this if we're configured with an env dir.
275        #
276    
277        if ($env_config_type eq 'dir')
278        {
279      my @ld_path = ($env_lib);      my @ld_path = ($env_lib);
280    
281      my $dh;      my $dh;
# Line 271  Line 322 
322      $OtherConfig->{ld_library_path} = $ld_path;      $OtherConfig->{ld_library_path} = $ld_path;
323    
324      push(@$Env, ["LD_LIBRARY_PATH", $ld_path, 1]);      push(@$Env, ["LD_LIBRARY_PATH", $ld_path, 1]);
325        }
326    
327        #
328        # If we're configuring with an env dir, we start with our @INC that we
329        # found. Otherwise we just append.
330        #
331    
332      my @perllib = grep({ $_ ne "." } @INC,      my @perllib;
333        if ($env_config_type eq 'dir')
334        {
335            @perllib = grep({ $_ ne "." } @INC);
336        }
337    
338        push(@perllib,
339                         $release_lib,                         $release_lib,
340                         "$release_lib/FigKernelPackages",                         "$release_lib/FigKernelPackages",
341                         "$release_lib/WebApplication",                         "$release_lib/WebApplication",
# Line 390  Line 453 
453  {  {
454      my $perl;      my $perl;
455    
456        if ($env_config_type eq 'config_file')
457        {
458            return $run_perl;
459        }
460    
461      $perl = "$ENV{FIGCONFIG_ENV_DIR}/bin/perl";      $perl = "$ENV{FIGCONFIG_ENV_DIR}/bin/perl";
462      if (-x $perl)      if (-x $perl)
463      {      {
# Line 429  Line 497 
497              print $fh "export $name\n";              print $fh "export $name\n";
498          }          }
499      }      }
500    
501        #
502        # If we're configuring from a config file, add the code to set up the PATH with the
503        # right ext_bin.
504        #
505        if ($env_config_type eq 'config_file')
506        {
507            print $fh "export FIG_ENV_CONFIG_FILE='$env_config_file'\n";
508            print $fh <<'END';
509    env_dir=`awk "\\$1 == \"$HOSTTYPE\" { print \\$2 }" $FIG_ENV_CONFIG_FILE`
510    export PATH=$env_dir/bin:${PATH}
511    END
512        }
513    
514      print $fh "alias rtpath='source \$RTDIST/releases/\$RTCURRENT/ReleaseTools/RTPath.sh'\n";      print $fh "alias rtpath='source \$RTDIST/releases/\$RTCURRENT/ReleaseTools/RTPath.sh'\n";
515  }  }
516    
# Line 542  Line 624 
624    
625  }  }
626    
627    sub write_run_perl
628    {
629        unlink($run_perl);
630        open(F, ">$run_perl") or die "Cannot write $run_perl: $!";
631    
632        print F "#!/bin/sh\n\n";
633    
634        print F ". $fig_disk/config/fig-user-env.sh\n\n";
635    
636        if ($env_config_type eq 'config_file')
637        {
638            print F <<'END';
639    env_dir=`awk "\\$1 == \"$HOSTTYPE\" { print \\$2 }" $FIG_ENV_CONFIG_FILE`
640    perl="$env_dir/bin/perl"
641    END
642        }
643        else
644        {
645            print F "perl=$env_dir/bin/perl\n";
646        }
647        print F 'exec $perl "$@"' . "\n";
648        close(F);
649    
650    }
651    
652  sub finalize_server_scripts  sub finalize_server_scripts
653  {  {
654      #      #
# Line 570  Line 677 
677      {      {
678          my($name, $value, $quote) = @$item;          my($name, $value, $quote) = @$item;
679    
680            #
681            # special code for non-var=value items.
682            #
683            if (ref($name) eq 'HASH')
684            {
685                my $l = $name->{perl};
686                if ($l ne '')
687                {
688                    print $fh "$l\n";
689                }
690            }
691            else
692            {
693          my $q = $quote ? '"' : '';          my $q = $quote ? '"' : '';
694          printf $fh "\$%-15s = $q$value$q;\n", $name              printf $fh "\$%-15s = $q$value$q;\n", $name;
695            }
696      }      }
697    
698      print $fh "\n1;\n";      print $fh "\n1;\n";
# Line 586  Line 707 
707          my($name, $value, $quote) = @$item;          my($name, $value, $quote) = @$item;
708    
709          #          #
710            # special code for non-var=value items.
711            #
712            if (ref($name) eq 'HASH')
713            {
714                my $l = $name->{python};
715                if ($l ne '')
716                {
717                    print $fh "$l\n";
718                }
719            }
720            else
721            {
722                #
723          # Ugh. "global" is a keyword in python.          # Ugh. "global" is a keyword in python.
724          #          #
725    
726          $name = "global_dir" if $name eq "global";          $name = "global_dir" if $name eq "global";
727    
728          my $q = $quote ? '"' : '';          my $q = $quote ? '"' : '';
729          printf $fh "%-15s = $q$value$q\n", $name              printf $fh "%-15s = $q$value$q\n", $name;
730            }
731      }      }
732  }  }
733    
# Line 729  Line 864 
864                    "$fig_disk/config");                    "$fig_disk/config");
865    
866  setup_server_scripts();  setup_server_scripts();
867    write_run_perl();
868    
869  find_python();  find_python();
870    

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.31

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3