[Bio] / FigCommon / bootstrap.pl Repository:
ViewVC logotype

Annotation of /FigCommon/bootstrap.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.30 - (view) (download) (as text)

1 : olson 1.1 #
2 : olson 1.28 # 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 : olson 1.1 # FIG bootstrap script.
20 :     #
21 :     # Control is passed here from the toplevel configure (or dists/releases/install depending
22 :     # on how far we've gotten in the process).
23 :     #
24 :     # The configure has set the following environment variables for our use:
25 :     #
26 :     # FIG_HOME Root of the FIGdisk tree we're setting up
27 :     # FIGCONFIG_ENV Name of the environment we're configuring for
28 :     # FIGCONFIG_ENV_DIR Directory in which the binary install tree for $FIGCONFIG_ENV lives
29 :     # FIGCONFIG_RELEASE Release number we're configuring
30 :     # FIGCONFIG_RELEASE_DIR Directory in which that release lives
31 :     #
32 :     # Important note: perl system libraries may not be available when this
33 :     # script is running, if the FIGCONFIG_ENV_DIR is different than it was
34 :     # when the binaries were created. Part of the task of this
35 :     # script is to recognize this case and configure the process
36 :     # environment correctly so that the post-install process as
37 :     # handled by the Makefiles can use perl properly, without concern for paths.
38 :     #
39 :    
40 :     #
41 :     # Look into the FIGCONFIG_ENV_DIR for the PREFIX that this
42 :     # environment was compiled on. If that directory is different
43 :     # than the one we're currently using, rewrite @INC accordingly.
44 :     #
45 :     # We put this into a BEGIN block so that we can later use "use"
46 :     # without worrying about paths.
47 :     #
48 :     # We also set the $perlenv_override to true if we've done this,
49 :     # so we can insert these fixes into the perl tool header.
50 :     #
51 :    
52 :     BEGIN {
53 :    
54 : olson 1.3 print "Here in the perl bootstrap. inc is:\n" . join("\n", @INC), "\n";
55 : olson 1.1
56 : parrello 1.29 my ($my_prefix, $prefix, $inc, @newInc);
57 : olson 1.1
58 :     $my_prefix = $ENV{FIGCONFIG_ENV_DIR};
59 :     open(P, "<$my_prefix/PREFIX");
60 :     $prefix = <P>;
61 :     chomp $prefix;
62 :    
63 :    
64 :     # print "Prefix is $prefix myprefix=$my_prefix\n";
65 :    
66 :     if ($prefix ne $my_prefix)
67 :     {
68 :     @newInc = ();
69 :     for $inc (@INC)
70 :     {
71 :     $inc =~ s,^$prefix,$my_prefix,;
72 :     push(@newInc, $inc);
73 :     }
74 :    
75 :     $::perlenv_override = 1;
76 : olson 1.3 @INC = @newInc;
77 : olson 1.1 }
78 :     }
79 :    
80 :    
81 :     use FileHandle;
82 :     use strict;
83 :    
84 :     #
85 :     # Environment definition
86 :     #
87 :     # This list contains triples
88 :     # ($name, $value, $appendFlag). $name is the name of the
89 :     # variable; $value is the value to set, and $appendFlag
90 :     # is nonzero if we need to append this value to an existing
91 :     # environment variable.
92 :     #
93 :    
94 :     our $Env = [];
95 :    
96 :     #
97 :     # FIG configuration information.
98 :     # This list contains tuples [$name, $value, $quote]
99 :     # which are to be set in the FIG_Config modules for
100 :     # both python and perl. $quote is 1 for things that need
101 :     # to be quoted, 0 otherwise.
102 :     #
103 :     our $Config = [];
104 :    
105 :     #
106 :     # Other key/value pairs of stuff we may need to pass
107 :     # to and from the environment-specific configuration modules.
108 :     #
109 :     # Known keys:
110 :     #
111 :     # pythonpath
112 :     #
113 :    
114 :     our $OtherConfig = {};
115 :    
116 :     #
117 :     # Cache values of the various places we may be installing things.
118 :     #
119 :    
120 :     our $fig_disk = $ENV{FIG_HOME};
121 :     our $env_name = $ENV{FIGCONFIG_ENV};
122 : olson 1.7 our $env_dir = "$ENV{FIGCONFIG_ENV_DIR}";
123 : olson 1.1 our $env_bin = "$ENV{FIGCONFIG_ENV_DIR}/bin";
124 :     our $env_lib = "$ENV{FIGCONFIG_ENV_DIR}/lib";
125 : olson 1.2 #
126 :     # We are moving to use a symlink in dist/releases/current for these.
127 :     # This symlink is managed by switch_to_release.
128 :     #
129 :     #our $release_bin = "$ENV{FIGCONFIG_RELEASE_DIR}/bin/$ENV{FIGCONFIG_ENV}";
130 :     #our $release_lib = "$ENV{FIGCONFIG_RELEASE_DIR}/lib/$ENV{FIGCONFIG_ENV}";
131 :    
132 : olson 1.8 our $release_bin = "$fig_disk/dist/releases/current/$ENV{FIGCONFIG_ENV}/bin";
133 :     our $release_lib = "$fig_disk/dist/releases/current/$ENV{FIGCONFIG_ENV}/lib";
134 : olson 1.2
135 :     our $fig_bin = "$fig_disk/FIG/bin";
136 : olson 1.1
137 :     #
138 :     # Location of start/stop servers scripts.
139 :     #
140 :     our $start_servers = "$fig_disk/bin/start-servers";
141 :     our $stop_servers = "$fig_disk/bin/stop-servers";
142 :    
143 :     sub configure_std_fig_environment
144 :     {
145 :     #
146 :     # Populate the Config with the usual stuff we need in FIG_Config.pm.
147 :     #
148 :    
149 :     my $fig = "$fig_disk/FIG";
150 :     my $data = "$fig/Data";
151 : olson 1.21 my $sproutData = "$fig/SproutData";
152 : olson 1.1
153 :     my $hostname = `hostname`;
154 :     chomp $hostname;
155 :    
156 :     push(@$Config, ["fig_disk", $fig_disk, 1]);
157 : olson 1.6 push(@$Config, ["blastmat", "$fig_disk/BLASTMAT", 1]);
158 : olson 1.1 push(@$Config, ["fig", $fig, 1]);
159 : olson 1.2 push(@$Config, ["bin", $fig_bin, 1]);
160 : olson 1.1 push(@$Config, ["ext_bin", $env_bin, 1]);
161 : olson 1.18 push(@$Config, ["common_runtime", $env_dir, 1]);
162 :     push(@$Config, ["arch", $ENV{FIGCONFIG_ENV}, 1]);
163 : olson 1.22 push(@$Config, ["var", "$fig/var", 1]);
164 : olson 1.1 push(@$Config, ["data", $data, 1]);
165 :     push(@$Config, ["global", "$data/Global", 1]);
166 :     push(@$Config, ["organisms", "$data/Organisms", 1]);
167 :     push(@$Config, ["RC", "$fig_disk/FIG/ResolutionCenter", 1]);
168 :     push(@$Config, ["NR", "$fig_disk/FIG/NR", 1]);
169 :     push(@$Config, ["temp", "$fig_disk/FIG/Tmp", 1]);
170 : olson 1.21 push(@$Config, ["sproutData", $sproutData, 1]);
171 : olson 1.11
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 : golsen 1.9
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 : olson 1.11 push(@$Config, ["temp_base", "$sandbox/FIG-Tmp/", 1]);
188 :     push(@$Config, ["cgi_base", "$sandbox/FIG/", 1]);
189 : parrello 1.29
190 : olson 1.1 }
191 :    
192 :     sub compute_environment
193 :     {
194 :     #
195 :     # ReleaseTools configuration.
196 :     #
197 :    
198 :     push(@$Env, ["RTROOT", $ENV{FIG_HOME}, 0]);
199 :     push(@$Env, ["RTDIST", "\$RTROOT/dist", 0]);
200 : olson 1.23 push(@$Env, ["RTSITECONFIGDIR", "\$RTROOT/config", 0]);
201 : olson 1.1 push(@$Env, ["RTARCH", $ENV{FIGCONFIG_ENV}, 0]);
202 : olson 1.2 push(@$Env, ["RTCURRENT", "`cat \$RTROOT/CURRENT_RELEASE`", 0]);
203 : olson 1.1 push(@$Env, ["FIG_HOME", $ENV{FIG_HOME}, 0]);
204 :    
205 :     push(@$Env, ["BLASTMAT", "$ENV{FIG_HOME}/BLASTMAT", 0]);
206 :    
207 :     #
208 :     # Determine the path to use.
209 :     #
210 :     # This includes the path into the particular release we're configuring for,
211 :     # and to the environment's bin directory.
212 :     #
213 :    
214 :     my @path = ();
215 : olson 1.24 push(@path, $fig_bin);
216 : olson 1.1 push(@path, $env_bin);
217 :     push(@path, "$fig_disk/bin");
218 :    
219 :     push(@$Env, ["PATH", join(":", @path), 1]);
220 :    
221 : olson 1.26 #
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 : olson 1.11
275 : olson 1.23 my @perllib = grep({ $_ ne "." } @INC,
276 :     $release_lib,
277 :     "$release_lib/FigKernelPackages",
278 : olson 1.30 "$release_lib/WebApplication",
279 :     "$release_lib/FortyEight",
280 :     "$release_lib/PPO",
281 : olson 1.23 "$fig_disk/config");
282 : olson 1.12
283 :     push(@$Env, ["PERL5LIB", join(":", @perllib), 1]);
284 : olson 1.1 }
285 :    
286 :     sub configure_python
287 :     {
288 :     #
289 :     # Determine the PYTHONPATH we're to use.
290 :     #
291 :     # Right now, we don't compute a replacement for the system path,
292 :     # but we're likely going to require that *if* python is
293 :     # distributed with the environment. We're currently not doing that.
294 :     #
295 :     # So we just need to point to any python packages in the release,
296 :     # and to packages that were installed in the environment dir.
297 :     #
298 :    
299 :     my $python = find_python();
300 :     print "Found python at $python\n";
301 :    
302 :     my $py_version = `$python -c 'import sys; print "%d.%d" % (sys.version_info[:2])'`;
303 :     chomp $py_version;
304 :     print "Python version $py_version\n";
305 :    
306 : olson 1.23 #
307 :     # Python figures this out for us.
308 :     #$OtherConfig->{python_site_path} = "$ENV{FIGCONFIG_ENV_DIR}/lib/python$py_version/site-packages";
309 : olson 1.2
310 : olson 1.1 my @path = ();
311 : olson 1.23 #push(@path, $OtherConfig->{python_site_path});
312 : olson 1.2 push(@path, "$release_lib");
313 : olson 1.1 push(@path, "$fig_disk/config");
314 :     push(@$Env, ["PYTHONPATH", join(":", @path), 1]);
315 :    
316 :     $OtherConfig->{pythonpath} = join(":", @path);
317 :     }
318 :    
319 :     sub find_in_path
320 :     {
321 : olson 1.5 my($file, @extra) = @_;
322 : olson 1.1 my(@path) = split(":", $ENV{PATH});
323 :    
324 : olson 1.5 for my $p (@path, @extra)
325 : olson 1.1 {
326 :     my $x = "$p/$file";
327 :     if (-x $x)
328 :     {
329 :     return $x;
330 :     }
331 :     }
332 :     return undef;
333 :     }
334 :    
335 :     #
336 :     # Find the name of the python executable we are to use.
337 :     #
338 :     sub find_python
339 :     {
340 :     my $python;
341 :    
342 :     #
343 :     # Special case for the mac.
344 :     #
345 : olson 1.11 # RDO 20040603 - don't do this any more; we want to pick up
346 :     # the python we ship.
347 :     #
348 : olson 1.1
349 : olson 1.11 if (0 && $ENV{FIGCONFIG_ENV} eq "mac")
350 : olson 1.1 {
351 : olson 1.7 #
352 :     # We'd like to use the MacPython that is installed
353 :     # as pythonw.
354 :     #
355 :     if ($python = find_in_path("pythonw", "/usr/local/bin"))
356 : olson 1.1 {
357 : olson 1.7 $OtherConfig->{python_require_poundbang_env} = 1;
358 : olson 1.1 return $python;
359 :     }
360 :    
361 :     #
362 : olson 1.7 # Otherwise, we can live with the regular python.
363 :     # Fall thru to the generic case.
364 : olson 1.1 #
365 : olson 1.7 }
366 :     #
367 :     # Non-mac, just look in the env dir or the path.
368 :     #
369 : olson 1.1
370 : olson 1.7 $python = "$ENV{FIGCONFIG_ENV_DIR}/bin/python";
371 :     if (-x $python)
372 :     {
373 : olson 1.13 #
374 :     # The mac doesn't seem to like the long #! lines, so we'll use poundbang env.
375 :     #
376 : olson 1.15 if ($ENV{FIGCONFIG_ENV} =~ /^mac/)
377 : olson 1.13 {
378 :     $OtherConfig->{python_require_poundbang_env} = 1;
379 :     }
380 : olson 1.7 return $python;
381 : olson 1.1 }
382 :    
383 : olson 1.7 return find_in_path("python");
384 : olson 1.1 }
385 :    
386 :     #
387 :     # Find the name of the perl executable we are to use.
388 :     #
389 :     sub find_perl
390 :     {
391 :     my $perl;
392 :    
393 :     $perl = "$ENV{FIGCONFIG_ENV_DIR}/bin/perl";
394 :     if (-x $perl)
395 :     {
396 :     return $perl;
397 :     }
398 :    
399 :     warn "We did not find a perl executable in the SEED distribution; some modules may not be found\n";
400 :     return find_in_path("perl");
401 :     }
402 :    
403 :     sub write_bash_init
404 :     {
405 :     my($fh, $env) = @_;
406 :    
407 :     foreach my $item (@$env)
408 :     {
409 :     my($name, $value, $append) = @$item;
410 :    
411 :     if ($append)
412 :     {
413 :     #
414 :     # Write code to detect if the value is set, and act accordingly.
415 :     #
416 :    
417 :     print $fh <<END;
418 :     DELIM=
419 :     if [ -n "\$$name" ] ; then
420 :     DELIM=:
421 :     fi
422 : olson 1.10 $name=$value\${DELIM}\${$name}
423 : olson 1.1 export $name
424 :     END
425 :     }
426 :     else
427 :     {
428 :     print $fh "$name=\"$value\"\n";
429 :     print $fh "export $name\n";
430 :     }
431 :     }
432 : olson 1.20 print $fh "alias rtpath='source \$RTDIST/releases/\$RTCURRENT/ReleaseTools/RTPath.sh'\n";
433 : olson 1.1 }
434 :    
435 :     sub write_csh_init
436 :     {
437 :     my($fh, $env) = @_;
438 :    
439 :     foreach my $item (@$env)
440 :     {
441 :     my($name, $value, $append) = @$item;
442 :    
443 :     if ($append)
444 :     {
445 :     #
446 :     # Write code to detect if the value is set, and act accordingly.
447 :     #
448 :    
449 :     print $fh <<END;
450 :     if (\$?$name) then
451 : olson 1.10 setenv $name $value:\${$name}
452 : olson 1.1 else
453 :     setenv $name $value
454 :     endif
455 :     END
456 :     }
457 :     else
458 :     {
459 :     print $fh "setenv $name \"$value\"\n";
460 :     }
461 :     }
462 :    
463 : olson 1.20 #
464 :     # Alias for RT stuff.
465 :     #
466 :     print $fh "alias rtpath 'source \$RTDIST/releases/\$RTCURRENT/ReleaseTools/RTPath.csh'\n";
467 : olson 1.1 }
468 :    
469 :     sub run_script
470 :     {
471 :     my($script) = @_;
472 :    
473 :    
474 :     unless (my $ret = do $script)
475 :     {
476 :     if ($@)
477 :     {
478 :     warn "Error parsing $script: $@\n";
479 :     }
480 :     elsif (!defined($ret))
481 :     {
482 :     warn "Couldn't do $script: $!\n";
483 :     }
484 :     else
485 :     {
486 :     warn "Counldn't run $script\n";
487 :     }
488 :     }
489 :    
490 :    
491 :     }
492 :    
493 :     sub configure_environment_specific
494 :     {
495 :     my $env_script = $ENV{FIGCONFIG_ENV_CONFIG};
496 :    
497 :     if (! -f $env_script)
498 :     {
499 :     warn "No environment-specific configuration file $env_script found, skipping\n";
500 :     return;
501 :     }
502 :    
503 :     run_script($env_script);
504 :     }
505 :    
506 :     #
507 :     # Create any directories that might be missing.
508 :     #
509 :    
510 :     sub setup_directories
511 :     {
512 :     my(@needed) = @_;
513 :    
514 :     for my $dir (@needed)
515 :     {
516 :     if (! -d $dir)
517 :     {
518 :     mkdir($dir) or warn "Could not create $dir: $!\n";
519 :     }
520 :     }
521 :     }
522 :    
523 :     sub setup_server_scripts
524 :     {
525 :     #
526 :     # Remove any start/stop servers scripts we might have, and write the stub
527 :     # start.
528 :     #
529 :    
530 :     unlink($start_servers);
531 :     unlink($stop_servers);
532 :    
533 :     open(F, ">$start_servers") or die "Cannot write $start_servers: $!";
534 :     print F "#!/bin/sh\n\n";
535 :     close(F);
536 :     chmod(0775, $start_servers);
537 :    
538 :     open(F, ">$stop_servers") or die "Cannot write $stop_servers: $!";
539 :     print F "#!/bin/sh\n\n";
540 :     close(F);
541 :     chmod(0775, $stop_servers);
542 :    
543 :     }
544 :    
545 : olson 1.7 sub finalize_server_scripts
546 :     {
547 :     #
548 :     # After any environment-specific stuff, call start_services and stop_services.
549 :     #
550 :    
551 :     open(F, ">>$start_servers") or die "Cannot write $start_servers: $!";
552 :     print F "\n$fig_bin/start_services\n";
553 :     close(F);
554 :     chmod(0775, $start_servers);
555 :    
556 :     open(F, ">>$stop_servers") or die "Cannot write $stop_servers: $!";
557 :     print F "\n$fig_bin/stop_services\n";
558 :     close(F);
559 :     chmod(0775, $stop_servers);
560 :    
561 :     }
562 :    
563 : olson 1.1 sub write_config_pm
564 :     {
565 :     my($fh, $config) = @_;
566 :    
567 :     print $fh "package FIG_Config;\n\n";
568 :    
569 :     foreach my $item (@$config)
570 :     {
571 :     my($name, $value, $quote) = @$item;
572 :    
573 :     my $q = $quote ? '"' : '';
574 :     printf $fh "\$%-15s = $q$value$q;\n", $name
575 :     }
576 :    
577 :     print $fh "\n1;\n";
578 :     }
579 :    
580 :     sub write_config_py
581 :     {
582 :     my($fh, $config) = @_;
583 :    
584 :     foreach my $item (@$config)
585 :     {
586 :     my($name, $value, $quote) = @$item;
587 :    
588 :     #
589 :     # Ugh. "global" is a keyword in python.
590 :     #
591 :    
592 :     $name = "global_dir" if $name eq "global";
593 :    
594 :     my $q = $quote ? '"' : '';
595 :     printf $fh "%-15s = $q$value$q\n", $name
596 :     }
597 :     }
598 :    
599 :     sub write_tool_hdr_perl
600 :     {
601 :     my($fh) = @_;
602 :    
603 :     my $perl = find_perl();
604 :    
605 :     print $fh "#!$perl\n";
606 :     print $fh "\n";
607 :    
608 :     if ($::perlenv_override)
609 :     {
610 :     #
611 :     # Write the tool header BEGIN block to reset the environment.
612 :     #
613 :    
614 :     print $fh "BEGIN {\n";
615 :     print $fh " \@INC = qw(\n";
616 :     for my $inc (@INC)
617 :     {
618 :     next if $inc eq '.';
619 :     print $fh "\t$inc\n";
620 :     }
621 : olson 1.2 print $fh ");\n";
622 : olson 1.1 print $fh "}\n";
623 :     }
624 :    
625 :     print $fh "use Data::Dumper;\n";
626 :     print $fh "use Carp;\n";
627 :    
628 : olson 1.2 #
629 :     # We generate a comment here that gets expanded by switch_to_release
630 :     # This is part of the effort in making the environment bootstrapping
631 :     # code independent of releases.
632 :     #
633 :    
634 :     #print $fh "use lib \"$release_lib\";\n";
635 :     #print $fh "use lib \"$release_lib/FigKernelPackages\";\n";
636 :    
637 :     print $fh "# Following block is expanded by switch_to_release to add use lib directives\n";
638 :     print $fh "# to point at the correct locations in the release directory.\n";
639 :     print $fh "#BEGIN switch_to_release generated code\n";
640 :     print $fh "#END switch_to_release generated code\n";
641 :     print $fh "\n";
642 :    
643 : olson 1.1 print $fh "use lib \"$fig_disk/config\";\n";
644 :    
645 :     print $fh "use FIG_Config;\n";
646 :     print $fh "\n";
647 : olson 1.11 print $fh "#### END tool_hdr ####\n\n"
648 : olson 1.1 }
649 :    
650 :     sub write_tool_hdr_python
651 :     {
652 :     my($fh) = @_;
653 :    
654 :     my $python = find_python();
655 :    
656 : olson 1.4 if ($OtherConfig->{python_require_poundbang_env})
657 :     {
658 :     print $fh "#!/usr/bin/env $python\n";
659 :     }
660 :     else
661 :     {
662 :     print $fh "#!$python\n";
663 :     }
664 : olson 1.1 print $fh "\n";
665 :    
666 : olson 1.11 print $fh "import sys, os\n";
667 : olson 1.2
668 :    
669 :     print $fh "sys.path.append('$OtherConfig->{python_site_path}')\n";
670 :    
671 : olson 1.11 #
672 :     # Append the perl path to the environment, for use later with CallPerl.
673 :     #
674 :    
675 : olson 1.23 my $perlpath = join(":", @INC, $release_lib, "$release_lib/FigKernelPackages", "$fig_disk/config");
676 : olson 1.11 print $fh <<END;
677 :     if os.getenv("PERL5LIB", "") != "":
678 :     _delim = ":"
679 :     else:
680 :     _delim = ""
681 :     os.environ["PERL5LIB"] = "$perlpath" + _delim + os.getenv("PERL5LIB", "")
682 :    
683 :     END
684 :    
685 : olson 1.2 print $fh "# Following block is expanded by switch_to_release to add use lib directives\n";
686 :     print $fh "# to point at the correct locations in the release directory.\n";
687 :     print $fh "#BEGIN switch_to_release generated code\n";
688 :     print $fh "#END switch_to_release generated code\n";
689 :     print $fh "\n";
690 :    
691 :     print $fh "sys.path.append('$fig_disk/config')\n";
692 :    
693 : olson 1.1 print $fh "import FIG_Config\n";
694 :     print $fh "\n";
695 : olson 1.11 print $fh "#### END tool_hdr_py ####\n\n"
696 : olson 1.1 }
697 :    
698 : olson 1.23 sub write_rtconfig
699 :     {
700 :     my($fh) = @_;
701 :    
702 :     my $python = find_python();
703 :     my $perl = find_perl();
704 :    
705 :     print $fh "RTPYTHON=$python\n";
706 :     print $fh "RTPERL=$perl\n";
707 :     print $fh "RTPYTHONPATH=$OtherConfig->{pythonpath}\n";
708 :    
709 : olson 1.25 my %seen;
710 :     my @perlpath;
711 :     for (@INC, "$fig_disk/config")
712 :     {
713 :     next if $seen{$_};
714 :     push(@perlpath, $_);
715 :     $seen{$_}++;
716 :     }
717 :     my $perlpath = join(":", @perlpath);
718 : olson 1.23
719 :     print $fh "RTPERL5LIB=$perlpath\n";
720 :    
721 :     print $fh "RTPYTHONIMPORTS=FIG_Config\n";
722 :     print $fh "RTPERLIMPORTS=FIG_Config\n";
723 : olson 1.25 print $fh "RTSETENV=BLASTMAT=$fig_disk/BLASTMAT\n";
724 :     print $fh "RTSETENV=FIG_HOME=$fig_disk\n";
725 : olson 1.27 print $fh "#RTLD_LDPATH=$OtherConfig->{ld_library_path}\n";
726 : olson 1.23 }
727 :    
728 : olson 1.1 setup_directories("$fig_disk/bin",
729 :     "$fig_disk/config");
730 :    
731 :     setup_server_scripts();
732 :    
733 :    
734 :     find_python();
735 :    
736 :     compute_environment();
737 :     configure_std_fig_environment();
738 :     configure_python();
739 :     configure_environment_specific();
740 : olson 1.19 # configure_database();
741 : olson 1.7
742 :     finalize_server_scripts();
743 : olson 1.1
744 :     #
745 :     # Write the shell startup to the figdisk.
746 :     #
747 :     open(FH, ">$fig_disk/config/fig-user-env.sh") or die "Cannot write $fig_disk/config/fig-user-env.sh: $!";
748 :     write_bash_init(\*FH, $Env);
749 :     close(FH);
750 :    
751 :     open(FH, ">$fig_disk/config/fig-user-env.csh") or die "Cannot write $fig_disk/config/fig-user-env.csh: $!";
752 :     write_csh_init(\*FH, $Env);
753 :     close(FH);
754 :    
755 :     #
756 :     # Write the FIG_Config file.
757 :     #
758 :    
759 :     open(FH, ">$fig_disk/config/FIG_Config.pm") or die "Cannot write $fig_disk/config/FIG_Config.pm: $!";
760 :     write_config_pm(\*FH, $Config);
761 :     close(FH);
762 :    
763 :     open(FH, ">$fig_disk/config/FIG_Config.py") or die "Cannot write $fig_disk/config/FIG_Config.py: $!";
764 :     write_config_py(\*FH, $Config);
765 :     close(FH);
766 :    
767 :     #
768 :     # Write the tool headers
769 :     #
770 :    
771 : olson 1.2 open(FH, ">$fig_disk/config/base_tool_hdr") or die "Cannot write $fig_disk/config/tool_hdr: $!";
772 : olson 1.1 write_tool_hdr_perl(\*FH);
773 :     close(FH);
774 :    
775 : olson 1.2 open(FH, ">$fig_disk/config/base_tool_hdr_py") or die "Cannot write $fig_disk/config/tool_hdr_py: $!";
776 : olson 1.1 write_tool_hdr_python(\*FH);
777 :     close(FH);
778 :    
779 : olson 1.23 open(FH, ">$fig_disk/config/RTConfig") or die "Cannot write $fig_disk/config/RTConfig: $!";
780 :     write_rtconfig(\*FH);
781 :     close(FH);
782 :    
783 : olson 1.2 unshift(@INC, "$ENV{FIGCONFIG_RELEASE_DIR}");
784 :    
785 :     require FigCommon::SwitchRelease;
786 : olson 1.1
787 : olson 1.16 #
788 :     # We need to tweak the current path and PERL5LIB environment to get bootstrapping to
789 :     # work correctly.
790 :     #
791 :    
792 :     $ENV{PATH} = "$ENV{FIGCONFIG_ENVDIR}/bin:$ENV{PATH}";
793 :    
794 : olson 1.17 $ENV{PERL5LIB} = (map { $_->[1] } grep { $_->[0] eq "PERL5LIB"} @$Env)[0];
795 : olson 1.16
796 : olson 1.2 &FigCommon::SwitchRelease::switch_to_release($fig_disk, $ENV{FIGCONFIG_ENV}, $ENV{FIGCONFIG_RELEASE});

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3