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

Annotation of /Sprout/NMPDRSetup.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3