The following commit has been merged in the master branch:
commit 3d27c6a7206b91ca4d43efb07621a1491fab1c11
Author: James Vega <[email protected]>
Date:   Mon Oct 17 20:55:26 2011 -0400

    uscan: Fully support lzma and xz tarballs.
    
    Closes: #631713
    Signed-off-by: James Vega <[email protected]>

diff --git a/debian/changelog b/debian/changelog
index 1f074fe..5b1570b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -20,6 +20,8 @@ devscripts (2.11.2) UNRELEASED; urgency=low
     supported.  Thanks to Matthijs Kooijman for the patch.  (Closes: #639813)
   * mergechanges: Use awk instead of sed to handle massaging the final output
     so we can better control the processing.  (Closes: #640782)
+  * uscan: Fully support lzma and xz tarballs.  Based on a patch from Tanguy
+    Ortolo.  (Closes: #631713)
 
   [ Stefano Rivera ]
   * debchange: Add precise as a recognised Ubuntu distro.
diff --git a/scripts/uscan.1 b/scripts/uscan.1
index efb1a39..15e529a 100644
--- a/scripts/uscan.1
+++ b/scripts/uscan.1
@@ -182,10 +182,8 @@ available is newer than the current version, then it is 
downloaded
 into the parent directory, unless the \fB\-\-report\fR or
 \fR\-\-report-status\fR option has been used.  Once the file has been
 downloaded, then a symlink to the file is made from
-\fI<package>_<version>.orig.tar.gz\fR if the file has a \fI.tar.gz\fR
-or a \fI.tgz\fR suffix and from \fI<package>_<version>.orig.tar.bz2\fR
-if the file has a \fI.tar.bz2\fR or a \fI.tbz\fR or \fI.tbz2\fR
-suffix.
+\fI<package>_<version>.orig.tar.{gz|bz2|lzma|xz}\fR as described by the help
+for the \fB\-\-symlink\fR option.
 .PP
 Finally, if a third parameter (an action) is given in the \fIwatch\fR file
 line, this is taken as the name of a command, and the command
@@ -364,25 +362,26 @@ Set timeout to N seconds (default 20 seconds).
 .TP
 .B \-\-symlink
 Make orig.tar.gz symlinks to any downloaded files if their extensions
-are \fI.tar.gz\fR or \fI.tgz\fR, and similarly for to orig.tar.bz2 for
-the suffixes \fI.tar.gz\fR, \fI.tbz\fR and \fI.tbz2\fR.  (This is the
+are \fI.tar.gz\fR or \fI.tgz\fR.  This is also handled for orig.tar.bz2 (for
+upstream \fI.tar.bz2\fR, \fI.tbz\fR, and \fI.tbz2\fR), orig.tar.lzma (for
+upstream \fI.tar.lzma\fR, \fI.tlz\fR, \fI.tlzm\fR, and \fI.tlzma\fR), and
+orig.tar.xz (for upstream \fI.tar.xz\fR and \fI.txz\fR).  (This is the
 default behaviour.)
 .TP
 .B \-\-rename
 Instead of symlinking, rename the downloaded files to their Debian
-\fIorig.tar.gz\fR names if their extensions are \fI.tar.gz\fR or \fI.tgz\fR,
-and similarly for \fItar.bz2\fR files.
+\fIorig.tar.gz\fR, \fIorig.tar.bz2\fR, \fIorig.tar.lzma\fR, or
+\fIorig.tar.xz\fR names as described above.
 .TP
 .B \-\-repack
 After having downloaded an lzma tar, xz tar, bzip tar or zip archive,
 repack it to a gzip tar archive, which is still currently required as a
 member of a Debian source package. Does nothing if the downloaded
 archive is not an lzma tar archive, xz tar archive, bzip tar archive or
-a zip archive (i.e. it doesn't match a .tlz, .tar.lzma, .txz, .tar.xz
-\^.tbz, .tbz2, .tar.bz2 or .zip extension). The unzip package must be
-installed in order to repack .zip archives, the lzma package must be
-installed to repack lzma tar archives, and the xz-utils package must be
-installed to repack xz tar archives.
+a zip archive (i.e. it doesn't match a .tlz, .tlzm, .tlzma, .tar.lzma, .txz,
+\^.tar.xz .tbz, .tbz2, .tar.bz2 or .zip extension). The unzip package must be
+installed in order to repack .zip archives, the xz-utils package must be
+installed to repack lzma or xz tar archives.
 .TP
 .B \-\-no\-symlink
 Don't make these symlinks and don't rename the files.
@@ -474,7 +473,7 @@ If set to a number \fIN\fR, then set the timeout to \fIN\fR 
seconds.
 This is equivalent to the \fB\-\-timeout\fR option.
 .TP
 .B USCAN_SYMLINK
-If this is set to \fIno\fR, then a pkg_version.orig.tar.{gz|bz2}
+If this is set to \fIno\fR, then a pkg_version.orig.tar.{gz|bz2|lzma|xz}
 symlink will not be made (equivalent to the \fB\-\-no\-symlink\fR
 option).  If it is set to \fIyes\fR or \fIsymlink\fR, then the
 symlinks will be made.  If it is set to \fIrename\fR, then the files
diff --git a/scripts/uscan.pl b/scripts/uscan.pl
index 2962c47..58a8b3e 100755
--- a/scripts/uscan.pl
+++ b/scripts/uscan.pl
@@ -92,9 +92,10 @@ Options:
                    servers to respond (default 20 seconds)
     --symlink      Make an orig.tar.gz symlink to downloaded file (default)
     --rename       Rename to orig.tar.gz instead of symlinking
-                   (Both will use orig.tar.bz2 if appropriate)
-    --repack       Repack downloaded archives from orig.tar.bz2 or orig.zip to
-                   orig.tar.gz
+                   (Both will use orig.tar.bz2, orig.tar.lzma, or orig.tar.xz
+                   if appropriate)
+    --repack       Repack downloaded archives from orig.tar.bz2, orig.tar.lzma,
+                   orig.tar.xz or orig.zip to orig.tar.gz
                    (does nothing if downloaded archive orig.tar.gz)
     --no-symlink   Don\'t make symlink or rename
     --verbose      Give verbose output
@@ -164,7 +165,7 @@ my $download = 1;
 my $download_version;
 my $force_download = 0;
 my $report = 0; # report even on up-to-date packages?
-my $repack = 0; # repack .tar.bz2 or .zip to .tar.gz
+my $repack = 0; # repack .tar.bz2, .tar.lzma, .tar.xz or .zip to .tar.gz
 my $symlink = 'symlink';
 my $verbose = 0;
 my $check_dirname_level = 1;
@@ -1250,7 +1251,7 @@ EOF
     }
 
     if (defined $pkg_dir) {
-       if (! -d "$destdir") {
+       if (! -d "$destdir") {
            print "Package directory '$destdir to store downloaded file is not 
existing\n";
            return 1;
        }
@@ -1259,15 +1260,12 @@ EOF
                if $verbose or ($download == 0 and ! $dehs);
            return 0;
        }
-       if (-f "$destdir/${pkg}_${newversion}.orig.tar.gz") {
-           print " => ${pkg}_${newversion}.orig.tar.gz already in package 
directory '$destdir'\n"
-               if $verbose or ($download == 0 and ! $dehs);
-           return 0;
-       }
-       elsif (-f "$destdir/${pkg}_${newversion}.orig.tar.bz2") {
-           print " => ${pkg}_${newversion}.orig.tar.bz2 already in package 
directory '$destdir'\n"
-               if $verbose or ($download == 0 and ! $dehs);
-           return 0;
+       foreach my $suffix (qw(gz bz2 lzma xz)) {
+           if (-f "$destdir/${pkg}_${newversion}.orig.tar.$suffix") {
+               print " => ${pkg}_${newversion}.orig.tar.$suffix already in 
package directory '$destdir'\n"
+                   if $verbose or ($download == 0 and ! $dehs);
+               return 0;
+           }
        }
     }
 
@@ -1392,7 +1390,10 @@ EOF
        $newfile_base = $newfile_base_gz;
     }
 
-    if ($newfile_base =~ /\.(tar\.gz|tgz|tar\.bz2|tbz2?)$/) {
+    if ($newfile_base =~ /\.(tar\.gz|tgz
+                            |tar\.bz2|tbz2?
+                            |tar.lzma|tlz(?:ma?)?
+                            |tar.xz|txz)$/x) {
        my $filetype = `file -b -k $destdir/$newfile_base`;
        unless ($filetype =~ /compressed data/) {
            warn "$progname warning: $destdir/$newfile_base does not appear to 
be a compressed file;\nthe file command says: $filetype\nNot processing this 
file any further!\n";
@@ -1400,89 +1401,61 @@ EOF
        }
     }
 
-    if ($newfile_base =~ /\.(tar\.gz|tgz)$/) {
-       if ($symlink eq 'symlink') {
-           symlink $newfile_base, "$destdir/${pkg}_${newversion}.orig.tar.gz";
-       } elsif ($symlink eq 'rename') {
-           move "$destdir/$newfile_base", 
"$destdir/${pkg}_${newversion}.orig.tar.gz";
+    my @renames = (
+       [qr/\.(tar\.gz|tgz)$/, 'gz'],
+       [qr/\.(tar\.bz2|tbz2?)$/, 'bz2'],
+       [qr/\.tar\.lzma|tlz(?:ma?)?$/, 'lzma'],
+       [qr/\.(tar\.xz|txz)$/, 'xz'],
+    );
+
+    my ($renamed_base);
+    foreach my $pair (@renames) {
+       if ($newfile_base !~ $pair->[0]) {
+           next;
        }
-    }
-    elsif ($newfile_base =~ /\.(tar\.bz2|tbz2?)$/) {
+
+       my ($pattern, $suffix) = @{$pair};
+       $renamed_base = "${pkg}_${newversion}.orig.tar.$suffix";
        if ($symlink eq 'symlink') {
-           symlink $newfile_base, "$destdir/${pkg}_${newversion}.orig.tar.bz2";
+           symlink $newfile_base, "$destdir/$renamed_base";
        } elsif ($symlink eq 'rename') {
-           move "$destdir/$newfile_base", 
"$destdir/${pkg}_${newversion}.orig.tar.bz2";
-       }
-    }
-
-    if ($verbose) {
-       print "-- Successfully downloaded updated package $newfile_base\n";
-       if ($newfile_base =~ /\.(tar\.gz|tgz)$/) {
-           if ($symlink eq 'symlink') {
-               print "    and symlinked ${pkg}_${newversion}.orig.tar.gz to 
it\n";
-           } elsif ($symlink eq 'rename') {
-               print "    and renamed it as 
${pkg}_${newversion}.orig.tar.gz\n";
-           }
+           move "$destdir/$newfile_base", "$destdir/$renamed_base";
        }
-       elsif ($newfile_base =~ /\.(tar\.bz2|tbz2?)$/) {
-           if ($symlink eq 'symlink') {
-               print "    and symlinked ${pkg}_${newversion}.orig.tar.bz2 to 
it\n";
-           } elsif ($symlink eq 'rename') {
-               print "    and renamed it as 
${pkg}_${newversion}.orig.tar.bz2\n";
-           }
-       }
-    } elsif ($dehs) {
-       my $msg = "Successfully downloaded updated package $newfile_base";
-       if ($newfile_base =~ /\.(tar\.gz|tgz)$/) {
-           $dehs_tags{'target'} = "${pkg}_${newversion}.orig.tar.gz";
+       if ($verbose) {
+           print "-- Successfully downloaded updated package $newfile_base\n";
            if ($symlink eq 'symlink') {
-               $msg .= " and symlinked ${pkg}_${newversion}.orig.tar.gz to it";
+               print "    and symlinked $renamed_base to it\n";
            } elsif ($symlink eq 'rename') {
-               $msg .= " and renamed it as ${pkg}_${newversion}.orig.tar.gz";
-           } else {
-               $dehs_tags{'target'} = $newfile_base;
+               print "    and renamed it as $renamed_base\n";
            }
-       }
-       elsif ($newfile_base =~ /\.(tar\.bz2|tbz2?)$/) {
-           $dehs_tags{'target'} = "${pkg}_${newversion}.orig.tar.bz2";
+       } elsif ($dehs) {
+           my $msg = "Successfully downloaded updated package $newfile_base";
+           $dehs_tags{'target'} = "$renamed_base";
            if ($symlink eq 'symlink') {
-               $msg .= " and symlinked ${pkg}_${newversion}.orig.tar.bz2 to 
it";
+               $msg .= " and symlinked $renamed_base to it";
            } elsif ($symlink eq 'rename') {
-               $msg .= " and renamed it as ${pkg}_${newversion}.orig.tar.bz2";
+               $msg .= " and renamed it as $renamed_base";
            } else {
                $dehs_tags{'target'} = $newfile_base;
            }
-       }
-       dehs_msg($msg);
-    } else {
-       print "$pkg: Successfully downloaded updated package $newfile_base\n";
-       if ($newfile_base =~ /\.(tar\.gz|tgz)$/) {
-           if ($symlink eq 'symlink') {
-               print "    and symlinked ${pkg}_${newversion}.orig.tar.gz to 
it\n";
-           } elsif ($symlink eq 'rename') {
-               print "    and renamed it as 
${pkg}_${newversion}.orig.tar.gz\n";
-           }
-       }
-       elsif ($newfile_base =~ /\.(tar\.bz2|tbz2?)$/) {
+           dehs_msg($msg);
+       } else {
+           print "$pkg: Successfully downloaded updated package 
$newfile_base\n";
            if ($symlink eq 'symlink') {
-               print "    and symlinked ${pkg}_${newversion}.orig.tar.bz2 to 
it\n";
+               print "    and symlinked $renamed_base to it\n";
            } elsif ($symlink eq 'rename') {
-               print "    and renamed it as 
${pkg}_${newversion}.orig.tar.bz2\n";
+               print "    and renamed it as $renamed_base\n";
            }
        }
+       last;
     }
 
     # Do whatever the user wishes to do
     if ($action) {
        my $usefile = "$destdir/$newfile_base";
        my @cmd = shellwords($action);
-       if ($symlink =~ /^(symlink|rename)$/
-           and $newfile_base =~ /\.(tar\.gz|tgz)$/) {
-           $usefile = "$destdir/${pkg}_${newversion}.orig.tar.gz";
-       }
-       elsif ($symlink =~ /^(symlink|rename)$/
-           and $newfile_base =~ /\.(tar\.bz2|tbz2)$/) {
-           $usefile = "$destdir/${pkg}_${newversion}.orig.tar.bz2";
+       if ($symlink =~ /^(symlink|rename)$/ && $renamed_base) {
+           $usefile = "$destdir/$renamed_base";
        }
 
        # Any symlink requests are already handled by uscan

-- 
Git repository for devscripts


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

Reply via email to