commit:     27bd0ed056b3b2ea2b64ead0a128ed0196062ee5
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Thu Jun 19 02:09:02 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jun 19 18:13:10 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=27bd0ed0

emerge-webrsync: have both signature checking routines employ common diagnostics

Recently, the diagnostics shown by the check_file_signature_gpg()
function in the event of a missing key were improved. Said commit did
not adjust the diagnostics shown by the check_file_signature_gemato()
function. That is, the former shows the new diagnostics whereas the
latter continues to show the old diagnostics.

Thus, one realises that there is an opportunity to unify them in this
regard. Do so by introducing the assign_key() function and delegating to
it the responsibility of testing for - and reacting to - a missing key.

See-also: bf07fbe382a4a04c65dd76f286bcc061ba11728b
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/emerge-webrsync | 44 +++++++++++++++++++-------------------------
 1 file changed, 19 insertions(+), 25 deletions(-)

diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
index a705a59eef..005548cf90 100755
--- a/bin/emerge-webrsync
+++ b/bin/emerge-webrsync
@@ -260,16 +260,7 @@ check_file_signature_gemato() {
        local -a gemato_args
        local key
 
-       if [[ -n ${PORTAGE_GPG_KEY} ]] ; then
-               key="${PORTAGE_GPG_KEY}"
-       else
-               key="${EPREFIX}/usr/share/openpgp-keys/gentoo-release.asc"
-       fi
-
-       if [[ ! -f "${key}" ]] ; then
-               eerror "${key} not available. Is 
sec-keys/openpgp-keys-gentoo-release installed?"
-               die "Needed keys unavailable! Install its package or set 
PORTAGE_GPG_KEY to the right path."
-       fi
+       assign_key
 
        gemato_args=(
                openpgp-verify-detached
@@ -293,21 +284,7 @@ check_file_signature_gpg() {
        local signature=$1 file=$2
        local fingerprint key
 
-       if [[ -n ${PORTAGE_GPG_KEY} ]] ; then
-               key="${PORTAGE_GPG_KEY}"
-       else
-               key="${EPREFIX}/usr/share/openpgp-keys/gentoo-release.asc"
-       fi
-
-       if [[ ! -f "${key}" ]]; then
-               if [[ ${PORTAGE_GPG_KEY} ]]; then
-                       eerror "PORTAGE_GPG_KEY does not appear to have been 
set correctly"
-               else
-                       eerror "sec-keys/openpgp-keys-gentoo-release does not 
appear to be installed"
-               fi
-               die "${key@Q} does not exist (or is not a file)"
-       fi
-
+       assign_key
        export GNUPGHOME
 
        if [[ ! ${GNUPGHOME=${PORTAGE_GPG_DIR}} ]]; then
@@ -331,6 +308,23 @@ check_file_signature_gpg() {
        gpg_verify "${signature}" "${file}"
 }
 
+assign_key() {
+       if [[ ${PORTAGE_GPG_KEY} ]]; then
+               key=${PORTAGE_GPG_KEY}
+       else
+               key=${EPREFIX}/usr/share/openpgp-keys/gentoo-release.asc
+       fi
+
+       if [[ ! -f ${key} ]]; then
+               if [[ ${PORTAGE_GPG_KEY} ]]; then
+                       eerror "PORTAGE_GPG_KEY does not appear to have been 
set correctly"
+               else
+                       eerror "sec-keys/openpgp-keys-gentoo-release does not 
appear to be installed"
+               fi
+               die "${key@Q} does not exist (or is not a file)"
+       fi
+}
+
 gpg_fingerprint() {
        local -a fields
 

Reply via email to