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

Annotation of /FigCommon/bootstrap.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

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