[devscripts] 03/05: mk-origtargz: Add --repack-suffix option

James McCoy jamessan at debian.org
Sun Sep 21 01:48:45 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 1201e2d2fd7c0154b855e086dc90b45e96d7d57e
Author: James McCoy <jamessan at debian.org>
Date:   Sat Sep 20 21:30:25 2014 -0400

    mk-origtargz: Add --repack-suffix option
    
    This allows automatically modifying the upstream version of the
    resulting tar archive based on whether the upstream sources are
    modified.  The common use case currently is to enable automatically
    adjusting the version when Files-Excluded rules (from debian/copyright
    or the command line) result in files being deleted.
    
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 debian/changelog        |  5 ++---
 scripts/mk-origtargz.pl | 24 +++++++++++++++++++++---
 test/test_mk-origtargz  | 45 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+), 6 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 40a1b17..8f1be07 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -19,9 +19,8 @@ devscripts (2.14.7) UNRELEASED; urgency=low
   * grep-excuses: Remove useless call to “hostname --fqdn”.  (Closes: #758668)
   * build-rdeps: Recognize arch-qualified package names.  Thanks to Stuart
     Prescott for the patch.  (Closes: #757807)
-  * uscan: Consistently pass the path to the downloaded (and possibly
-    renamed/symlinked/…) file as an argument to the watch file's action
-    command.
+  * mk-origtargz: Add a --repack-suffix option to adjust the upstream version
+    when the upstream sources are modified (e.g., due to Files-Excluded).
 
   [ Benjamin Drung ]
   * Remove unused build-dependencies libjson-perl and libterm-size-perl
diff --git a/scripts/mk-origtargz.pl b/scripts/mk-origtargz.pl
index 842f7b4..6419900 100755
--- a/scripts/mk-origtargz.pl
+++ b/scripts/mk-origtargz.pl
@@ -116,6 +116,10 @@ If the file has to be modified (because it is a B<zip> file, because of B<--repa
 If the given file is not compressed using the desired format (see
 B<--compression>), recompress it.
 
+=item B<-S>, B<--repack-suffix> I<suffix>
+
+If the file has to be modified, because of B<Files-Excluded>, append I<suffix> to the upstream version.
+
 =item B<--compression> [ B<gzip> | B<bzip2> | B<lzma> | B<xz> ]
 
 If B<--repack> is used, or if the given file is a B<zip> file, ensure that the resulting file is compressed using the given scheme. The default is B<gzip>.
@@ -178,6 +182,7 @@ my $destdir = undef;
 my $compression = "gzip";
 my $mode = undef; # can be symlink, rename or copy. Can internally be repacked if the file was repacked.
 my $repack = 0;
+my $suffix = '';
 
 my $upstream = undef;
 
@@ -205,6 +210,7 @@ GetOptions(
     "rename" => \&setmode,
     "copy" => \&setmode,
     "repack" => \$repack,
+    'repack-suffix|S=s' => \$suffix,
     "directory|C=s" => \$destdir,
     "help|h" => sub { pod2usage({-exitval => 0, -verbose => 1}); },
 ) or pod2usage({-exitval => 3, -verbose=>1});
@@ -335,8 +341,8 @@ if ($is_tarfile and not $repack) {
 # Now we know what the final filename will be
 my $destfilebase = sprintf "%s_%s.orig.tar", $package, $version;
 my $destfiletar = sprintf "%s/%s", $destdir, $destfilebase;
-my $suffix = compression_get_property($compression, "file_ext");
-my $destfile = sprintf "%s.%s", $destfiletar, $suffix;
+my $destext = compression_get_property($compression, "file_ext");
+my $destfile = sprintf "%s.%s", $destfiletar, $destext;
 
 
 # $upstream_tar is $upstream, unless the latter was a zip file.
@@ -373,7 +379,7 @@ if ($is_zipfile) {
 		   @files],
 	wait_child => 1);
     unless (-e "$destfiletar") {
-	die("Repacking from zip or jar to tar.$suffix failed (could not create tarball)\n");
+	die("Repacking from zip or jar to tar.$destext failed (could not create tarball)\n");
     }
     compress_archive($destfiletar, $destfile, $compression);
 
@@ -431,6 +437,18 @@ if (@exclude_globs) {
     $deletecount = scalar(@to_delete);
 }
 
+if ($deletecount) {
+    $destfilebase = sprintf "%s_%s%s.orig.tar", $package, $version, $suffix;
+    $destfiletar = sprintf "%s/%s", $destdir, $destfilebase;
+    $destfile = sprintf "%s.%s", $destfiletar, $destext;
+
+    # Zip -> tar process already created $destfile, so need to rename it
+    if ($is_zipfile) {
+	move $upstream_tar, $destfile;
+	$upstream_tar = $destfile;
+    }
+}
+
 # Actually do the unpack, remove, pack cycle
 if ($do_repack || $deletecount) {
     decompress_archive($upstream_tar, $destfiletar);
diff --git a/test/test_mk-origtargz b/test/test_mk-origtargz
index 7f7ae5e..1bf4083 100755
--- a/test/test_mk-origtargz
+++ b/test/test_mk-origtargz
@@ -389,6 +389,51 @@ testExcludeZip() {
 	assertEquals "file contents" "$expected_files_after_removal" "$(tar taf $TMPDIR/foo_0.1.orig.tar.xz | sort)"
 }
 
+testSuffix() {
+	makeTarBall gz
+	makeDebianDir
+	makeDebianCopyright
+	run_mk_origtargz foo "$expected_stderr_after_removal" \
+		"Successfully repacked ../foo-0.1.tar.gz as ../foo_0.1+dfsg1.orig.tar.gz, deleting 19 files from it." \
+		 ../foo-0.1.tar.gz --repack-suffix +dfsg1
+	assertTrue "result does not exist" "[ -e $TMPDIR/foo_0.1+dfsg1.orig.tar.gz ]"
+	assertType application/gzip $TMPDIR/foo_0.1+dfsg1.orig.tar.gz
+	assertEquals "file contents" "$expected_files_after_removal" "$(tar taf $TMPDIR/foo_0.1+dfsg1.orig.tar.gz | sort)"
+}
+
+testSuffixXZ() {
+	makeTarBall xz
+	makeDebianDir
+	makeDebianCopyright
+	run_mk_origtargz foo "$expected_stderr_after_removal" \
+		"Successfully repacked ../foo-0.1.tar.xz as ../foo_0.1+dfsg1.orig.tar.xz, deleting 19 files from it." \
+		 ../foo-0.1.tar.xz --repack-suffix +dfsg1
+	assertTrue "result does not exist" "[ -e $TMPDIR/foo_0.1+dfsg1.orig.tar.xz ]"
+	assertType application/xz $TMPDIR/foo_0.1+dfsg1.orig.tar.xz
+	assertEquals "file contents" "$expected_files_after_removal" "$(tar taf $TMPDIR/foo_0.1+dfsg1.orig.tar.xz | sort)"
+}
+
+testSuffixZip() {
+	makeZipFile
+	makeDebianDir
+	makeDebianCopyright
+	run_mk_origtargz foo "$expected_stderr_after_removal" \
+		"Successfully repacked ../foo-0.1.zip as ../foo_0.1+dfsg1.orig.tar.xz, deleting 19 files from it." \
+		 ../foo-0.1.zip --compression xz --repack-suffix +dfsg1
+	assertTrue "result does not exist" "[ -e $TMPDIR/foo_0.1+dfsg1.orig.tar.xz ]"
+	assertType application/xz $TMPDIR/foo_0.1+dfsg1.orig.tar.xz
+	assertEquals "file contents" "$expected_files_after_removal" "$(tar taf $TMPDIR/foo_0.1+dfsg1.orig.tar.xz | sort)"
+}
+
+testSuffixNoExclusions() {
+	makeTarBall gz
+	makeDebianDir
+	run_mk_origtargz foo "" \
+		"Successfully renamed ../foo-0.1.tar.gz to ../foo_0.1.orig.tar.gz." \
+		 ../foo-0.1.tar.gz --rename --repack-suffix +dfsg1
+	assertTrue "result does not exist" "[ -e $TMPDIR/foo_0.1.orig.tar.gz ]"
+}
+
 testSameNameSymlink() {
 	makeTarBall gz
 	mv $TMPDIR/foo-0.1.tar.gz $TMPDIR/foo_0.1.orig.tar.gz

-- 
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