[devscripts] 01/02: Use command to find gpg binary rather than check path

James McCoy jamessan at debian.org
Mon Jan 9 04:02:49 UTC 2017


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

jamessan pushed a commit to branch master
in repository devscripts.

commit 856719a23d5731af78aec192e5563f0c62bf3b7a
Author: James McCoy <jamessan at debian.org>
Date:   Sun Jan 8 22:53:30 2017 -0500

    Use command to find gpg binary rather than check path
    
    This simplifies the use of wrapper scripts.
    
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 debian/changelog              | 4 ++++
 scripts/dscverify.pl          | 2 +-
 scripts/uscan.pl              | 4 ++--
 scripts/who-permits-upload.pl | 2 +-
 scripts/who-uploads.sh        | 8 ++++----
 test/test_package_lifecycle   | 8 ++++----
 test/test_uscan_mangle        | 8 ++++----
 7 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index dc915f9..f8762d2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,10 @@ devscripts (2.16.14) UNRELEASED; urgency=medium
   * grep-excuses:
     + Ignore new --- header line in autoremovals.yaml.cgi
 
+  [ James McCoy ]
+  * Check for existence of gpg/gpg2 in $PATH rather than absolute paths.
+    (Closes: #850655)
+
  -- Sean Whitton <spwhitton at spwhitton.name>  Mon, 19 Dec 2016 09:51:35 +0000
 
 devscripts (2.16.13) unstable; urgency=medium
diff --git a/scripts/dscverify.pl b/scripts/dscverify.pl
index dd163ff..9760085 100755
--- a/scripts/dscverify.pl
+++ b/scripts/dscverify.pl
@@ -42,7 +42,7 @@ my $start_dir = cwd;
 my $verify_sigs = 1;
 my $use_default_keyrings = 1;
 my $verbose = 0;
-my $havegpg = first { -x $_ } qw(/usr/bin/gpg2 /usr/bin/gpg);
+my $havegpg = first { !system('sh', '-c', "command -v $_ >/dev/null 2>&1")  } qw(gpg2 gpg);
 
 sub usage {
     print <<"EOF";
diff --git a/scripts/uscan.pl b/scripts/uscan.pl
index 0710a5c..0ef2919 100755
--- a/scripts/uscan.pl
+++ b/scripts/uscan.pl
@@ -1753,8 +1753,8 @@ sub uscan_verbose($);
 sub uscan_debug($);
 sub dehs_verbose ($);
 
-my $havegpgv = first { -x $_ } qw(/usr/bin/gpgv2 /usr/bin/gpgv);
-my $havegpg = first { -x $_ } qw(/usr/bin/gpg2 /usr/bin/gpg);
+my $havegpgv = first { !system('sh', '-c', "command -v $_ >/dev/null 2>&1") } qw(gpgv2 gpgv);
+my $havegpg = first { !system('sh', '-c', "command -v $_ >/dev/null 2>&1") } qw(gpg2 gpg);
 uscan_die "Please install gpgv or gpgv2.\n" unless defined $havegpgv;
 uscan_die "Please install gnupg or gnupg2.\n" unless defined $havegpg;
 
diff --git a/scripts/who-permits-upload.pl b/scripts/who-permits-upload.pl
index 999c732..9d68e60 100755
--- a/scripts/who-permits-upload.pl
+++ b/scripts/who-permits-upload.pl
@@ -31,7 +31,7 @@ use List::Util qw(first);
 our $DM_URL = "https://ftp-master.debian.org/dm.txt";
 our $KEYRING = "/usr/share/keyrings/debian-keyring.gpg:/usr/share/keyrings/debian-maintainers.gpg";
 our $TYPE = "package";
-our $GPG = first { -x $_ } qw(/usr/bin/gpg2 /usr/bin/gpg);
+our $GPG = first { !system('sh', '-c', "command -v $_ >/dev/null 2>&1") } qw(gpg2 gpg);
 our ($HELP, @ARGUMENTS, @DM_DATA, %GPG_CACHE);
 
 binmode STDIN, ':encoding(console_in)';
diff --git a/scripts/who-uploads.sh b/scripts/who-uploads.sh
index 3e7d113..ef0e35f 100755
--- a/scripts/who-uploads.sh
+++ b/scripts/who-uploads.sh
@@ -69,11 +69,11 @@ DEFAULT_WHOUPLOADS_MAXUPLOADS=3
 DEFAULT_WHOUPLOADS_DATE=no
 VARS="WHOUPLOADS_KEYRINGS WHOUPLOADS_MAXUPLOADS WHOUPLOADS_DATE"
 
-GPG=/usr/bin/gpg
-if [ ! -x $GPG ];then
+GPG=gpg
+if ! command -v $GPG >/dev/null 2>&1; then
     echo "$GPG missing"
-    GPG=/usr/bin/gpg2
-    if [ ! -x $GPG ];then
+    GPG=gpg2
+    if  ! command -v $GPG >/dev/null 2>&1; then
 	echo "$GPG missing"
 	exit 1
     fi
diff --git a/test/test_package_lifecycle b/test/test_package_lifecycle
index 149f597..310f94e 100755
--- a/test/test_package_lifecycle
+++ b/test/test_package_lifecycle
@@ -31,11 +31,11 @@ fi
 GPGHOME=$(readlink -f ${WORKDIR}/uscan/gpg)
 
 oneTimeSetUp () {
-	GPG=/usr/bin/gpg
-	if [ ! -x $GPG ];then
+	GPG=gpg
+	if ! command -v $GPG >/dev/null 2>&1;then
 		echo "$GPG missing"
-		GPG=/usr/bin/gpg2
-		if [ ! -x $GPG ];then
+		GPG=gpg2
+		if ! command -v $GPG >/dev/null 2>&1;then
 		echo "$GPG missing"
 		exit 1
 		fi
diff --git a/test/test_uscan_mangle b/test/test_uscan_mangle
index 0a6c73a..b5de3d7 100755
--- a/test/test_uscan_mangle
+++ b/test/test_uscan_mangle
@@ -42,11 +42,11 @@ DEBUGBASH=":"
 
 GPGHOME=$(readlink -f $test_dir/uscan/gpg)
 
-GPG=/usr/bin/gpg
-if [ ! -x $GPG ];then
+GPG=gpg
+if !command -v $GPG >/dev/null 2>&1; then
     echo "$GPG missing"
-    GPG=/usr/bin/gpg2
-    if [ ! -x $GPG ];then
+    GPG=gpg2
+    if ! command -v $GPG >/dev/null 2>&1; then
 	echo "$GPG missing"
 	exit 1
     fi

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