mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-09 04:57:59 -05:00
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>
This commit is contained in:
parent
fade60088e
commit
036f98575c
@ -195,16 +195,19 @@ db_remove_delta()
|
|||||||
return 1
|
return 1
|
||||||
} # end db_remove_delta
|
} # 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
|
# sign the package database once repackaged
|
||||||
create_signature() {
|
create_signature() {
|
||||||
(( ! SIGN )) && return
|
(( ! SIGN )) && return
|
||||||
local dbfile="$1"
|
local dbfile="$1"
|
||||||
local ret=0
|
local ret=0
|
||||||
msg "$(gettext "Signing database...")"
|
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=""
|
local SIGNWITHKEY=""
|
||||||
if [[ -n $GPGKEY ]]; then
|
if [[ -n $GPGKEY ]]; then
|
||||||
@ -225,10 +228,7 @@ verify_signature() {
|
|||||||
local dbfile="$1"
|
local dbfile="$1"
|
||||||
local ret=0
|
local ret=0
|
||||||
msg "$(gettext "Verifying database signature...")"
|
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
|
if [[ ! -f $dbfile.sig ]]; then
|
||||||
warning "$(gettext "No existing signature found, skipping verification.")"
|
warning "$(gettext "No existing signature found, skipping verification.")"
|
||||||
return
|
return
|
||||||
@ -555,6 +555,7 @@ while [[ $# > 0 ]]; do
|
|||||||
-d|--delta) DELTA=1;;
|
-d|--delta) DELTA=1;;
|
||||||
-f|--files) WITHFILES=1;;
|
-f|--files) WITHFILES=1;;
|
||||||
-s|--sign)
|
-s|--sign)
|
||||||
|
check_gpg
|
||||||
SIGN=1
|
SIGN=1
|
||||||
if ! gpg --list-key ${GPGKEY} &>/dev/null; then
|
if ! gpg --list-key ${GPGKEY} &>/dev/null; then
|
||||||
if [[ ! -z $GPGKEY ]]; then
|
if [[ ! -z $GPGKEY ]]; then
|
||||||
@ -566,6 +567,7 @@ while [[ $# > 0 ]]; do
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
-k|--key)
|
-k|--key)
|
||||||
|
check_gpg
|
||||||
shift
|
shift
|
||||||
GPGKEY="$1"
|
GPGKEY="$1"
|
||||||
if ! gpg --list-key ${GPGKEY} &>/dev/null; then
|
if ! gpg --list-key ${GPGKEY} &>/dev/null; then
|
||||||
@ -573,7 +575,10 @@ while [[ $# > 0 ]]; do
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
-v|--verify) VERIFY=1;;
|
-v|--verify)
|
||||||
|
check_gpg
|
||||||
|
VERIFY=1
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
if [[ -z $REPO_DB_FILE ]]; then
|
if [[ -z $REPO_DB_FILE ]]; then
|
||||||
REPO_DB_FILE="$1"
|
REPO_DB_FILE="$1"
|
||||||
|
Loading…
Reference in New Issue
Block a user