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

Annotation of /Sprout/NMPDRSetup.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3