From 09d9b415cca219bb32f17d1addf545de82d6cd07 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Sun, 29 May 2011 18:05:12 -0400 Subject: [PATCH] Add GPG data to output to patch data in commit. As a positive (semi) side effect, checking of "Good signature" output of GPG is added. --- bash-patch-apply.plx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bash-patch-apply.plx b/bash-patch-apply.plx index 1ca3dba..cde2ff9 100755 --- a/bash-patch-apply.plx +++ b/bash-patch-apply.plx @@ -28,8 +28,13 @@ foreach my $patchFile (@ARGV) { print STDERR "${patchFile}.sig is not readable\n"; exit 1; } - system("/usr/bin/gpg ${patchFile}.sig"); - if ($? != 0) { + my $gpgData = ""; + open(GPG, "-|", "/usr/bin/gpg ${patchFile}.sig 2>&1") or die "unable to run GPG on ${patchFile}.sig: $!"; + while (my $line = ) { + $gpgData .= $line; + last if ($line =~ /(^|\s+)Good\s+signature/i); + } + if ($? != 0 or $gpgData !~ /Good\s+signature/i) { print STDERR "GPG signature check problem on $patchFile\n"; exit 1; } @@ -74,6 +79,8 @@ foreach my $patchFile (@ARGV) { $ENV{GIT_AUTHOR_EMAIL} = 'chet@cwru.edu'; open(COMMIT, "|-", "git commit -a -F -") or die "unable to run git: $!"; print COMMIT $log; + print "\nThis patch, in file $patchFile, was downloaded from ftp.gnu.org on 2011-05-29,\nand ${patchFile}.sig was furthermore verified, yielding the following output:\n"; + print $gpgData; close COMMIT; if ($? != 0) { print STDERR "$patchFile commit failed!\n";