The following commit has been merged in the master branch:
commit 3ea0a6ad5b658a26a9b12f0abff708e875674b9a
Author: James McCoy <[email protected]>
Date:   Fri Dec 9 23:10:49 2011 -0500

    Update tools to uniformly handle the supported compression types.
    
    Closes: #650118
    Signed-off-by: James McCoy <[email protected]>

diff --git a/debian/changelog b/debian/changelog
index 6a2bc86..f554356 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,10 @@ devscripts (2.11.3) UNRELEASED; urgency=low
   * manpage typographic and convention review. (Closes: #649450)
   * French translation update.
 
+  [ James McCoy ]
+  * Update tools to uniformly handle the supported compression types for
+    source packages.  (Closes: #650118)
+
  -- David Prévot <[email protected]>  Sat, 03 Dec 2011 11:39:52 -0400
 
 devscripts (2.11.2) unstable; urgency=low
diff --git a/scripts/dcmd.sh b/scripts/dcmd.sh
index 63d56c6..5577013 100755
--- a/scripts/dcmd.sh
+++ b/scripts/dcmd.sh
@@ -159,6 +159,8 @@ for arg in "$@"; do
                [ "$ARCHUDEB" = "0" ] || echo "newarg=\"\$newarg $THISARG\";"
                echo "SEEN_ARCHUDEB=1;"
            elif endswith "$THISARG" .tar.gz || \
+                endswith "$THISARG" .tar.xz || \
+                endswith "$THISARG" .tar.lzma || \
                 endswith "$THISARG" .tar.bz2; then
                [ "$TARBALL" = "0" ] || echo "newarg=\"\$newarg $THISARG\";"
                echo "SEEN_TARBALL=1;"
diff --git a/scripts/debchange.pl b/scripts/debchange.pl
index 5e54cf9..5cbe949 100755
--- a/scripts/debchange.pl
+++ b/scripts/debchange.pl
@@ -39,6 +39,7 @@ use Getopt::Long qw(:config gnu_getopt);
 use File::Copy;
 use File::Basename;
 use Cwd;
+use Dpkg::Compression;
 use lib '/usr/share/devscripts';
 use Devscripts::Debbugs;
 
@@ -1470,7 +1471,7 @@ if ((basename(cwd()) =~ m%^\Q$PACKAGE\E-\Q$UVERSION\E$%) 
&&
        }
        # And check whether a new orig tarball exists
        my @origs = glob("../$PACKAGE\_$new_uversion.*");
-       my $num_origs = grep { 
/^..\/\Q$PACKAGE\E_\Q$new_uversion\E\.orig\.tar\.(gz|bz2|lzma|xz)$/ } @origs;
+       my $num_origs = grep { 
/^..\/\Q$PACKAGE\E_\Q$new_uversion\E\.orig\.tar\.$compression_re_file_ext$/ } 
@origs;
        if ($num_origs == 0) {
            warn "$progname warning: no orig tarball found for the new 
version.\n";
        }
diff --git a/scripts/debcheckout.pl b/scripts/debcheckout.pl
index 043f1f5..3e23505 100755
--- a/scripts/debcheckout.pl
+++ b/scripts/debcheckout.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 #
 # debcheckout: checkout the development repository of a Debian package
 # Copyright (C) 2007-2009  Stefano Zacchiroli <[email protected]>
@@ -229,6 +229,7 @@ use File::Basename;
 use File::Copy qw/copy/;
 use File::Temp qw/tempdir/;
 use Cwd;
+use Dpkg::Compression;
 use lib '/usr/share/devscripts';
 use Devscripts::Versort;
 
@@ -322,7 +323,7 @@ sub find_repo($$) {
            ($type, $url) = (lc($2), $3);
        } elsif ($line =~ /^Version:\s*(.*)$/i) {
            $version = $1;
-       } elsif ($line =~ /^ [a-f0-9]{32} \d+ (\S+)\.orig\.tar\.gz$/) {
+       } elsif ($line =~ /^ [a-f0-9]{32} \d+ 
(\S+)\.orig\.tar\.$compression_re_file_ext$/) {
            $origtgz_name = $1;
        } elsif ($line =~ /^$/) {
            push (@repos, [$version, $type, $url, $origtgz_name])
diff --git a/scripts/debdiff.pl b/scripts/debdiff.pl
index e0d5c63..62a50ab 100755
--- a/scripts/debdiff.pl
+++ b/scripts/debdiff.pl
@@ -17,6 +17,7 @@
 use 5.006_000;
 use strict;
 use Cwd;
+use Dpkg::Compression;
 use File::Basename;
 use File::Temp qw/ tempdir tempfile /;
 use lib '/usr/share/devscripts';
@@ -459,7 +460,7 @@ elsif ($type eq 'dsc') {
                if ($file =~ /\.diff\.gz$/) {
                    $diffs[$i] = cwd() . '/' . $file;
                }
-               elsif ($file =~ /(\.orig)?\.tar\.(gz|bz2|lzma|xz)$/) {
+               elsif ($file =~ /(?:\.orig)?\.tar\.$compression_re_file_ext$/) {
                    $origs[$i] = $file;
                }
            } else {
@@ -546,9 +547,9 @@ elsif ($type eq 'dsc') {
            my $cmd = qq(cd ${"dir$i"} && dpkg-source @opts $dscs[$i] 
>/dev/null);
            system $cmd;
            if ($? != 0) {
-                   my $dir = dirname $dscs[1] if $i == 2;
-                   $dir = dirname $dscs[2] if $i == 1;
-                   my $cmdx = qq(cp $dir/$origs[$i] ${"dir$i"} >/dev/null);
+                   my $dir = dirname $dscs[1] if $i == 2;
+                   $dir = dirname $dscs[2] if $i == 1;
+                   my $cmdx = qq(cp $dir/$origs[$i] ${"dir$i"} >/dev/null);
                    system $cmdx;
                    fatal "$cmd failed" if $? != 0;
                    my $dscx = basename $dscs[$i];
@@ -572,15 +573,11 @@ elsif ($type eq 'dsc') {
            while ($_ = readdir(DIR)) {
                    my $unpacked = "=unpacked-tar" . $tarballs . "=";
                    my $filename = $_;
-                   if ($_ =~ /tar.gz$/) {
-                       $filename =~ s%(.*)\.tar\.gz$%$1%;
+                   if ($filename =~ s/\.tar\.$compression_re_file_ext$//) {
+                       my $comp = compression_guess_from_filename($_);
+                       my $decomp = compression_get_property($comp, 
'decomp_prog');
                        $tarballs++;
-                       system qq(cd ${"dir$i"}/${"sdir$i"} && tar zxf $_ 
>/dev/null && test -d $filename && mv $filename $unpacked);
-                   }
-                   if ($_ =~ /tar.bz$/ || $_ =~ /tar.bz2$/) {
-                       $filename =~ s%(.*)\.tar\.bz2?$%$1%;
-                       $tarballs++;
-                       system qq(cd ${"dir$i"}/${"sdir$i"} && tar jxf $_ 
>/dev/null && test -d $filename && mv $filename $unpacked);
+                       system qq(cd ${"dir$i"}/${"sdir$i"} && @$decomp $_ | 
tar xf >/dev/null && test -d $filename && mv $filename $unpacked);
                    }
            }
            closedir(DIR);
diff --git a/scripts/debuild.pl b/scripts/debuild.pl
index ac149a1..33fa35b 100755
--- a/scripts/debuild.pl
+++ b/scripts/debuild.pl
@@ -53,6 +53,7 @@ use 5.008;
 use File::Basename;
 use filetest 'access';
 use Cwd;
+use Dpkg::Compression;
 use IO::Handle;  # for flushing
 use vars qw(*BUILD *OLDOUT *OLDERR);  # prevent a warning
 
@@ -1212,11 +1213,12 @@ EOT
 
        my $srcmsg;
 
+       my $ext = $compression_re_file_ext;
        if (fileomitted @files, '\.deb') {
            # source only upload
-           if (fileomitted @files, '\.diff\.gz') {
+           if (fileomitted @files, "\\.diff\\.$ext" and fileomitted @files 
"\\.debian\\.tar\\.$ext") {
                $srcmsg='source only upload: Debian-native package';
-           } elsif (fileomitted @files, '\.orig\.tar\.gz') {
+           } elsif (fileomitted @files, "\\.orig\\.tar\\.$ext") {
                $srcmsg='source only, diff-only upload (original source NOT 
included)';
            } else {
                $srcmsg='source only upload (original source is included)';
@@ -1224,9 +1226,9 @@ EOT
        } else {
            if (fileomitted @files, '\.dsc') {
                $srcmsg='binary only upload (no source included)'
-           } elsif (fileomitted @files, '\.diff\.gz') {
+           } elsif (fileomitted @files, "\\.diff\\.$ext" and fileomitted 
@files "\\.debian\\.tar\\.$ext") {
                $srcmsg='full upload; Debian-native package (full source is 
included)';
-           } elsif (fileomitted @files, '\.orig\.tar\.gz') {
+           } elsif (fileomitted @files, "\\.orig\\.tar\\.$ext") {
                $srcmsg='binary and diff upload (original source NOT included)';
            } else {
                $srcmsg='full upload (original source is included)';
diff --git a/scripts/dget.pl b/scripts/dget.pl
index ef2d8de..20d8610 100755
--- a/scripts/dget.pl
+++ b/scripts/dget.pl
@@ -31,6 +31,7 @@ use Cwd qw(abs_path);
 use IO::Dir;
 use IO::File;
 use Digest::MD5;
+use Dpkg::Compression;
 use Getopt::Long qw(:config gnu_getopt);
 use File::Basename;
 
@@ -198,7 +199,8 @@ sub get_file {
     }
 
     # try apt-get if it is still not there
-    if (not -e $file and $file =~ 
m!^([a-z0-9.+-]{2,})_[^/]+\.(?:diff\.gz|tar\.gz)$!) {
+    my $ext = $compression_re_file_ext;
+    if (not -e $file and $file =~ 
m!^([a-z0-9.+-]{2,})_[^/]+\.(?:diff|tar)\.$ext$!) {
        my @cmd = ('apt-get', 'source', '--print-uris', $1);
        my $cmd = join ' ', @cmd;
        open(my $apt, '-|', @cmd) or die "$cmd: $!";
diff --git a/scripts/dscextract.sh b/scripts/dscextract.sh
index aac45ee..ea5b913 100755
--- a/scripts/dscextract.sh
+++ b/scripts/dscextract.sh
@@ -24,6 +24,15 @@ die () {
        exit 2
 }
 
+setzip () {
+       case $1 in
+               *.gz) ZIP=--gzip ;;
+               *.xz) ZIP=--xz ;;
+               *.lzma) ZIP=--lzma ;;
+               *.bz2) ZIP=--bzip2 ;;
+       esac
+}
+
 FAST=""
 while getopts "f" opt ; do
        case $opt in
@@ -43,7 +52,7 @@ DSCDIR=$(dirname "$DSC")
 WORKDIR=$(mktemp -d --tmpdir dscextract.XXXXXX)
 trap "rm -rf $WORKDIR" 0 2 3 15
 
-if DIFFGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ ]+\.diff\.(gz|bz2)$' "$DSC") ; 
then
+if DIFFGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ ]+\.diff\.(gz|xz|lzma|bz2)$' 
"$DSC") ; then
        DIFFGZ=$(echo "$DIFFGZ" | cut -d ' ' -f 4 | head -n 1)
        test -e "$DSCDIR/$DIFFGZ" || die "$DSCDIR/$DIFFGZ: not found"
        filterdiff -p1 -i "$FILE" -z "$DSCDIR/$DIFFGZ" > "$WORKDIR/patch"
@@ -51,14 +60,11 @@ if DIFFGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ 
]+\.diff\.(gz|bz2)$' "$DSC") ; th
                # case 1: file found in .diff.gz
                if ! grep -q '^@@ -0,0 ' "$WORKDIR/patch" ; then
                        # case 1a: patch requires original file
-                       ORIGTGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ 
]+\.orig\.tar\.(gz|bz2)$' "$DSC") || die "no orig.tar.gz found in $DSC"
+                       ORIGTGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ 
]+\.orig\.tar\.(gz|xz|lzma|bz2)$' "$DSC") || die "no orig.tar.* found in $DSC"
                        ORIGTGZ=$(echo "$ORIGTGZ" | cut -d ' ' -f 4 | head -n 1)
-                       case $ORIGTGZ in
-                               *.gz) ZIP=--gzip ;;
-                               *.bz2) ZIP=--bzip2 ;;
-                       esac
+                       setzip $ORIGTGZ
                        test -e "$DSCDIR/$ORIGTGZ" || die "$DSCDIR/$ORIGTGZ not 
found"
-                       tar --extract --to-stdout --gzip --file 
"$DSCDIR/$ORIGTGZ" --wildcards "*/$FILE" > "$WORKDIR/output" 2>/dev/null || :
+                       tar --extract --to-stdout $ZIP --file 
"$DSCDIR/$ORIGTGZ" --wildcards "*/$FILE" > "$WORKDIR/output" 2>/dev/null || :
                        test -s "$WORKDIR/output" || die "$FILE not found in 
$DSCDIR/$ORIGTGZ, but required by patch"
                fi
                patch --silent "$WORKDIR/output" < "$WORKDIR/patch"
@@ -71,15 +77,12 @@ if DIFFGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ 
]+\.diff\.(gz|bz2)$' "$DSC") ; th
        fi
 fi
 
-if DEBIANTARGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ 
]+\.debian\.tar\.(gz|bz2)$' "$DSC") ; then
+if DEBIANTARGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ 
]+\.debian\.tar\.(gz|xz|lzma|bz2)$' "$DSC") ; then
        case $FILE in
                debian/*)
                        DEBIANTARGZ=$(echo "$DEBIANTARGZ" | cut -d ' ' -f 4 | 
head -n 1)
                        test -e "$DSCDIR/$DEBIANTARGZ" || die 
"$DSCDIR/$DEBIANTARGZ not found"
-                       case $DEBIANTARGZ in
-                               *.gz) ZIP=--gzip ;;
-                               *.bz2) ZIP=--bzip2 ;;
-                       esac
+                       setzip $DEBIANTARGZ
                        tar --extract --to-stdout $ZIP --file 
"$DSCDIR/$DEBIANTARGZ" "$FILE" > "$WORKDIR/output" 2>/dev/null || :
                        test -s "$WORKDIR/output" || exit 1
                        # case 2a: file found in .debian.tar.gz
@@ -88,13 +91,10 @@ if DEBIANTARGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ 
]+\.debian\.tar\.(gz|bz2)$'
                        # for 3.0 format, no need to look in other places here
                        ;;
                *)
-                       ORIGTGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ 
]+\.orig\.tar\.(gz|bz2)$' "$DSC") || die "no orig.tar.gz found in $DSC"
+                       ORIGTGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ 
]+\.orig\.tar\.(gz|xz|lzma|bz2)$' "$DSC") || die "no orig.tar.gz found in $DSC"
                        ORIGTGZ=$(echo "$ORIGTGZ" | cut -d ' ' -f 4 | head -n 1)
                        test -e "$DSCDIR/$ORIGTGZ" || die "$DSCDIR/$ORIGTGZ not 
found"
-                       case $ORIGTGZ in
-                               *.gz) ZIP=--gzip ;;
-                               *.bz2) ZIP=--bzip2 ;;
-                       esac
+                       setzip $ORIGTGZ
                        tar --extract --to-stdout $ZIP --file 
"$DSCDIR/$ORIGTGZ" --wildcards --no-wildcards-match-slash "*/$FILE" > 
"$WORKDIR/output" 2>/dev/null || :
                        test -s "$WORKDIR/output" || exit 1
                        # case 2b: file found in .orig.tar.gz
@@ -105,13 +105,10 @@ if DEBIANTARGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ 
]+\.debian\.tar\.(gz|bz2)$'
        esac
 fi
 
-if TARGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ ]+\.tar\.(gz|bz2)$' "$DSC") ; 
then
+if TARGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ ]+\.tar\.(gz|xz|lzma|bz2)$' 
"$DSC") ; then
        TARGZ=$(echo "$TARGZ" | cut -d ' ' -f 4 | head -n 1)
        test -e "$DSCDIR/$TARGZ" || die "$DSCDIR/$TARGZ not found"
-       case $TARGZ in
-               *.gz) ZIP=--gzip ;;
-               *.bz2) ZIP=--bzip2 ;;
-       esac
+       setzip $TARGZ
        tar --extract --to-stdout $ZIP --file "$DSCDIR/$TARGZ" --wildcards 
--no-wildcards-match-slash "*/$FILE" > "$WORKDIR/output" 2>/dev/null || :
        test -s "$WORKDIR/output" || exit 1
        # case 3: file found in .tar.gz or .orig.tar.gz

-- 
Git repository for devscripts


-- 
To unsubscribe, send mail to [email protected].

Reply via email to