IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 3, 2011, 2:51:02 PM (15 years ago)
Author:
bills
Message:

Changes to support storing distribution bundles in nebulous

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/dist_bundle.pl

    r29960 r30489  
    1616
    1717use IPC::Cmd 0.36 qw( can_run run );
    18 use File::Temp qw( tempfile );
     18use File::Temp qw( tempfile tempdir );
    1919use File::Basename qw( basename );
    2020use Digest::MD5::File qw( file_md5_hex );
     
    7171# Parse the command-line arguments
    7272my ($camera, $stage, $stage_id, $component, $path_base, $chip_path_base, $alt_path_base, $clean);
    73 my ($outdir, $run_state, $data_state, $magicked, $no_magic, $poor_quality, $results_file, $prefix);
     73my ($outroot, $run_state, $data_state, $magicked, $no_magic, $poor_quality, $results_file, $prefix);
    7474my ($dbname, $save_temps, $verbose, $no_update, $logfile);
    7575
     
    8888           'magicked'       => \$magicked,   # magicked state for this component
    8989           'alt_path_base=s'=> \$alt_path_base,  # path to alternate inputs
    90            'outdir=s'       => \$outdir,     # "directory" for outputs
     90           'outroot=s'      => \$outroot,    # outroot
    9191           'prefix=s'       => \$prefix,     # "prefix" to apply to filenames
    9292           'clean'          => \$clean,      # create clean distribution
     
    9999
    100100pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    101 pod2usage( -msg => "Required options: --camera --stage --stage_id --component --path_base --outdir",
     101pod2usage( -msg => "Required options: --camera --stage --stage_id --component --path_base --outroot",
    102102           -exitval => 3) unless
    103103    defined $camera and
     
    106106    defined $component and
    107107    defined $path_base and
    108     defined $outdir;
     108    defined $outroot;
    109109
    110110$ipprc->redirect_output($logfile) if $logfile;
     
    116116$ipprc->define_camera($camera);
    117117
    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);
    126119
    127120# Get the list of data products for this component
     
    138131# set up directory for temporary files
    139132
    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);
     133my $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
     137my $tmpdir  = tempdir("$temproot/dist.XXXX", CLEANUP => !$save_temps);
    151138
    152139#
     
    349336if ($num_files) {
    350337    # 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    }
    356370
    357371    my $command = "tar -C $tmpdir --owner=ipp --group=users -czhf $tarfile .";
Note: See TracChangeset for help on using the changeset viewer.