- Timestamp:
- Feb 11, 2011, 2:49:34 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20101205/ippScripts/scripts/dist_bundle.pl
r30102 r30579 16 16 17 17 use IPC::Cmd 0.36 qw( can_run run ); 18 use File::Temp qw( tempfile );18 use File::Temp qw( tempfile tempdir ); 19 19 use File::Basename qw( basename ); 20 20 use Digest::MD5::File qw( file_md5_hex ); … … 71 71 # Parse the command-line arguments 72 72 my ($camera, $stage, $stage_id, $component, $path_base, $chip_path_base, $alt_path_base, $clean); 73 my ($out dir, $run_state, $data_state, $magicked, $no_magic, $poor_quality, $results_file, $prefix);73 my ($outroot, $run_state, $data_state, $magicked, $no_magic, $poor_quality, $results_file, $prefix); 74 74 my ($dbname, $save_temps, $verbose, $no_update, $logfile); 75 75 … … 88 88 'magicked' => \$magicked, # magicked state for this component 89 89 'alt_path_base=s'=> \$alt_path_base, # path to alternate inputs 90 'out dir=s' => \$outdir, # "directory" for outputs90 'outroot=s' => \$outroot, # outroot 91 91 'prefix=s' => \$prefix, # "prefix" to apply to filenames 92 92 'clean' => \$clean, # create clean distribution … … 99 99 100 100 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 101 pod2usage( -msg => "Required options: --camera --stage --stage_id --component --path_base --out dir",101 pod2usage( -msg => "Required options: --camera --stage --stage_id --component --path_base --outroot", 102 102 -exitval => 3) unless 103 103 defined $camera and … … 106 106 defined $component and 107 107 defined $path_base and 108 defined $out dir;108 defined $outroot; 109 109 110 110 $ipprc->redirect_output($logfile) if $logfile; … … 116 116 $ipprc->define_camera($camera); 117 117 118 # create the output directories if it is not a nebulous path and it doesn't exist 119 if (index($outdir, "neb://") != 0) { 120 if (! -e $outdir ) { 121 my $code = system "mkdir -p $outdir"; 122 &my_die("cannot create output directory $outdir", $component, 123 $code >> 8) if $code; 124 } 125 } 118 $ipprc->outroot_prepare($outroot); 126 119 127 120 # Get the list of data products for this component … … 138 131 # set up directory for temporary files 139 132 140 my $tmpdir = "$outdir/tmpdir.$component.$$"; 141 if (-e $tmpdir) { 142 if (-d $tmpdir) { 143 my $rc = system "rm -r $tmpdir"; 144 &my_die("cannot rm $tmpdir return code: $rc", $component, $PS_EXIT_UNKNOWN_ERROR) if $rc; 145 } else { 146 unlink $tmpdir or &my_die("cannot delete $tmpdir", $component, $PS_EXIT_UNKNOWN_ERROR); 147 } 148 } 149 mkdir $tmpdir or &my_die("cannot create temporary directory $tmpdir", $component, 150 $PS_EXIT_UNKNOWN_ERROR); 133 my $temproot = metadataLookupStr($ipprc->{_siteConfig}, "TEMP.DIR"); 134 $temproot = "/tmp" if !defined $temproot; 135 &my_die("directory for TEMP.DIR $temproot does not exist", $component, $PS_EXIT_CONFIG_ERROR) if ! -e $temproot; 136 137 my $tmpdir = tempdir("$temproot/dist.XXXX", CLEANUP => !$save_temps); 151 138 152 139 # … … 349 336 if ($num_files) { 350 337 # create the tarfile 351 # XXX TODO: create a file rule for the tar file name 352 my $tbase = basename($path_base); 353 $tbase .= ".$component" if $component; 354 $file_name = ($prefix ? $prefix : "") . "$tbase.tgz"; 355 my $tarfile = "$outdir/$file_name"; 338 # my $tbase = basename($path_base); 339 # $tbase .= ".$component" if $component; 340 # $file_name = ($prefix ? $prefix : "") . "$tbase.tgz"; 341 my $error; 342 my $output_tarfile; 343 my $rule; 344 if ($stage eq 'chip' or $stage eq 'chip_bg' or $stage eq 'raw') { 345 $rule = "DIST.OUTPUT.CHIP.BUNDLE"; 346 } else { 347 $rule = "DIST.OUTPUT.BUNDLE"; 348 } 349 $output_tarfile = $ipprc->prepare_output($rule, $outroot, $component, 1, \$error) 350 or &my_die("Failed to prepare output tarfile: $error", $component, $error); 351 $file_name = basename($output_tarfile); 352 353 354 my $scheme = file_scheme($output_tarfile); 355 356 my $tarfile; 357 if ($scheme) { 358 $ipprc->file_create($output_tarfile) 359 or &my_die("Failed to create $output_tarfile: $error", $component, $error); 360 $tarfile = $ipprc->file_resolve($output_tarfile); 361 362 if ($scheme eq 'neb') { 363 &my_die("output file $output_tarfile not found", $component, $PS_EXIT_SYS_ERROR) 364 unless ($tarfile and -e $tarfile); 365 } 366 } else { 367 # no scheme the filename and the resolved filename are the same 368 $tarfile = $output_tarfile; 369 } 356 370 357 371 my $command = "tar -C $tmpdir --owner=ipp --group=users -czhf $tarfile .";
Note:
See TracChangeset
for help on using the changeset viewer.
