Changeset 205


Ignore:
Timestamp:
08/16/15 21:19:27 (9 years ago)
Author:
kdeugau
Message:

/trunk

Fix, extend, and clean up command line -t handling. Patch by Andreas
Scherer, modulo some offset shifts probably due to out of order patching:

In its current state of version 0.11.3, debbuild seems to support the
'-t' option with .tar.gz files exclusively. Unzipped .tar files and
bzipped/xzipped .tar files couldn't be properly handled by zcat, nor
could .zip files.

TODO: Try to reduce/merge the three large logic constructs for selecting
"some action" according to the file extension.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/debbuild

    r204 r205  
    364364
    365365if ($cmdopts{type} eq 't') {
    366   # Need to unpack the tarball to find the spec file.  Sort of the inverse of -b above.
    367   # Note that rpmbuild doesn't seem to support this operation from a .zip file, so neither will we.
    368   # zcat $tarball |tar -t |grep .spec
    369   # collect some info about the tarball
    370   $specfile = "$topdir/BUILD/". qx { zcat $tarball |tar -t |grep -e '[\.]spec\$' };
     366  # Need to unpack the $tarball to find the spec file.  Sort of the inverse of
     367  # -b above.  Note that rpmbuild doesn't seem to support this operation from a
     368  # .zip file properly, but we try our best.
     369  $specfile = "$topdir/BUILD/";
     370  if ($tarball =~ /\.zip$/) {
     371    # .zip files are not really tarballs
     372    $specfile .= qx { /usr/bin/zipinfo -1 $tarball '*.spec' };
     373  } elsif ($tarball =~ /\.tar$/) {
     374    # plain .tar files don't need to be uncompressed
     375    $specfile .= qx { /bin/tar -tf $tarball --wildcards '*.spec' };
     376  } else {
     377    # select the decompressor according to the file extension
     378    $specfile .=
     379      ( $tarball =~ /\.(?:tgz|tar\.(?:gz|Z))$/ ?
     380          qx { /bin/zcat $tarball | /bin/tar -t | grep -e '[\.]spec\$' } :
     381        $tarball =~ /\.tar\.bz2$/ ?
     382          qx { /bin/bzcat $tarball | /bin/tar -t | grep -e '[\.]spec\$' } :
     383        $tarball =~ /\.tar\.xz$/ ?
     384          qx { /usr/bin/xzcat $tarball | /bin/tar -t | grep -e '[\.]spec\$' } :
     385        die("Can't handle unknown file type '$tarball'.") );
     386  }
    371387  chomp $specfile;
    372   my ($fileonly, $dirname) = ($tarball =~ /(([a-zA-Z0-9._-]+)\.(?:tgz|tar\.(?:gz|bz2|xz|Z)))$/);
    373388
    374389  $tarball = abs_path($tarball);
    375390##fixme:  use macro expansions for the executables
    376   my $unpackcmd = "cd $topdir/BUILD; ".
    377         ( $tarball =~ /\.(?:tgz|tar\.(?:gz|Z))$/         ? "/bin/gzip"   : "" ).
    378         ( $tarball =~ /\.tar\.bz2$/                      ? "/bin/bzip2"  : "" ).
    379         ( $tarball =~ /\.tar\.xz$/                       ? "/usr/bin/xz" : "" ).
    380         " -dc $tarball |/bin/tar -xf -";
     391  my $unpackcmd = "cd $topdir/BUILD;\n";
     392  if ($tarball =~ /\.zip$/) {
     393    # .zip files are not really tarballs
     394    $unpackcmd .= "/usr/bin/unzip -boa $tarball";
     395  } elsif ($tarball =~ /\.tar$/) {
     396    # plain .tar files don't need to be uncompressed
     397    $unpackcmd .= "/bin/tar -xf $tarball";
     398  } else {
     399    # select the decompressor according to the file extension
     400    $unpackcmd .=
     401      ( $tarball =~ /\.(?:tgz|tar\.(?:gz|Z))$/ ? "/bin/gzip"   :
     402        $tarball =~ /\.tar\.bz2$/              ? "/bin/bzip2"  :
     403        $tarball =~ /\.tar\.xz$/               ? "/usr/bin/xz" :
     404        die("Can't handle unknown file type '$tarball'.") ).
     405      " -dc $tarball | /bin/tar -xf -";
     406  }
    381407
    382408  system "$unpackcmd";
    383   system "cp $tarball $topdir/SOURCES/$fileonly";
    384   system "cp $specfile $topdir/SPECS/";
     409  system "cp -f $tarball $topdir/SOURCES/";
     410  system "cp -f $specfile $topdir/SPECS/";
    385411  parse_spec();
    386412  die "Can't build $pkgdata{main}{name}:  build requirements not met.\n"
     
    20452071   if ($sourcedrop =~ /\.zip$/) {
    20462072      # .zip files are not really tarballs
    2047       $cmdstring .= "/usr/bin/unzip".
     2073      $cmdstring .= "/usr/bin/unzip -o".
    20482074         ( $quietunpack ? ' -qq ' : ' ' ).
    20492075         "'$topdir/SOURCES/$sourcedrop'";
Note: See TracChangeset for help on using the changeset viewer.