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

Annotation of /Sprout/NMPDRSetup.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3