summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2011-04-24 20:56:59 +1000
committerDan McGee <dan@archlinux.org>2011-04-24 10:43:43 -0500
commit036f98575c1b57782db51c82b521d53ba1da99a1 (patch)
treee2b02031018ad173ff880bf30fdec517483359f2
parentfade60088e158c042e3a3a2c135fa067016998af (diff)
downloadpacman-036f98575c1b57782db51c82b521d53ba1da99a1.tar.xz
repo-add: check for gpg early
Check for the presence of gpg as soon as we know we need it. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--scripts/repo-add.sh.in23
1 files changed, 14 insertions, 9 deletions
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 00d3a416..80caf93b 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -195,16 +195,19 @@ db_remove_delta()
return 1
} # end db_remove_delta
+check_gpg() {
+ if ! type -p gpg >/dev/null; then
+ error "$(gettext "Cannot find the gpg binary! Is gnupg installed?")"
+ exit 1 # $E_MISSING_PROGRAM
+ fi
+}
+
# sign the package database once repackaged
create_signature() {
(( ! SIGN )) && return
local dbfile="$1"
local ret=0
msg "$(gettext "Signing database...")"
- if ! type -p gpg; then
- error "$(gettext "Cannot find the gpg binary! Is gnupg installed?")"
- exit 1 # $E_MISSING_PROGRAM
- fi
local SIGNWITHKEY=""
if [[ -n $GPGKEY ]]; then
@@ -225,10 +228,7 @@ verify_signature() {
local dbfile="$1"
local ret=0
msg "$(gettext "Verifying database signature...")"
- if ! type -p gpg; then
- error "$(gettext "Cannot find the gpg binary! Is gnupg installed?")"
- exit 1 # $E_MISSING_PROGRAM
- fi
+
if [[ ! -f $dbfile.sig ]]; then
warning "$(gettext "No existing signature found, skipping verification.")"
return
@@ -555,6 +555,7 @@ while [[ $# > 0 ]]; do
-d|--delta) DELTA=1;;
-f|--files) WITHFILES=1;;
-s|--sign)
+ check_gpg
SIGN=1
if ! gpg --list-key ${GPGKEY} &>/dev/null; then
if [[ ! -z $GPGKEY ]]; then
@@ -566,6 +567,7 @@ while [[ $# > 0 ]]; do
fi
;;
-k|--key)
+ check_gpg
shift
GPGKEY="$1"
if ! gpg --list-key ${GPGKEY} &>/dev/null; then
@@ -573,7 +575,10 @@ while [[ $# > 0 ]]; do
exit 1
fi
;;
- -v|--verify) VERIFY=1;;
+ -v|--verify)
+ check_gpg
+ VERIFY=1
+ ;;
*)
if [[ -z $REPO_DB_FILE ]]; then
REPO_DB_FILE="$1"