Author: adam-guest
Date: 2008-02-15 22:10:33 +0000 (Fri, 15 Feb 2008)
New Revision: 1018

Modified:
   trunk/debian/changelog
   trunk/scripts/uscan.1
   trunk/scripts/uscan.pl
Log:
uscan: Add support for repacking .zip archives, based on a patch
  from Antonio Terceiro (Closes: #456587)

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2008-02-15 13:42:23 UTC (rev 1017)
+++ trunk/debian/changelog      2008-02-15 22:10:33 UTC (rev 1018)
@@ -9,6 +9,8 @@
       (Closes: #465849)
     + Fix a warning about uninitialised values when a module name is not
       supplied for a cvs repository
+  * uscan: Add support for repacking .zip archives, based on a patch
+    from Antonio Terceiro (Closes: #456587)
 
  -- Adam D. Barratt <[EMAIL PROTECTED]>  Tue, 12 Feb 2008 08:50:01 +0000
 

Modified: trunk/scripts/uscan.1
===================================================================
--- trunk/scripts/uscan.1       2008-02-15 13:42:23 UTC (rev 1017)
+++ trunk/scripts/uscan.1       2008-02-15 22:10:33 UTC (rev 1018)
@@ -361,10 +361,12 @@
 and similarly for tar.bz2 files.
 .TP
 .B \-\-repack
-After having downloaded a bzip tar 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 a bzip tar archive (i.e. it doesn't
-match a .tbz, .tbz2, or .tar.bz2 extension)
+After having downloaded a 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 a bzip tar archive or a
+zip archive (i.e. it doesn't match a .tbz, .tbz2, .tar.bz2 or .zip 
+extension). The unzip package must be installed in order to repack .zip 
+archives.
 .TP
 .B \-\-no\-symlink
 Don't make these symlinks and don't rename the files.

Modified: trunk/scripts/uscan.pl
===================================================================
--- trunk/scripts/uscan.pl      2008-02-15 13:42:23 UTC (rev 1017)
+++ trunk/scripts/uscan.pl      2008-02-15 22:10:33 UTC (rev 1018)
@@ -27,6 +27,7 @@
 use Cwd;
 use File::Basename;
 use File::Copy;
+use File::Temp qw/tempdir/;
 use filetest 'access';
 use Getopt::Long;
 use lib '/usr/share/devscripts';
@@ -89,7 +90,8 @@
     --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 to orig.tar.gz
+    --repack       Repack downloaded archives from orig.tar.bz2 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
@@ -152,7 +154,7 @@
 my $download = 1;
 my $force_download = 0;
 my $report = 0; # report even on up-to-date packages?
-my $repack = 0; # repack .tar.bz2 to .tar.gz
+my $repack = 0; # repack .tar.bz2 or .zip to .tar.gz
 my $symlink = 'symlink';
 my $verbose = 0;
 my $check_dirname_level = 1;
@@ -1148,6 +1150,20 @@
        $newfile_base = $newfile_base_gz;
     }
 
+    if ($repack and $newfile_base =~ /^(.*)\.zip$/) {
+       print "-- Repacking from zip to .tar.gz\n" if $verbose;
+
+       system('command -v unzip >/dev/null 2>&1') >> 8 == 0
+         or die("unzip binary not found. You need to install the package unzip 
to be able to repack .zip upstream archives.\n");
+
+       my $newfile_base_gz = "$1.tar.gz";
+       my $tempdir = tempdir ( "uscanXXXX", TMPDIR => 1, CLEANUP => 1 );
+       system("unzip -q -d $tempdir $destdir/$newfile_base; tar -C $tempdir 
-czf $destdir/$newfile_base_gz .") == 0 
+         or die("Repacking from zip to tar.gz failed\n");
+       unlink "$destdir/$newfile_base";
+       $newfile_base = $newfile_base_gz;
+    }
+
     if ($newfile_base =~ /\.(tar\.gz|tgz|tar\.bz2|tbz2?)$/) {
        my $filetype = `file $destdir/$newfile_base`;
        $filetype =~ s%^\.\./\Q$newfile_base\E: %%;



-- 
To unsubscribe, send mail to [EMAIL PROTECTED]

Reply via email to