Changeset 198


Ignore:
Timestamp:
08/03/15 17:07:09 (9 years ago)
Author:
kdeugau
Message:

/trunk

Add support for .zip files as "tarballs".

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/debbuild

    r196 r198  
    363363if ($cmdopts{type} eq 't') {
    364364  # Need to unpack the tarball to find the spec file.  Sort of the inverse of -b above.
     365  # Note that rpmbuild doesn't seem to support this operation from a .zip file, so neither will we.
    365366  # zcat $tarball |tar -t |grep .spec
    366367  # collect some info about the tarball
     
    913914#   Looks to be "expand -a into $aftersource and expand -b into $beforesource inside the while()"
    914915#   instead of treating them as flags like the other arguments.
     916# Known differences
    915917# - -q appears to be somewhat positional
     918# - rpmbuild requires -n on all %setup macros, but carries the first down to %install etc,
     919#   debbuild sets the global on the first call, and keeps using it for further %setup calls
    916920
    917921        $prepscript .= "cd '$topdir/BUILD'\n";
     
    922926        if ($deftarball) {
    923927          $prepscript .= "cd '$tarballdir'\n" if $changedir;
    924           $prepscript .=
     928          if ($pkgdata{main}{source} =~ /\.zip$/) {
     929            # .zip files are not really tarballs
     930            $prepscript .= "/usr/bin/unzip".
     931                ( $quietunpack ? ' -qq ' : ' ' ).
     932                "'$topdir/SOURCES/$pkgdata{main}{source}'";
     933          } else {
     934            $prepscript .=
    925935                ( $pkgdata{main}{source} =~ /\.tar\.gz$/  ? "/bin/gzip"   : "" ).
    926936                ( $pkgdata{main}{source} =~ /\.tar\.bz2$/ ? "/bin/bzip2"  : "" ).
    927937                ( $pkgdata{main}{source} =~ /\.tar\.xz$/  ? "/usr/bin/xz" : "" ).
    928938                " -dc '$topdir/SOURCES/$pkgdata{main}{source}' | /bin/tar -x".
    929                 ( $quietunpack ? '' : 'vv' )."f -\n".
    930                 qq(STATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n  exit \$STATUS\nfi\n);
     939                ( $quietunpack ? '' : 'vv' )."f - ";
     940          }
     941          $prepscript .= qq(\nSTATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n  exit \$STATUS\nfi\n);
    931942        }
    932943
     
    934945          if ($altsource == 1) { # -a
    935946            $prepscript .= "cd '$tarballdir'\n";
    936             $prepscript .=
     947            if ($pkgdata{sources}{$snum} =~ /\.zip$/) {
     948              # .zip files are not really tarballs
     949              $prepscript .= "/usr/bin/unzip".
     950                ( $quietunpack ? ' -qq ' : ' ' ).
     951                "'$topdir/SOURCES/$pkgdata{sources}{$snum}'";
     952            } else {
     953              $prepscript .=
    937954                ( $pkgdata{sources}{$snum} =~ /\.tar\.gz$/  ? "/bin/gzip"   : "" ).
    938955                ( $pkgdata{sources}{$snum} =~ /\.tar\.bz2$/ ? "/bin/bzip2"  : "" ).
    939956                ( $pkgdata{sources}{$snum} =~ /\.tar\.xz$/  ? "/usr/bin/xz" : "" ).
    940957                " -dc '$topdir/SOURCES/$pkgdata{sources}{$snum}' | /bin/tar -x".
    941                 ( $quietunpack ? '' : 'vv' )."f -\n".
    942                 qq(STATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n  exit \$STATUS\nfi\n);
     958                ( $quietunpack ? '' : 'vv' )."f -";
     959            }
     960            $prepscript .= qq(\nSTATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n  exit \$STATUS\nfi\n);
    943961          } # $altsource == 1
    944962
    945963          if ($altsource == 2) { # -b
    946             $prepscript .=
     964            if ($pkgdata{sources}{$snum} =~ /\.zip$/) {
     965              # .zip files are not really tarballs
     966              $prepscript .= "/usr/bin/unzip".
     967                ( $quietunpack ? ' -qq ' : ' ' ).
     968                "'$topdir/SOURCES/$pkgdata{main}{source}'";
     969            } else {
     970              $prepscript .=
    947971                ( $pkgdata{sources}{$snum} =~ /\.tar\.gz$/  ? "/bin/gzip"   : "" ).
    948972                ( $pkgdata{sources}{$snum} =~ /\.tar\.bz2$/ ? "/bin/bzip2"  : "" ).
    949973                ( $pkgdata{sources}{$snum} =~ /\.tar\.xz$/  ? "/usr/bin/xz" : "" ).
    950974                " -dc '$topdir/SOURCES/$pkgdata{sources}{$snum}' | /bin/tar -x".
    951                 ( $quietunpack ? '' : 'vv' )."f -\n".
    952                 qq(STATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n  exit \$STATUS\nfi\n);
     975                ( $quietunpack ? '' : 'vv' )."f -";
     976            }
     977            $prepscript .= qq(\nSTATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n  exit \$STATUS\nfi\n);
    953978            $prepscript .= "cd '$tarballdir'\n";
    954979          } # $altsource == 2
     
    11461171        $pkgdata{main}{source} =~ s|^.+/([^/]+)$|$1|;
    11471172        $pkgdata{sources}{0} = $pkgdata{main}{source};
    1148         # .tar, .tar.gz, .tar.bz2, .tgz, .xz
    1149         die "Unknown Source: header format $sval\n" if $sval !~ /\.(?:tar(?:\.(?:gz|bz2|xz))?|tgz)$/;
     1173        # .tar, .tar.gz, .tar.bz2, .tgz, .xz, .zip
     1174        die "Unknown Source: header format $sval\n" if $sval !~ /\.(?:tar(?:\.(?:gz|bz2|xz))?|tgz|zip)$/;
    11501175      } elsif (my ($srcnum, $src) = (/^source([0-9]+):\s*(.+)/i)) {
    11511176        $src =~ s/\s*$//;
Note: See TracChangeset for help on using the changeset viewer.