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

Annotation of /Sprout/NMPDRSetup.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (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 nmpdr-1 server, while
25 :     the production NMPDR runs on the nmpdr-3 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 2.
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 : 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 :     Copy the cover pages.
101 :    
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 :     is C<figadmin>.
112 :    
113 :     =item server
114 :    
115 : parrello 1.4 Server path to the cover pages. 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 : parrello 1.1
120 :     =back
121 :    
122 :     =head2 Maintenance Notes
123 :    
124 :     This script will need to be updated if the default directories change. In addition,
125 :     the CVS information is hard-coded.
126 :    
127 :     Currently the FIG_Config is set up to use the NEXT pointer in the proxy URL system.
128 :     This means it has to be edited manually during the cutover.
129 :    
130 :     =cut
131 :    
132 :     use strict;
133 :     use Tracer;
134 :     use DocUtils;
135 :     use Cwd;
136 :     use File::Copy;
137 :     use File::Path;
138 :     use File::stat;
139 : parrello 1.3 #use POSIX;
140 : parrello 1.1 use IO::Handle;
141 :    
142 :     # Get the command-line options.
143 :     my ($options, @parameters) = StandardSetup(['Sprout', 'DocUtils'],
144 :     { envDir => ["$FIG_Config::nmpdr_base/FIGdisk/env",
145 :     'environment directory containing pointers to applications and development tools'],
146 :     blastMAT => ["copy",
147 :     'BLASTMAT TAR file or "copy" to copy the source BLASTMAT directory'],
148 :     dataDir => ["0",
149 :     'fully-qualified name of the SEED data directory to use; default is most recent'],
150 :     relName => ["nmpdr_XX",
151 :     'name to use for the release created (default "nmpdr_XX")'],
152 :     test => [0,
153 :     'print some data but do not run'],
154 :     stage => [0,
155 :     'stage at which to start'],
156 :     force => [0,
157 :     'force an update over a possible existing SEED'],
158 :     group => ['fig',
159 :     'group to be given write permission for the new files'],
160 : parrello 1.4 server => ['next',
161 :     'server path to the cover pages'],
162 : parrello 1.1 },
163 : parrello 1.3 '<versionNumber>',
164 : parrello 1.1 @ARGV);
165 :    
166 :     # Get the main directory names.
167 :     my $arch = $FIG_Config::arch;
168 :     my $env_dir = $options->{envDir};
169 :     my $blastmat_tarfile = $options->{blastMAT};
170 :     my $base_dir = $FIG_Config::nmpdr_base;
171 :    
172 : parrello 1.2 # Get the new version number.
173 : parrello 1.1 my $version = $parameters[0];
174 : parrello 1.2 # Compute the current version number.
175 :     $FIG_Config::nmpdr_version =~ /(\d+)/;
176 :     my $old_version = $1;
177 : parrello 1.1
178 :     # Set up the CVS data. Note that we are using an anonymous login. You can
179 :     # update from the NMPDR server but you can't commit!
180 :     my $cvsroot = ":pserver:anonymous\@biocvs.mcs.anl.gov:/disks/cvs/bio";
181 : parrello 1.3 my $cvs_packages = "nmpdr_base";
182 : parrello 1.1
183 : parrello 1.3 # Check the parameters.
184 :     if (! $FIG_Config::nmpdr_base) {
185 :     Confess("Please specify a value for FIG_Config::nmpdr_base.");
186 :     } elsif (! -d $FIG_Config::nmpdr_base) {
187 :     Confess("NMPDR base directory \"$FIG_Config::nmpdr_base\" not found.");
188 :     } elsif ($blastmat_tarfile ne 'copy' && ! -e $blastmat_tarfile) {
189 :     Confess("BlastMAT TAR file not found at $blastmat_tarfile.");
190 :     } elsif (! -d $env_dir) {
191 :     Confess("Environment directory $env_dir not found.");
192 :     } elsif (! $version) {
193 :     Confess("No version number specified.");
194 :     } elsif ($version !~ /^\d+$/) {
195 :     Confess("Invalid (non-numeric) version number $version.");
196 : parrello 1.1 }
197 :     # Make the version number pretty.
198 :     $version = sprintf("%02d", $version);
199 :     # Add the version number to the release name.
200 :     my $version_rel = $options->{relName};
201 :     $version_rel =~ s/XX/$version/e;
202 :     # Now we can start the setup.
203 :     Trace("Creating NMPDR version $version with name $version_rel.");
204 :     # Get the directory for the version-specific stuff.
205 :     my $version_dir = "$base_dir/v$version";
206 :     Insure($version_dir);
207 :     # This will be the directory of FIG stuff.
208 :     my $target_dir = "$version_dir/FIGdisk";
209 :     # Compute the Sprout database name.
210 :     my $sprout_db_name = "nmpdr_v${version}_sprout";
211 :     Trace("Starting at stage $options->{stage}.") if T(2);
212 :     #
213 :     # Stage 1: SEED directories and CVS source.
214 :     #
215 :     if ($options->{stage} <= 1) {
216 :     # Insure we're not wiping out an old SEED.
217 :     if (-e $target_dir) {
218 :     if ($options->{force}) {
219 :     # Here we have an old seed but we want to build over the
220 :     # top of it.
221 :     Trace("Deleting SEED already in place.") if T(2);
222 :     if ($options->{test}) {
223 :     Trace("Tree $target_dir would be deleted.") if T(2);
224 :     } else {
225 :     rmtree($target_dir);
226 :     }
227 :     } else {
228 :     Confess("A SEED was already found at $target_dir. Use \"-force\" to force an update anyway.");
229 :     }
230 :     }
231 :     # At this point, if we're still alive, there's no target directory, so
232 :     # we want to create it.
233 :     Insure($target_dir);
234 :     # Build the main FIG directory.
235 :     Insure("$target_dir/FIG");
236 :     # Build the temporary directory.
237 :     Insure("$target_dir/FIG/Tmp");
238 :     # Build the sprout data directory.
239 :     Insure("$target_dir/FIG/SproutData");
240 :     # Now we create the code directories.
241 :     Insure("$target_dir/dist");
242 :     Insure("$target_dir/dist/releases");
243 : parrello 1.2 # Finally, we create the directory that holds the cover pages.
244 : parrello 1.1 Insure("$version_dir/html");
245 :     # Change to the target directory. This means we're inside FIGdisk and above
246 :     # FIG.
247 :     ChDir($target_dir);
248 :     # Symbolically link to the environment directory.
249 :     if ($options->{test}) {
250 :     Trace("Symlink from env to $env_dir would have been created.") if T(2);
251 :     } else {
252 :     do_symlink($env_dir, "env");
253 :     }
254 :     # Create the BLASTMat directory.
255 :     if ($blastmat_tarfile eq 'copy') {
256 :     # Here we are copying the BLAST data from the previous version.
257 :     my $new_blastmat = "$target_dir/BLASTMAT";
258 :     Insure($new_blastmat);
259 :     if ($options->{test}) {
260 :     Trace("BLASTMAT data will be copied from $FIG_Config::blastmat to $target_dir/BLASTMAT.") if T(2);
261 :     } else {
262 :     Trace("Copying BLASTMAT directory from $FIG_Config::blastmat to $new_blastmat.") if T(2);
263 :     for my $fileName (OpenDir($FIG_Config::blastmat)) {
264 :     copy "$FIG_Config::blastmat/$fileName", "$new_blastmat/$fileName";
265 :     }
266 :     }
267 :     } else {
268 :     # Here we are extracting the BLAST data from a TAR file.
269 :     if ($options->{test}) {
270 :     Trace("BLASTMAT would have been pulled from $blastmat_tarfile.") if T(2);
271 :     } else {
272 :     do_untar($blastmat_tarfile);
273 :     }
274 :     }
275 :     # Next we copy the Sprout group file.
276 :     my $newSproutDataDir = "$target_dir/FIG/SproutData";
277 :     if ($options->{test}) {
278 :     Trace("Sprout groups table would be copied from $FIG_Config::sproutData to $newSproutDataDir.") if T(2);
279 :     } else {
280 :     Trace("Copying Sprout groups table from $FIG_Config::sproutData to $newSproutDataDir.") if T(2);
281 :     copy "$FIG_Config::sproutData/groups.tbl", "$newSproutDataDir/groups.tbl";
282 :     }
283 :     # Now we need to symbolically link the data directory to the NMPDR master SEED.
284 :     my $best_data = "";
285 :     if ($options->{dataDir} ne "0") {
286 :     # Here the user specified a particular directory.
287 :     $best_data = $options->{dataDir};
288 :     } else {
289 :     # Here we want the most recently-modified data directory under
290 :     # $base_dir/FIGdisk/FIG.
291 :     my $data_base = "$base_dir/FIGdisk/FIG";
292 :     my @possibleDatas = grep { $_ =~ /^Data/ } OpenDir("$data_base");
293 :     my $best_time = 0;
294 :     Trace(scalar(@possibleDatas) . " subdirectories found under $data_base.") if T(2);
295 :     for my $possibleData (@possibleDatas) {
296 :     # Note we're using the File::stat thing here, which returns a hash of the
297 :     # file info, instead of the built-in function.
298 :     my $this_data = "$data_base/$possibleData";
299 :     my $fileInfo = stat $this_data;
300 :     Trace("Directory $this_data has modify time " . $fileInfo->mtime . ".") if T(3);
301 :     if ($fileInfo->mtime >= $best_time) {
302 :     Trace("Directory $this_data selected.") if T(3);
303 :     $best_data = $this_data;
304 :     $best_time = $fileInfo->mtime;
305 :     }
306 :     }
307 :     # If we didn't find any data, it's an error.
308 :     if (! $best_data) {
309 :     Confess("Could not find a data directory under $data_base.");
310 :     }
311 :     }
312 :     # Verify that we have a directory.
313 :     if (! -d $best_data) {
314 :     Confess("Cannot use $best_data because it is not a directory.");
315 :     }
316 :     # Symlink to the data directory we found. Now it will appear to be a part
317 :     # of the normal FIG data structure tree.
318 :     if ($options->{test}) {
319 :     Trace("Directory $best_data will be used for FIG/Data.") if T(2);
320 :     } else {
321 :     do_symlink($best_data, "FIG/Data");
322 :     }
323 :     # Change to the code directory.
324 :     ChDir("dist/releases");
325 :     # Create a directory to hold the release.
326 :     my $rel = $version_rel;
327 :     Insure($rel);
328 :     ChDir($rel);
329 :     # Set up the CVS log file. Note it will be in the same directory as
330 :     # our other log files with the same suffix.
331 :     my $lf = "$FIG_Config::temp/CVS$options->{user}.log";
332 :     if ($options->{test}) {
333 :     Trace("CVS checkout would be to " . getcwd() . ".") if T(2);
334 :     } else {
335 :     Trace("Checking out from CVS.") if T(2);
336 : parrello 1.4 my $rc = system("cvs -d $cvsroot co -P $cvs_packages >$lf 2>&1 ");
337 : parrello 1.1 if ($? != 0) {
338 :     # Here the checkout failed.
339 :     Confess("Error during CVS checkout for $cvsroot.");
340 :     } else {
341 :     Trace("CVS checkout log is in $lf.") if T(2);
342 :     }
343 :     # Now copy the configuration script and make it executable.
344 :     copy("FigCommon/configure", "$target_dir/configure") ||
345 :     Confess("Could not copy configuration script.");
346 :     chmod 0775, "$target_dir/configure";
347 :     # Copy the make file.
348 :     copy("ReleaseTools/Makefile.top", "Makefile") ||
349 :     Confess("Could not copy master make file.");
350 :     # Write out the release name.
351 :     Open(\*RELFILE, ">$target_dir/DEFAULT_RELEASE");
352 :     print RELFILE "$rel\n";
353 :     close(RELFILE);
354 :     # Hack out the PostGres initialization. NMPDR is MySQL-only.
355 :     unlink("FigCommon/env.$arch.pl");
356 :     }
357 :     Trace("Stage 1 complete.") if T(2);
358 :     }
359 :     #
360 :     # STAGE 2: Bootstrap and build the new FIG.
361 :     #
362 :     if ($options->{stage} <= 2) {
363 :     # Change to the target FIG directory. We'll run the configuration
364 :     # script from here, and it requires another log file.
365 :     ChDir($target_dir);
366 :     if ($options->{test}) {
367 :     Trace("Configuration script would be executed from $target_dir.") if T(2);
368 :     } else {
369 :     delete $ENV{PERL5LIB};
370 :     my $lf = "$FIG_Config::temp/Config$options->{user}.log";
371 :     Trace("Executing configuration script from $target_dir.") if T(2);
372 :     system("./configure $arch >$lf 2>&1");
373 :     if ($? != 0) {
374 :     Trace("Error during configuration script.") if T(0);
375 :     }
376 :     }
377 :     Trace("Stage 2 complete.") if T(2);
378 :     }
379 :     #
380 : parrello 1.2 # STAGE 3: Configure FIG_Config and the config script
381 :     # and protect from updates.
382 : parrello 1.1 #
383 :     if ($options->{stage} <= 3) {
384 :     # Switch to the configuration directory.
385 :     Insure("$target_dir/config");
386 :     ChDir("$target_dir/config");
387 :     # Create a hash of the changes that need to be made.
388 :     my %changes = (
389 :     temp_url => "\$nmpdr_site_url/FIG-Tmp",
390 :     cgi_url => "\$nmpdr_site_url/FIG",
391 : parrello 1.6 temp_base => "/next/FIG-Tmp",
392 :     cgi_base => "/next/FIG",
393 : parrello 1.1 template_url => "\$nmpdr_site_url/templates",
394 :     dbms => "mysql",
395 :     sproutDbms => "mysql",
396 :     db => $FIG_Config::db,
397 :     dbuser => $FIG_Config::dbuser,
398 :     dbpass => $FIG_Config::dbpass,
399 :     dbsock => $FIG_Config::dbsock,
400 :     dbport => $FIG_Config::dbport,
401 :     sproutDB => $sprout_db_name,
402 :     oldSproutDB => $FIG_Config::sproutDB,
403 :     oldSproutDBD => "$FIG_Config::fig/SproutDBD.xml",
404 :     sproutUser => "seed",
405 :     sproutPass => "",
406 :     sproutSock => "",
407 :     sproutPort => 3306,
408 : parrello 1.5 sprout_host => "localhost",
409 : parrello 1.1 nmpdr_version => $version_rel,
410 : parrello 1.4 nmpdr_release => $version,
411 : parrello 1.1 nmpdr_base => $FIG_Config::nmpdr_base,
412 :     nmpdr_pages => "$version_dir/html",
413 :     preIndex => 1,
414 :     otherGroup => "(supporting)",
415 :     feature_types => "peg rna pp pi",
416 :     results_per_page => 50,
417 :     blast_limit => 1000,
418 :     prop_search_limit => 4,
419 :     drug_directory => "\$var/DrugTargets",
420 : parrello 1.4 dockLimit => "00000100",
421 : parrello 1.1 advanced_class => "FidSearch BlastSearch",
422 :     splitter => " : ",
423 :     attrURL => "http://anno-3.nmpdr.org/attrib_server/AttribXMLRPC.cgi",
424 :     attrDbms => "mysql",
425 :     attrDbName => "fig_v5_attributes",
426 :     attrHost => undef,
427 :     attrUser => "seed",
428 :     attrPass => "",
429 :     attrPort => 3306,
430 :     attrSock => undef,
431 :     attrDBD => "/disks/nmpdr/v$version/FIGdisk/FIG/AttributesDBD.xml",
432 : parrello 1.2 phone => "{ user => 'BruceTheHumanPet', password => 'STARl00k', api_id => '2561022' }",
433 :     nmpdr_mode => 1,
434 : parrello 1.4 lib => "\$FIG_Config::fig_disk/dist/releases/$version_rel/$FIG_Config::arch/lib",
435 :     wiki_data => "\$FIG_Config::fig/WikiData",
436 :     web_app_db => "{ -database => 'WebAppBackend', -host => 'bioseed.mcs.anl.gov', -user => 'root' };",
437 : parrello 1.7 app_name => "NMPDR",
438 : parrello 1.4 live_server => 0,
439 :     sprout_host => "localhost",
440 : parrello 1.8 ontology_db => "\$FIG_Config::global/Ontology/ontology.sqlite",
441 :     file_images_only => 1,
442 : parrello 1.9 error_feed => "rss2trace.xml",
443 :     nmpdr_source => "\$FIG_Config::fig_disk/dist/releases/current",
444 : parrello 1.1 );
445 : parrello 1.2 # Pull forward the server values from the current version.
446 :     for my $serverKey (qw(bbh_server_url sim_server_url pin_server_url pch_server_url use_pch_server)) {
447 :     my $value = eval("\$FIG_Config::$serverKey");
448 :     if (defined $value) {
449 :     $changes{$serverKey} = $value;
450 :     }
451 :     }
452 :    
453 : parrello 1.1 # Create a list of lines to be added to the front.
454 : parrello 1.4 my $nmpdr_url = "http://" . $ENV{'HTTP-HOST'} . "/$options->{server}";
455 :     Trace("URL for this NMPDR release is $nmpdr_url") if T(2);
456 : parrello 1.1 my $inserts = [
457 :     "",
458 : parrello 1.4 "\$nmpdr_site_url = \"$nmpdr_url\";",
459 : parrello 1.1 ];
460 :     if ($options->{test}) {
461 :     Trace("Configuration file update would run from " . getcwd() . ".") if T(2);
462 :     } else {
463 :     Trace("Updating configuration file in " . getcwd() . ".") if T(2);
464 :     DocUtils::ModifyConfigFile("FIG_Config.pm", \%changes, $inserts);
465 :     }
466 :     # The next step is to update the shell script. We need to add CVS information and
467 :     # the temp directory.
468 :     my %elims = (CVSROOT => $cvsroot,
469 :     CVS_RSH => 'ssh',
470 :     TMPDIR => "$target_dir/FIG/Tmp",
471 :     );
472 :     # Switch to the configuration directory.
473 :     ChDir("$target_dir/config");
474 :     # Check to see if we're in test mode.
475 :     if ($options->{test}) {
476 :     Trace("File fig-user-env.sh would be updated.") if T(2);
477 :     for my $elim (keys %elims) {
478 :     Trace("export $elim = \"$elims{$elim}\"") if T(2);
479 :     }
480 :     } else {
481 :     # Slurp in the entire file.
482 :     my @lines = Tracer::GetFile("fig-user-env.sh");
483 :     # Loop through the variables.
484 :     for my $elim (keys %elims) {
485 :     # Remove any existing lines for the variable.
486 :     @lines = grep { $_ !~ /(export $elim)|($elim=)/ } @lines;
487 :     # Add the new lines.
488 :     Trace("Updating $elim in fig-user-env.sh.");
489 :     push @lines, "$elim=\"$elims{$elim}\"";
490 :     push @lines, "export $elim";
491 :     }
492 :     # Write the file back out.
493 :     Open(\*FIGOUT, ">fig-user-env.sh~");
494 :     for my $line (@lines) {
495 :     print FIGOUT "$line\n";
496 :     }
497 :     close FIGOUT;
498 :     rename "fig-user-env.sh~", "fig-user-env.sh";
499 :     }
500 : parrello 1.2 # Copy the WebApplication configuration subdirectory from the
501 :     # current version to the next version. First, we get our current
502 :     # configuration directory.
503 :     my $currentConfig = "$FIG_Config::fig_disk/config";
504 :     # Now we create the web-application subdirectory in the target directory.
505 :     mkdir "WebApplication";
506 :     # Copy across the files inside.
507 :     my @lines = `cp -r $currentConfig/WebApplication/* $target_dir/config/WebApplication`;
508 :     Trace("WebApplication configuration files copied:\n" . join("\n", @lines)) if T(2);
509 : parrello 1.1 # Finally, create a marker file to protect this installation from
510 :     # automatic updates.
511 :     my $marker_file = "$target_dir/config/DISABLE_P2P";
512 :     if ($options->{test}) {
513 :     Trace("Marker file $marker_file would be created.") if T(2);
514 :     } else {
515 :     Trace("Creating marker file $marker_file.") if T(2);
516 :     Open(\*FIGOUT, ">$marker_file");
517 :     print FIGOUT "\n";
518 :     close FIGOUT;
519 :     }
520 :     # We're done.
521 :     Trace("Stage 3 complete.") if T(2);
522 :     }
523 :     #
524 :     # STAGE 4: fix the file permissions.
525 :     #
526 :     if ($options->{stage} <= 4) {
527 :     # Get the group name and ID.
528 :     my $gname = $options->{group};
529 :     my $gid = getgrnam($gname);
530 :     if ($options->{test}) {
531 :     Trace("Permission fix would occur in $version_dir. Group $gname has ID $gid.") if T(2);
532 :     } else {
533 :     # Set the permissions.
534 :     Tracer::SetPermissions($version_dir, $options->{group}, 02664, tmp => 02777);
535 :     }
536 : parrello 1.2 Trace("Stage 4 complete.") if T(2);
537 :     }
538 :     #
539 :     # STAGE 5: Copy the cover pages.
540 :     #
541 :     if ($options->{stage} <= 5) {
542 :     Trace("Copying cover pages.") if T(2);
543 : parrello 1.3 my @syncData = `rsync --archive --recursive /disks/nmpdr/v$old_version/html $version_dir/`;
544 : parrello 1.2 Trace("Copy results\n" . join("\n", @syncData)) if T(3);
545 :     # Create the version number file for the wiki.
546 :     my $text = join("\n", "<?php",
547 :     "\$wgNmpdrVersion = $version;",
548 :     "?>",
549 :     "");
550 : parrello 1.3 my $fh = Tracer::Open(undef, ">$version_dir/html/wiki/extensions/NmpdrVersion.php");
551 : parrello 1.2 print "$fh", $text;
552 :     close $fh;
553 :     Trace("Version file created for wiki.") if T(2);
554 : parrello 1.1 Trace("Stage 5 complete.") if T(2);
555 :     }
556 :     #
557 : parrello 1.2 # STAGE 6: Copy the drug target files.
558 : parrello 1.1 #
559 : parrello 1.2 if ($options->{stage} <= 6) {
560 :     Trace("Copying drug target files.") if T(2);
561 : parrello 1.3 my @syncData = ` rsync --archive --recursive /disks/nmpdr/v$old_version/FIGdisk/FIG/var/DrugTargets $version_dir/FIGdisk/FIG/var/`;
562 : parrello 1.2 Trace("Copy results\n" . join("\n", @syncData)) if T(3);
563 :     Trace("Stage 6 complete.") if T(2);
564 : parrello 1.1 }
565 : parrello 1.2
566 : parrello 1.1 Trace("Processing complete.") if T(0);
567 :    
568 :     # Forge a symbolic Link.
569 :     sub do_symlink {
570 :     my($from, $to) = @_;
571 :     # Erase the old link if necessary.
572 :     if (-e $to) {
573 :     Trace("Erasing old link $to.") if T(3);
574 :     unlink $to;
575 :     }
576 :     symlink($from, $to) ||
577 :     Confess("Symlink $from $to failed: $!");
578 :     }
579 :    
580 :     # Untar a bunch of files.
581 :     sub do_untar {
582 :     my($file) = @_;
583 :     my $args = "-x -f $file";
584 :     if ($file =~ /gz$/) {
585 :     $args .= " -z";
586 :     } elsif ($file =~ /bz2/) {
587 :     $args .= " -j";
588 :     }
589 :     my $cmd = "tar $args";
590 :     my $rc = system($cmd);
591 :     if ($rc != 0) {
592 :     Confess("tar failed with rc=$rc: $cmd");
593 :     }
594 :     }
595 :    
596 : parrello 1.9 1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3