[Bio] / Sprout / NmpdrSetup.pl Repository:
ViewVC logotype

Annotation of /Sprout/NmpdrSetup.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     =head1 NMPDR Setup Script
4 :    
5 :     This script sets up a new version of the NMPDR web complex. It takes a single
6 :     positional parameter-- the numeric ID of the new version. So, for example
7 :    
8 :     NmpdrSetup 07
9 :    
10 :     would set up version 7.
11 :    
12 :     The script should run as part of the previous version. It will set up a new
13 :     version on the same machine. At some later point we may want to make it more
14 :     flexible.
15 :    
16 :     To run this script in the background, use something like
17 :    
18 :     nohup NmpdrSetup -background -user=You 07 >null &
19 :    
20 :     This will cause the output, error, and trace files to be produced in the
21 :     FIG temporary directory. The output file will be C<outYou.log>, the
22 :     error file will be C<errYou.log>, and the trace file C<traceYou.log>.
23 :    
24 :     Currently, the development NMPDR runs on the %DEVSERVER% server, while
25 :     the production NMPDR runs on the %PRODSERVER% server. When copying files
26 :     between servers for purposes of synchronization, it is important that
27 :     the rsync originate from the destination server so that the ownership is
28 :     not all messed up.
29 :    
30 :     =over 4
31 :    
32 :     =item trace
33 :    
34 :     Numeric trace level. A higher trace level causes more messages to appear. The
35 :     default trace level is 3.
36 :    
37 :     =item user
38 :    
39 :     User name to append to trace and output file names. If none is specified, the
40 :     PID is used.
41 :    
42 :     =item envDir
43 :    
44 :     Fully-qualified name of the environment directory. The default is
45 :     C<$FIG_Config::nmpdr_base/env>.
46 :    
47 :     =item relName
48 :    
49 :     Name to use for the release created. The default is C<nmpdr_XX>, where XX is the vesion
50 :     number. In general, any use of C<XX> in the release name will be replaced by the two-
51 :     digit version number in the positional parameters.
52 :    
53 :     =item blastMAT
54 :    
55 :     Location of the BLAST tar file. The default is C<$FIG_Config::nmpdr_base/BLASTMAT.tgz>. If
56 :     C<copy> is specified, the BLAST directory is copied from this version to the new version.
57 :    
58 :     =item h
59 :    
60 :     Display this command's parameters and options.
61 :    
62 :     =item dataDir
63 :    
64 :     Path for the SEED data directory. The default is C<0>, which indicates the most
65 :     recently-modified directory will be used.
66 :    
67 :     =item force
68 :    
69 :     Delete any existing SEED. If this option is not specified, the program will fail
70 :     if it finds a SEED already at the location of the new NMPDR.
71 :    
72 :     =item test
73 :    
74 :     If specified, information is displayed but nothing is changed.
75 :    
76 :     =item stage
77 :    
78 :     Specify the stage at which to start. The current stages are as follows
79 :    
80 :     =over 8
81 :    
82 :     =item 1
83 :    
84 :     Set up directories and check out the source.
85 :    
86 :     =item 2
87 :    
88 :     Bootstrap and build the new FIG.
89 :    
90 :     =item 3
91 :    
92 :     Perform configuration fixes.
93 :    
94 :     =item 4
95 :    
96 :     Fix file permissions.
97 :    
98 :     =item 5
99 :    
100 :     Copy the wiki pages.
101 :    
102 :     =item 6
103 :    
104 :     Copy the drug target files.
105 :    
106 :     =back
107 :    
108 :     =item group
109 :    
110 :     Name of the group to be given write permission for all the files. The default
111 :     is C<fig>.
112 :    
113 :     =item server
114 :    
115 :     Symbolic name of the new version. This indicates the type of NMPDR being created,
116 :     and is usually the name of a symlink known to the Apache configuration. The
117 :     default is C<next>, which indicates the development version. For the experimental
118 :     version, it should be C<dev>.
119 :    
120 :     =item logdir
121 :    
122 :     Directory to contain the log files. The default is C<logs> in the NMPDR base
123 :     directory.
124 :    
125 :     =item version
126 :    
127 :     If specified, displays information about this version of the NMPDR and exits.
128 :    
129 :     =back
130 :    
131 :     =head2 Maintenance Notes
132 :    
133 :     This script will need to be updated if the default directories change. In addition,
134 :     the CVS information is hard-coded.
135 :    
136 :     =cut
137 :    
138 :     use strict;
139 :     use Tracer;
140 :     use DocUtils;
141 :     use Cwd;
142 :     use File::Copy;
143 :     use File::Path;
144 :     use File::stat;
145 :     use IO::Handle;
146 :     use SFXlate;
147 : parrello 1.2 use Fcntl qw(:mode);
148 : parrello 1.1
149 :     # Get the command-line options.
150 :     my ($options, @parameters) = StandardSetup(['Sprout', 'DocUtils'],
151 :     { envDir => ["$FIG_Config::nmpdr_base/FIGdisk/env",
152 :     'environment directory containing pointers to applications and development tools'],
153 :     blastMAT => ["copy", 'BLASTMAT TAR file or "copy" to copy the source BLASTMAT directory'],
154 :     dataDir => ["0", 'fully-qualified name of the SEED data directory to use; default is most recent'],
155 :     relName => ["nmpdr_XX", 'name to use for the release created (default "nmpdr_XX")'],
156 :     test => [0, 'print some data but do not run'],
157 :     stage => [0, 'stage at which to start'],
158 :     force => [0, 'force an update over a possible existing SEED'],
159 :     group => ['fig', 'group to be given write permission for the new files'],
160 :     server => ['next', 'NMPDR version type'],
161 :     trace => [3, 'tracing level'],
162 :     logdir => ["$FIG_Config::nmpdr_base/logs", 'directory for log files'],
163 :     version => [0, 'print NMPDR version info and exit'],
164 :     },
165 :     '<versionNumber>',
166 :     @ARGV);
167 :    
168 :     # Get the main directory names.
169 :     my $arch = "common";
170 :     my $env_dir = $options->{envDir};
171 :     my $blastmat_tarfile = $options->{blastMAT};
172 :     my $base_dir = $FIG_Config::nmpdr_base;
173 :    
174 :     # Get the new version number.
175 :     my $version = $parameters[0];
176 :     # Compute the current version number.
177 :     $FIG_Config::nmpdr_version =~ /(\d+)/;
178 :     my $old_version = $1;
179 :    
180 :     # Set up the CVS data. Note that we are using an anonymous login. You can
181 :     # update from the NMPDR server but you can't commit!
182 :     my $cvsroot = ":pserver:anonymous\@biocvs.mcs.anl.gov:/disks/cvs/bio";
183 :     my $cvs_packages = "nmpdr_base";
184 :    
185 :     # Check the parameters.
186 :     if (! $FIG_Config::nmpdr_base) {
187 :     Confess("Please specify a directory value for FIG_Config::nmpdr_base.");
188 :     } elsif (! -d $FIG_Config::nmpdr_base) {
189 :     Confess("NMPDR base directory \"$FIG_Config::nmpdr_base\" not found.");
190 :     } elsif ($blastmat_tarfile ne 'copy' && ! -e $blastmat_tarfile) {
191 :     Confess("BlastMAT TAR file not found at $blastmat_tarfile.");
192 :     } elsif (! -d $env_dir) {
193 :     Confess("Environment directory $env_dir not found.");
194 :     }
195 :    
196 :     # If this is version-display-only, display version info.
197 :     if ($options->{version}) {
198 :     Trace("Computing version information.") if T(3);
199 :     # We'll put the version data in here, a line at a time.
200 :     my @lines;
201 :     push @lines, "Current directory is " . getcwd . ".";
202 :     my $type = $FIG_Config::nmpdr_site_type;
203 :     $type =~ s#/##;
204 :     push @lines, "NMPDR version is $old_version with type \"$type\" for $FIG_Config::arch.";
205 :     push @lines, "Sprout database is $FIG_Config::sproutDB.";
206 :     push @lines, "Attribute database is $FIG_Config::attrDbName on $FIG_Config::attrHost.";
207 :     # This part is a little tricky. We want to see what's in the database, but it may
208 :     # not exist yet.
209 :     my $sproutLine = "Sprout database is not working.";
210 :     eval {
211 :     my $sprout = SFXlate->new_sprout_only();
212 :     # If we got this far, the database exists.
213 :     $sproutLine = "Sprout database is working.";
214 :     my $features = Tracer::CommaFormat($sprout->GetCount(['Feature'], "", []));
215 :     # Here the database exists and it has features in it.
216 :     $sproutLine = "Sprout database contains $features features.";
217 :     };
218 :     push @lines, $sproutLine;
219 :     # Check for load files.
220 :     if (! -d $FIG_Config::sproutData) {
221 :     push @lines, "No sprout load files found.";
222 :     } else {
223 :     my $dtxFiles = scalar(grep { $_ =~ /\.dtx$/i } Tracer::OpenDir("$FIG_Config::sproutData"));
224 :     push @lines, "$dtxFiles sprout load files found.";
225 :     }
226 :     Trace("NMPDR Version information:\n\n" . join("\n", @lines)) if T(2);
227 :     exit;
228 :     }
229 :     # Check the version parameter.
230 :     if (! $version) {
231 :     Confess("No version number specified.");
232 :     } elsif ($version !~ /^\d+$/) {
233 :     Confess("Invalid (non-numeric) version number $version.");
234 :     }
235 :     # Make the version number pretty. This means stripping off the "v" (if any)
236 :     # and converting to two digits.
237 :     $version =~ s/^v//;
238 :     $version = sprintf("%02d", $version);
239 :     # Add the version number to the release name.
240 :     my $version_rel = $options->{relName};
241 :     $version_rel =~ s/XX/$version/e;
242 :     # Create the log file directory.
243 :     my $log_dir = $options->{logdir};
244 :     Insure($log_dir);
245 :     my $logFilePrefix = "$log_dir/v$version";
246 :     # Now we can start the setup.
247 :     Trace("Creating NMPDR version $version with name $version_rel.");
248 :     # Get the directory for the version-specific stuff.
249 :     my $version_dir = "$base_dir/v$version";
250 :     Insure($version_dir);
251 :     # This will be the directory of FIG stuff.
252 :     my $target_dir = "$version_dir/FIGdisk";
253 :     # This is a global for the name of the code directory.
254 :     my $code_dir = "$target_dir/dist/releases/$version_rel";
255 :     # Compute the Sprout database name.
256 :     my $sprout_db_name = "nmpdr_v${version}_sprout";
257 :     Trace("Starting at stage $options->{stage}.") if T(2);
258 :     #
259 :     # Stage 1: SEED directories and CVS source.
260 :     #
261 :     if ($options->{stage} <= 1) {
262 :     # Insure we're not wiping out an old SEED.
263 :     if (-e $target_dir) {
264 :     if ($options->{force}) {
265 :     # Here we have an old seed but we want to build over the
266 :     # top of it.
267 :     Trace("Deleting SEED already in place.") if T(2);
268 :     if ($options->{test}) {
269 :     Trace("Tree $target_dir would be deleted.") if T(2);
270 :     } else {
271 :     rmtree($target_dir);
272 :     }
273 :     } else {
274 :     Confess("A SEED was already found at $target_dir. Use \"-force\" to force an update anyway.");
275 :     }
276 :     }
277 :     # At this point, if we're still alive, there's no target directory, so
278 :     # we want to create it.
279 :     Insure($target_dir);
280 :     # Build the main FIG directory.
281 :     Insure("$target_dir/FIG");
282 :     # Build the temporary directory.
283 :     Insure("$target_dir/FIG/Tmp");
284 :     # Build the sprout data directory.
285 :     Insure("$target_dir/FIG/SproutData");
286 :     # Now we create the code directories.
287 :     Insure("$target_dir/dist");
288 :     Insure("$target_dir/dist/releases");
289 : parrello 1.2 if (! $options->{test}) {
290 :     # Insure the group is sticky for the code directories.
291 :     chmod 0775 | S_ISGID, "$target_dir/dist/releases";
292 :     }
293 : parrello 1.1 # Finally, we create the directory that holds the cover pages.
294 :     Insure("$version_dir/html");
295 :     # Change to the target directory. This means we're inside FIGdisk and above
296 :     # FIG.
297 :     ChDir($target_dir);
298 :     # Symbolically link to the environment directory.
299 :     if ($options->{test}) {
300 :     Trace("Symlink from env to $env_dir would have been created.") if T(2);
301 :     } else {
302 :     do_symlink($env_dir, "env");
303 :     }
304 :     # Create the BLASTMat directory.
305 :     if ($blastmat_tarfile eq 'copy') {
306 :     # Here we are copying the BLAST data from the previous version.
307 :     my $new_blastmat = "$target_dir/BLASTMAT";
308 :     Insure($new_blastmat);
309 :     if ($options->{test}) {
310 :     Trace("BLASTMAT data will be copied from $FIG_Config::blastmat to $target_dir/BLASTMAT.") if T(2);
311 :     } else {
312 : parrello 1.2 my $blastDir = "$FIG_Config::nmpdr_base/FIGdisk/BLASTMAT";
313 : parrello 1.1 Trace("Copying BLASTMAT directory from $FIG_Config::blastmat to $new_blastmat.") if T(2);
314 : parrello 1.2 for my $fileName (OpenDir($blastDir)) {
315 : parrello 1.1 copy "$FIG_Config::blastmat/$fileName", "$new_blastmat/$fileName";
316 :     }
317 :     }
318 :     } else {
319 :     # Here we are extracting the BLAST data from a TAR file.
320 :     if ($options->{test}) {
321 :     Trace("BLASTMAT would have been pulled from $blastmat_tarfile.") if T(2);
322 :     } else {
323 :     do_untar($blastmat_tarfile);
324 :     }
325 :     }
326 :     # Next we copy the Sprout group file.
327 :     my $newSproutDataDir = "$target_dir/FIG/SproutData";
328 :     if ($options->{test}) {
329 :     Trace("Sprout groups table would be copied from $FIG_Config::sproutData to $newSproutDataDir.") if T(2);
330 :     } else {
331 :     Trace("Copying Sprout groups table from $FIG_Config::sproutData to $newSproutDataDir.") if T(2);
332 :     copy "$FIG_Config::sproutData/groups.tbl", "$newSproutDataDir/groups.tbl";
333 :     }
334 :     # Now we need to symbolically link the data directory to the NMPDR master SEED.
335 :     my $best_data = "";
336 :     if ($options->{dataDir} ne "0") {
337 :     # Here the user specified a particular directory.
338 :     $best_data = $options->{dataDir};
339 :     } else {
340 :     # Here we want the most recently-modified data directory under
341 :     # $base_dir/FIGdisk/FIG.
342 :     my $data_base = "$base_dir/FIGdisk/FIG";
343 :     my @possibleDatas = grep { $_ =~ /^Data/ } OpenDir("$data_base");
344 :     my $best_time = 0;
345 :     Trace(scalar(@possibleDatas) . " subdirectories found under $data_base.") if T(2);
346 :     for my $possibleData (@possibleDatas) {
347 :     # Note we're using the File::stat thing here, which returns a hash of the
348 :     # file info, instead of the built-in function.
349 :     my $this_data = "$data_base/$possibleData";
350 :     my $fileInfo = stat $this_data;
351 :     Trace("Directory $this_data has modify time " . $fileInfo->mtime . ".") if T(3);
352 :     if ($fileInfo->mtime >= $best_time) {
353 :     Trace("Directory $this_data selected.") if T(3);
354 :     $best_data = $this_data;
355 :     $best_time = $fileInfo->mtime;
356 :     }
357 :     }
358 :     # If we didn't find any data, it's an error.
359 :     if (! $best_data) {
360 :     Confess("Could not find a data directory under $data_base.");
361 :     }
362 :     }
363 :     # Verify that we have a directory.
364 :     if (! -d $best_data) {
365 :     Confess("Cannot use $best_data because it is not a directory.");
366 :     }
367 :     # Symlink to the data directory we found. Now it will appear to be a part
368 :     # of the normal FIG data structure tree.
369 :     if ($options->{test}) {
370 :     Trace("Directory $best_data will be used for FIG/Data.") if T(2);
371 :     } else {
372 :     do_symlink($best_data, "FIG/Data");
373 :     }
374 :     # Change to the code directory.
375 :     ChDir("dist/releases");
376 :     # Create a directory to hold the release.
377 :     my $rel = $version_rel;
378 :     Insure($rel);
379 :     ChDir($rel);
380 :     # Set up the CVS log file. Note it will be in the same directory as
381 :     # our other log files with the same suffix.
382 :     my $lf = "$logFilePrefix-CVS.log";
383 :     if ($options->{test}) {
384 :     Trace("CVS checkout would be to " . getcwd() . ".") if T(2);
385 :     } else {
386 :     Trace("Checking out from CVS.") if T(2);
387 :     my $rc = system("cvs -d $cvsroot co -P $cvs_packages >$lf 2>&1 ");
388 :     if ($? != 0) {
389 :     # Here the checkout failed.
390 :     Confess("Error during CVS checkout for $cvsroot.");
391 :     } else {
392 :     Trace("CVS checkout log is in $lf.") if T(2);
393 :     }
394 :     # Now copy the configuration script and make it executable.
395 :     copy("FigCommon/configure", "$target_dir/configure") ||
396 :     Confess("Could not copy configuration script.");
397 :     chmod 0775, "$target_dir/configure";
398 :     # Copy the make file.
399 :     copy("ReleaseTools/Makefile.top", "Makefile") ||
400 :     Confess("Could not copy master make file.");
401 :     # Write out the release name.
402 :     Open(\*RELFILE, ">$target_dir/DEFAULT_RELEASE");
403 :     print RELFILE "$rel\n";
404 :     close(RELFILE);
405 :     # Hack out the PostGres initialization. NMPDR is MySQL-only.
406 :     unlink("FigCommon/env.$arch.pl");
407 :     }
408 :     Trace("Stage 1 complete.") if T(2);
409 :     }
410 :     #
411 :     # STAGE 2: Bootstrap and build the new FIG.
412 :     #
413 :     if ($options->{stage} <= 2) {
414 :     # Change to the target FIG directory. We'll run the configuration
415 :     # script from here, and it requires another log file.
416 :     ChDir($target_dir);
417 :     if ($options->{test}) {
418 :     Trace("Configuration script would be executed from $target_dir.") if T(2);
419 :     } else {
420 :     delete $ENV{PERL5LIB};
421 :     my $lf = "$logFilePrefix-Config.log";
422 :     Trace("Executing configuration script from $target_dir.") if T(2);
423 : parrello 1.2 system("./configure nmpdr-config $target_dir >$lf 2>&1");
424 : parrello 1.1 if ($? != 0) {
425 :     Trace("Error during configuration script.") if T(0);
426 :     }
427 :     }
428 :     Trace("Stage 2 complete.") if T(2);
429 :     }
430 :     #
431 :     # STAGE 3: Configure FIG_Config and the config script
432 :     # and protect from updates.
433 :     #
434 :     if ($options->{stage} <= 3) {
435 :     # Compute the configuration directory locations.
436 :     my $old_config_dir = "$FIG_Config::fig_disk/config";
437 :     my $new_config_dir = "$target_dir/config";
438 :     Insure($new_config_dir);
439 :     # Copy the old configuration. This destroys the config file created by the
440 :     # bootstrap.
441 :     my $old_config = "$old_config_dir/FIG_Config.pm";
442 :     my $new_config = "$new_config_dir/FIG_Config.pm";
443 :     if ($options->{test}) {
444 :     Trace("$old_config would be copied to $new_config.") if T(2);
445 :     } else {
446 :     Trace("Copying $old_config to $new_config") if T(2);
447 :     copy $old_config, $new_config;
448 :     }
449 :     # Next, we update the few lines at the beginning that have all the magic in them.
450 :     # Every other config value is derived from these four.
451 :     my %changes = (
452 :     version => $version,
453 :     old_version => $FIG_Config::version,
454 :     nmpdr_site_type => "/$options->{server}",
455 :     arch => $arch,
456 :     );
457 :     if ($options->{test}) {
458 :     Trace("Configuration file update would run from $new_config_dir.") if T(2);
459 :     } else {
460 :     Trace("Updating configuration file $new_config.") if T(2);
461 :     DocUtils::ModifyConfigFile($new_config, \%changes, []);
462 :     }
463 :     # The next step is to update the shell script. We need to add CVS information and
464 :     # the temp directory.
465 :     my %elims = (CVSROOT => $cvsroot,
466 :     CVS_RSH => 'ssh',
467 :     TMPDIR => "$target_dir/FIG/Tmp",
468 :     );
469 :     # Switch to the new configuration directory.
470 :     ChDir($new_config_dir);
471 :     # Check to see if we're in test mode.
472 :     if ($options->{test}) {
473 :     Trace("File fig-user-env.sh would be updated in " . getcwd() . ".") if T(2);
474 :     for my $elim (keys %elims) {
475 :     Trace("export $elim = \"$elims{$elim}\"") if T(2);
476 :     }
477 :     } else {
478 :     # Slurp in the entire file.
479 :     my @lines = Tracer::GetFile("fig-user-env.sh");
480 :     # Loop through the variables.
481 :     for my $elim (keys %elims) {
482 :     # Remove any existing lines for the variable.
483 :     @lines = grep { $_ !~ /(export $elim)|($elim=)/ } @lines;
484 :     # Add the new lines.
485 :     Trace("Updating $elim in fig-user-env.sh.");
486 :     push @lines, "$elim=\"$elims{$elim}\"";
487 :     push @lines, "export $elim";
488 :     }
489 :     # Write the file back out.
490 :     Open(\*FIGOUT, ">fig-user-env.sh~");
491 :     for my $line (@lines) {
492 :     print FIGOUT "$line\n";
493 :     }
494 :     close FIGOUT;
495 :     rename "fig-user-env.sh~", "fig-user-env.sh";
496 :     }
497 :     # Copy the WebApplication configuration subdirectory from the
498 :     # current version to the next version.
499 :     Insure("$new_config_dir/WebApplication");
500 :     if ($options->{test}) {
501 :     Trace("WebApplication configuration files would be copied to $new_config_dir/WebApplication.") if T(2);
502 :     } else {
503 :     my @lines = `cp -r $old_config_dir/WebApplication/* $new_config_dir/WebApplication`;
504 :     Trace("WebApplication configuration files copied:\n" . join("\n", @lines)) if T(2);
505 :     }
506 :     # Finally, create a marker file to protect this installation from
507 :     # automatic updates.
508 :     my $marker_file = "$target_dir/config/DISABLE_P2P";
509 :     if ($options->{test}) {
510 :     Trace("Marker file $marker_file would be created.") if T(2);
511 :     } else {
512 :     Trace("Creating marker file $marker_file.") if T(2);
513 :     Open(\*FIGOUT, ">$marker_file");
514 :     print FIGOUT "\n";
515 :     close FIGOUT;
516 :     }
517 :     # We're done.
518 :     Trace("Stage 3 complete.") if T(2);
519 :     }
520 :     #
521 :     # STAGE 4: Do a make.
522 :     #
523 :     if ($options->{stage} <= 4) {
524 :     if ($options->{test}) {
525 :     Trace("Make would occur in directory $code_dir.") if T(2);
526 :     } else {
527 :     ChDir($code_dir);
528 :     Trace("Making in $code_dir.") if T(2);
529 :     my $lf = "$logFilePrefix-Make.log";
530 :     my @lines = `make 2>&1 1>$lf`;
531 :     if (scalar @lines) {
532 :     Trace("Messages from make:\n" . join("\n", @lines)) if T(1);
533 :     }
534 :     Trace("Make complete.") if T(2);
535 :     }
536 :     Trace("Stage 4 complete.") if T(2);
537 :     }
538 :     #
539 :     # STAGE 5: Copy the wiki pages.
540 :     #
541 :     if ($options->{stage} <= 5) {
542 :     # Make sure we have a place to put them.
543 :     Insure("$target_dir/FIG/WikiData");
544 :     # Compute the sync command.
545 :     my $command = "rsync --archive --recursive --perms --group --exclude=Trash/ --exclude=tmp/ $FIG_Config::wiki_data/ $target_dir/FIG/WikiData/";
546 :     # Execute it.
547 :     if ($options->{test}) {
548 :     Trace("Command to execute:\n$command") if T(2);
549 :     } else {
550 :     Trace("Copying wiki pages.") if T(2);
551 :     my @syncData = `$command`;
552 :     Trace("Copy results\n" . join("\n", @syncData)) if T(3);
553 :     # Create the temp-file directory. This was deliberately excluded from the
554 :     # copy process to avoid goofy permission problems.
555 :     mkdir "$target_dir/FIG/WikiData/working/tmp";
556 :     }
557 :     Trace("Stage 5 complete.") if T(2);
558 :     }
559 :     #
560 :     # STAGE 6: Copy the drug target files.
561 :     #
562 :     if ($options->{stage} <= 6) {
563 :     # Compute the sync command.
564 :     my $command = "rsync --archive --recursive $FIG_Config::var/DrugTargets $target_dir/FIG/var/";
565 :     if ($options->{test}) {
566 :     Trace("Command to execute:\n$command") if T(2);
567 :     } else {
568 :     Trace("Copying drug target files.") if T(2);
569 :     my @syncData = `$command`;
570 :     Trace("Copy results\n" . join("\n", @syncData)) if T(3);
571 :     }
572 :     Trace("Stage 6 complete.") if T(2);
573 :     }
574 :    
575 :     Trace("Processing complete.") if T(0);
576 :    
577 :     # Forge a symbolic Link.
578 :     sub do_symlink {
579 :     my($from, $to) = @_;
580 :     # Erase the old link if necessary.
581 :     if (-e $to) {
582 :     Trace("Erasing old link $to.") if T(3);
583 :     unlink $to;
584 :     }
585 :     symlink($from, $to) ||
586 :     Confess("Symlink $from $to failed: $!");
587 :     }
588 :    
589 :     # Untar a bunch of files.
590 :     sub do_untar {
591 :     my($file) = @_;
592 :     my $args = "-x -f $file";
593 :     if ($file =~ /gz$/) {
594 :     $args .= " -z";
595 :     } elsif ($file =~ /bz2/) {
596 :     $args .= " -j";
597 :     }
598 :     my $cmd = "tar $args";
599 :     my $rc = system($cmd);
600 :     if ($rc != 0) {
601 :     Confess("tar failed with rc=$rc: $cmd");
602 :     }
603 :     }
604 :    
605 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3