summaryrefslogtreecommitdiff
path: root/scripts/pacman-key.sh.in
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-09-21 16:35:07 -0500
committerDan McGee <dan@archlinux.org>2011-09-22 11:15:45 -0500
commit067721cbff9652d5c436d277f9be3f8fa2a71796 (patch)
treec3b46b791abad4e270ef2d84770cd042aeace12b /scripts/pacman-key.sh.in
parent33685b960d3f05841cfac5696a0946396c448a34 (diff)
downloadpacman-067721cbff9652d5c436d277f9be3f8fa2a71796.tar.xz
pacman-key: factor out validate_with_gpg() method
This was copy-pasted code for the most part once the filename was factored out. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'scripts/pacman-key.sh.in')
-rw-r--r--scripts/pacman-key.sh.in30
1 files changed, 14 insertions, 16 deletions
diff --git a/scripts/pacman-key.sh.in b/scripts/pacman-key.sh.in
index 72725154..cb76a403 100644
--- a/scripts/pacman-key.sh.in
+++ b/scripts/pacman-key.sh.in
@@ -196,6 +196,18 @@ check_keyring() {
fi
}
+validate_with_gpg() {
+ msg2 "$(gettext "Verifying %s...")" "$1"
+ if [[ ! -f "$1.sig" ]]; then
+ error "$(gettext "File %s is unsigned, cannot continue.")" "$1"
+ return 1
+ elif ! "${GPG_PACMAN[@]}" --verify "$1.sig"; then
+ error "$(gettext "The signature of file %s is not valid.")" "$1"
+ return 1
+ fi
+ return 0
+}
+
verify_keyring_input() {
local ret=0;
local KEYRING_IMPORT_DIR='@pkgdatadir@/keyrings'
@@ -205,25 +217,11 @@ verify_keyring_input() {
local keyring keyfile
for keyring in "${KEYRINGIDS[@]}"; do
keyfile="${KEYRING_IMPORT_DIR}/${keyring}.gpg"
- msg2 "$(gettext "Verifying %s...")" "${keyfile}"
- if [[ ! -f "${keyfile}.sig" ]]; then
- error "$(gettext "File %s is unsigned, cannot continue.")" "${keyfile}"
- ret=1
- elif ! "${GPG_PACMAN[@]}" --verify "${keyfile}.sig"; then
- error "$(gettext "The signature of file %s is not valid.")" "${keyfile}"
- ret=1
- fi
+ validate_with_gpg "${keyfile}" || ret=1
keyfile="${KEYRING_IMPORT_DIR}/${keyring}-revoked"
if [[ -f "${keyfile}" ]]; then
- msg2 "$(gettext "Verifying %s...")" "${keyfile}"
- if [[ ! -f "${keyfile}.sig" ]]; then
- error "$(gettext "File %s is unsigned, cannot continue.")" "${keyfile}"
- ret=1
- elif ! "${GPG_PACMAN[@]}" --verify "${keyfile}.sig"; then
- error "$(gettext "The signature of file %s is not valid.")" "${keyfile}"
- ret=1
- fi
+ validate_with_gpg "${keyfile}" || ret=1
fi
done