1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 15:58:50 -05:00

pacman-key: follow gpg options for listing keys

The current --list option outputed the keys and all their signatures
which can be overly verbose.  It also did not take a list of keys on
the command line to limit its output (although the code suggests that
was intended).

That patch brings consistency with gpg, providing --list-keys and
--list-sigs options that function equivalently to those provided by
gpg.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Allan McRae 2011-07-30 12:24:46 +10:00 committed by Dan McGee
parent cbaff216b3
commit c55cbfbd5f
2 changed files with 18 additions and 10 deletions

View File

@ -71,8 +71,11 @@ Options
Ensure the keyring is properly initialized and has the required access
permissions.
*-l, \--list*::
Equivalent to --list-sigs from GnuPG.
*-l, \--list-keys* [keyid(s)]::
Lists all or specified keys from the public keyring.
*--list-sigs* [keyid(s)]::
Same as --list-keys, but the signatures are listed too.
*-r, \--receive* <keyserver> <keyid(s)>::
Fetch the specified keyids from the specified key server URL.

View File

@ -35,7 +35,8 @@ FINGER=0
IMPORT=0
IMPORT_TRUSTDB=0
INIT=0
LIST=0
LISTKEYS=0
LISTSIGS=0
RECEIVE=0
RELOAD=0
UPDATEDB=0
@ -58,7 +59,7 @@ usage() {
echo "$(gettext " -e, --export [<keyid(s)>] Export the specified or all keyids")"
echo "$(gettext " -f, --finger [<keyid(s)>] List fingerprint for specified or all keyids")"
echo "$(gettext " -h, --help Show this help message and exit")"
echo "$(gettext " -l, --list List keys")"
echo "$(gettext " -l, --list-keys [<keyid(s)>] List the specified or all keys")"
echo "$(gettext " -r, --receive <keyserver> <keyid(s)> Fetch the specified keyids")"
echo "$(gettext " -u, --updatedb Update the trustdb of pacman")"
echo "$(gettext " -v, --verify <signature> Verify the file specified by the signature")"
@ -71,6 +72,7 @@ usage() {
echo "$(gettext " --import <dir(s)> Imports pubring.gpg and trustdb.gpg from dir(s)")"
echo "$(gettext " --import-trustdb <dir(s)> Imports ownertrust values from trustdb.gpg in dir(s)")"
echo "$(gettext " --init Ensure the keyring is properly initialized")"
echo "$(gettext " --list-sigs [<keyid(s)>] List keys and their signatures")"
echo "$(gettext " --reload Reload the default keys")"
}
@ -317,10 +319,10 @@ if ! type gettext &>/dev/null; then
}
fi
OPT_SHORT="a::d:e:f::hlr:uv:V"
OPT_SHORT="a::d:e:f::hl::r:uv:V"
OPT_LONG="add::,config:,delete:,edit-key:,export::,finger::,gpgdir:"
OPT_LONG+=",help,import:,import-trustdb:,init,list,receive:,reload,updatedb"
OPT_LONG+=",verify:,version"
OPT_LONG+=",help,import:,import-trustdb:,init,list-keys::,list-sigs::,,receive:"
OPT_LONG+=",reload,updatedb,verify:,version"
if ! OPT_TEMP="$(parse_options $OPT_SHORT $OPT_LONG "$@")"; then
echo; usage; exit 1 # E_INVALID_OPTION;
fi
@ -344,7 +346,8 @@ while true; do
--import) IMPORT=1; shift; IMPORT_DIRS=($1) ;;
--import-trustdb) IMPORT_TRUSTDB=1; shift; IMPORT_DIRS=($1) ;;
--init) INIT=1 ;;
-l|--list) LIST=1 ;;
-l|--list-keys) LISTKEYS=1; [[ -n $2 && ${2:0:1} != "-" ]] && shift && KEYIDS=($1) ;;
--list-sigs) LISTSIGS=1; [[ -n $2 && ${2:0:1} != "-" ]] && shift && KEYIDS=($1) ;;
-r|--receive) RECEIVE=1; shift; TMP=($1); KEYSERVER=${TMP[0]}; KEYIDS=(${TMP[@]:1}); unset TMP;;
--reload) RELOAD=1 ;;
-u|--updatedb) UPDATEDB=1 ;;
@ -383,7 +386,8 @@ PACMAN_KEYRING_DIR=${PACMAN_KEYRING_DIR:-$(get_from "$CONFIG" "GPGDir" || echo "
GPG_PACMAN=(gpg --homedir ${PACMAN_KEYRING_DIR} --no-permission-warning)
# check only a single operation has been given
numopt=$(( ADD + DELETE + EDITKEY + EXPORT + FINGER + IMPORT + IMPORT_TRUSTDB + INIT + LIST + RECEIVE + RELOAD + UPDATEDB + VERIFY ))
numopt=$(( ADD + DELETE + EDITKEY + EXPORT + FINGER + IMPORT + IMPORT_TRUSTDB +
INIT + LISTKEYS + LISTSIGS + RECEIVE + RELOAD + UPDATEDB + VERIFY ))
case $numopt in
0)
@ -407,7 +411,8 @@ esac
(( IMPORT )) && import
(( IMPORT_TRUSTDB)) && import_trustdb
(( INIT )) && initialize
(( LIST )) && "${GPG_PACMAN[@]}" --batch --list-sigs "${KEYIDS[@]}"
(( LISTKEYS )) && "${GPG_PACMAN[@]}" --batch --list-keys "${KEYIDS[@]}"
(( LISTSIGS )) && "${GPG_PACMAN[@]}" --batch --list-sigs "${KEYIDS[@]}"
(( RECEIVE )) && receive_keys
(( RELOAD )) && reload_keyring
(( UPDATEDB )) && "${GPG_PACMAN[@]}" --batch --check-trustdb