IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29960 for trunk/ippScripts


Ignore:
Timestamp:
Dec 6, 2010, 2:53:16 PM (15 years ago)
Author:
bills
Message:

detect and handle compresssed config dump files

File:
1 edited

Legend:

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

    r29063 r29960  
    6262my $streaksrelease   = can_run('streaksrelease') or (warn "Can't find streaksrelease" and $missing_tools = 1);
    6363my $bgtool   = can_run('bgtool') or (warn "Can't find bgtool" and $missing_tools = 1);
     64my $file_cmd   = can_run('file') or (warn "can't find program file" and $missing_tools = 1);
     65my $zcat   = can_run('zcat') or (warn "can't find program zcat" and $missing_tools = 1);
    6466if ($missing_tools) {
    6567    warn("Can't find required tools.");
     
    526528                    $PS_EXIT_CONFIG_ERROR) if (!$resolved);
    527529
     530    &my_die("config dump file resolved but not accessible: $config_file_rule", $component,
     531                    $PS_EXIT_CONFIG_ERROR) if !$ipprc->file_exists($resolved);
     532
     533    my $mdc_compressed;
     534    {
     535        my $command = "$file_cmd $resolved";
     536        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     537            run(command => $command, verbose => $verbose);
     538        unless ($success) {
     539            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     540            &my_die("Unable to perform $command: $error_code", $component, $error_code);
     541        }
     542        my $output = join "", @$stdout_buf;
     543        # XXX: may need to to make this more robust
     544        $mdc_compressed = ($output =~ /gzip/);
     545    }
     546    my $inName;
     547    if ($mdc_compressed) {
     548        my $tmpfile;
     549        ($tmpfile, $inName) = tempfile( "/tmp/bundle.XXXX", UNLINK => !$save_temps );
     550        close($tmpfile) or &my_die("failed to close $inName", $component, $PS_EXIT_UNKNOWN_ERROR);
     551
     552        my $command = "$zcat $resolved > $inName";
     553        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     554            run(command => $command, verbose => $verbose);
     555        unless ($success) {
     556            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     557            &my_die("Unable to perform $command: $error_code", $component, $error_code);
     558        }
     559
     560
     561    } else {
     562        $inName = $resolved;
     563    }
     564    my $in = open_with_retries($inName);
     565
    528566    # we don't use the mdc parser because the perl parser is way is too slow for complicated config
    529567    # files like this
    530     my $in = open_with_retries($resolved);
    531 
    532568    my $line;
    533569    while ($line = <$in>) {
Note: See TracChangeset for help on using the changeset viewer.