[devscripts] 02/04: mk-origtargz: refactor to support symlink

Osamu Aoki osamu at moszumanska.debian.org
Sun Aug 27 10:33:57 UTC 2017


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

osamu pushed a commit to branch master
in repository devscripts.

commit cd1d5e8429aaa335731a524b089c8d2107ad8c0d
Author: Osamu Aoki <osamu at debian.org>
Date:   Sun Aug 27 17:31:04 2017 +0900

    mk-origtargz: refactor to support symlink
---
 scripts/mk-origtargz.pl | 73 ++++++++++++++++++++++++++++---------------------
 1 file changed, 42 insertions(+), 31 deletions(-)

diff --git a/scripts/mk-origtargz.pl b/scripts/mk-origtargz.pl
index 6bd0be5..e35b142 100644
--- a/scripts/mk-origtargz.pl
+++ b/scripts/mk-origtargz.pl
@@ -413,42 +413,12 @@ if ($is_tarfile and not $repack) {
     }
 }
 
-# Gather information about the signature file.
-
-my $is_ascfile = $signature_file =~ /\.asc$/i;
-my $is_gpgfile = $signature_file =~ /\.(gpg|pgp|sig|sign)$/i;
-
 # Now we know what the final filename will be
 my $destfilebase = sprintf "%s_%s.%s.tar", $package, $version, $orig;
 my $destfiletar = sprintf "%s/%s", $destdir, $destfilebase;
 my $destext = compression_get_property($compression, "file_ext");
 my $destfile = sprintf "%s.%s", $destfiletar, $destext;
 
-my $destsigfile;
-if ($signature == 1) {
-    $destsigfile = sprintf "%s.asc", $destfile;
-} elsif ($signature == 2) {
-    $destsigfile = sprintf "%s.asc", $destfiletar;
-} else {
-    # XXX FIXME XXX place holder
-    $destsigfile = sprintf "%s.asc", $destfile;
-}
-
-if ($signature != 0) {
-    if ($is_gpgfile) {
-	my $enarmor = `gpg --output - --enarmor $signature_file 2>&1`;
-	$? == 0 or die "mk-origtargz: Failed to convert $signature_file to *.asc\n";
-	$enarmor =~ s/ARMORED FILE/SIGNATURE/;
-	$enarmor =~ /^Comment:/d;
-	open(DESTSIG, ">> $destsigfile") or die "mk-origtargz: Failed to open $destsigfile for append: $!\n";
-	print DESTSIG $enarmor;
-    } else {
-	if (abs_path($signature_file) ne abs_path($destsigfile)) {
-	    copy $signature_file, $destsigfile;
-	}
-    }
-}
-
 # $upstream_tar is $upstream, unless the latter was a zip file.
 my $upstream_tar = $upstream;
 
@@ -602,7 +572,7 @@ if ($do_repack || $deletecount) {
     $upstream_tar = $destfile;
 }
 
-# Final step: symlink, copy or rename.
+# Final step: symlink, copy or rename for tarball.
 
 my $same_name = abs_path($destfile) eq abs_path($upstream);
 unless ($same_name) {
@@ -618,6 +588,47 @@ unless ($same_name) {
     }
 }
 
+# Final step: symlink, copy or rename for signature file.
+
+my $is_ascfile = $signature_file =~ /\.asc$/i;
+my $is_gpgfile = $signature_file =~ /\.(gpg|pgp|sig|sign)$/i;
+
+my $destsigfile;
+if ($signature == 1) {
+    $destsigfile = sprintf "%s.asc", $destfile;
+} elsif ($signature == 2) {
+    $destsigfile = sprintf "%s.asc", $destfiletar;
+} else {
+    # XXX FIXME XXX place holder
+    $destsigfile = sprintf "%s.asc", $destfile;
+}
+
+if ($signature != 0) {
+    if ($mode eq "repack") {
+	print "Skip adding upstream signature since tarball is repacked.\n";
+    } elsif ($is_gpgfile) {
+	my $enarmor = `gpg --output - --enarmor $signature_file 2>&1`;
+	$? == 0 or die "mk-origtargz: Failed to convert $signature_file to *.asc\n";
+	$enarmor =~ s/ARMORED FILE/SIGNATURE/;
+	$enarmor =~ /^Comment:/d;
+	open(DESTSIG, ">> $destsigfile") or die "mk-origtargz: Failed to open $destsigfile for append: $!\n";
+	print DESTSIG $enarmor;
+    } else {
+	if (abs_path($signature_file) ne abs_path($destsigfile)) {
+	    if ($mode eq "symlink") {
+		my $rel = File::Spec->abs2rel($signature_file, $destdir);
+		symlink $rel, $destsigfile;
+	    } elsif ($mode eq "copy") {
+		copy $signature_file, $destsigfile;
+	    } elsif ($mode eq "rename") {
+		move $signature_file, $destsigfile;
+	    } else {
+		die "Strange mode=\"$mode\"\n";
+	    }
+	}
+    }
+}
+
 # Final check: Is the tarball usable
 
 # We are lazy and rely on Dpkg::IPC to report an error message (spawn does not report back the error code).

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