[devscripts] 03/05: mk-origtargz: Use file's mime detection to detect zip files

James McCoy jamessan at debian.org
Wed May 28 04:20:05 UTC 2014


This is an automated email from the git hooks/post-receive script.

jamessan pushed a commit to branch master
in repository devscripts.

commit fea069683b6b6ccd81b7cb5274e3eae1f54cf97f
Author: James McCoy <jamessan at debian.org>
Date:   Tue May 27 23:07:13 2014 -0400

    mk-origtargz: Use file's mime detection to detect zip files
    
    Closes: #748462
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 debian/changelog        |  4 +++-
 scripts/mk-origtargz.pl | 20 +++++++++++---------
 test/test_mk-origtargz  | 11 +++++++++++
 3 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 40d6d6d..7fadd35 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -17,7 +17,9 @@ devscripts (2.14.3) UNRELEASED; urgency=medium
       (Closes: #747901)
     + Add target-path node to dehs output for those who care about the actual
       path to the file.
-    + Restore display of final file name after file is donwloaded.
+    + Restore display of final file name after file is downloaded.
+  * mk-origtargz: Use file's mime detection to detect zip files.  (Closes:
+    #748462)
 
   [ Christoph Berg ]
   * uscan: Fix "upsteam" typo.  (Closes: #749343)
diff --git a/scripts/mk-origtargz.pl b/scripts/mk-origtargz.pl
index 5ab43c6..fb24df5 100755
--- a/scripts/mk-origtargz.pl
+++ b/scripts/mk-origtargz.pl
@@ -298,20 +298,23 @@ for my $copyright_file (@copyright_files) {
 
 # Gather information about the upstream file.
 
-my $zip_regex = qr/\.(zip|jar)$/;
 # This makes more sense in Dpkg:Compression
-my $tar_regex = qr/\.(tar\.gz  |tgz
-		     |tar\.bz2 |tbz2?
-		     |tar.lzma |tlz(?:ma?)?
-		     |tar.xz   |txz)$/x;
-
-my $is_zipfile = $upstream =~ $zip_regex;
-my $is_tarfile = $upstream =~ $tar_regex;
+my $tar_regex = qr/\.(tar\.gz   |tgz
+		     |tar\.bz2  |tbz2?
+		     |tar\.lzma |tlz(?:ma?)?
+		     |tar\.xz   |txz
+		     |tar\.Z
+		     )$/x;
 
 unless (-e $upstream) {
     die "Could not read $upstream: $!"
 }
 
+my $mime = compression_guess_from_file($upstream);
+
+my $is_zipfile = $mime eq 'zip';
+my $is_tarfile = $upstream =~ $tar_regex;
+
 unless ($is_zipfile or $is_tarfile) {
     # TODO: Should we ignore the name and only look at what file knows?
     die "Parameter $upstream does not look like a tar archive or a zip file."
@@ -395,7 +398,6 @@ if ($repack) {
 	die("Cannot determine compression method of $upstream_tar");
     }
     $do_repack = $comp ne $compression;
-
 }
 
 # Removing files
diff --git a/test/test_mk-origtargz b/test/test_mk-origtargz
index 9809e19..0697d2b 100755
--- a/test/test_mk-origtargz
+++ b/test/test_mk-origtargz
@@ -314,6 +314,17 @@ testRepackZip2XZ() {
 	assertType application/xz $TMPDIR/foo_0.1.orig.tar.xz
 }
 
+testRepackXpi2XZ() {
+	makeZipFile
+	mv $TMPDIR/foo-0.1.zip $TMPDIR/foo-0.1.xpi
+	run_mk_origtargz "" "" \
+		"Successfully repacked foo-0.1.xpi as foo_0.1.orig.tar.xz." \
+		--package foo --version 0.1 foo-0.1.xpi --compression xz
+	assertTrue "original xpi file does not exist" "[ -e $TMPDIR/foo-0.1.xpi ]"
+	assertTrue "result does not exist" "[ -e $TMPDIR/foo_0.1.orig.tar.xz ]"
+	assertType application/xz $TMPDIR/foo_0.1.orig.tar.xz
+}
+
 testExclude() {
 	makeTarBall gz
 	makeDebanDir

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list