commit:     9d92b90754e89b7afd0b506e2463cc3c9e5010a3
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Wed Jun 18 00:00:58 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jun 18 01:15:04 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=9d92b907

emerge-webrsync: refrain from invoking die() with no arguments

Should a command yield an exit status value other than zero, there in no
sense in calling die() unless there is something in particular to be
said. Consider the following example, in which chown(1) has failed.

chown: changing ownership of '/var/db/repos/gentoo': Operation not permitted
emerge-webrsync:

The additional (empty) diagnostic message confers no value whatsoever.

Presently, there are three instances in which this can occur, all of
which concern the main() function. Address the first two by instead
calling the exit builtin, and the third by passing an argument to die().
I took the liberty of reducing eight rambling lines (in quintessential
Gentoo fashion) to just two, as depicted below.

 * Invalid sync-type attribute for 'gentoo' repo: 'wrongsync' (expected 'rsync' 
or 'webrsync')
emerge-webrsync: repos.conf validation failed

Also, the value of the 'repo_name' variable is now properly incorporated
into the diagnostic. Hitherto, it had been hard-coded as "gentoo".

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

 bin/emerge-webrsync | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
index f0637c2258..d7ad148c20 100755
--- a/bin/emerge-webrsync
+++ b/bin/emerge-webrsync
@@ -47,10 +47,10 @@ main() {
        handle_pgp_setup
 
        if [[ ! -d ${repo_location} ]]; then
-               mkdir -p "${repo_location}" || die
+               mkdir -p "${repo_location}" || exit
 
                if contains_word usersync "${FEATURES}"; then
-                       chown "${PORTAGE_USERNAME}":"${PORTAGE_GRPNAME}" 
"${repo_location}" || die
+                       chown "${PORTAGE_USERNAME}":"${PORTAGE_GRPNAME}" 
"${repo_location}" || exit
                fi
        fi
 
@@ -77,14 +77,8 @@ main() {
        # This is a sanity check to help prevent people like funtoo users
        # from accidentally wiping out their git tree.
        if [[ ${repo_sync_type} != @(''|rsync|webrsync) ]]; then
-               eerror "The current sync-type attribute of repository 'gentoo' 
is not set to 'rsync' or 'webrsync':"
-               eerror
-               eerror "  sync-type=${repo_sync_type}"
-               eerror
-               eerror "If you intend to use emerge-webrsync then please"
-               eerror "adjust sync-type and sync-uri attributes to refer to 
rsync."
-               eerror "emerge-webrsync exiting due to abnormal sync-type 
setting."
-               die
+               eerror "Invalid sync-type attribute for ${repo_name@Q} repo: 
${repo_sync_type@Q} (expected 'rsync' or 'webrsync')"
+               die "repos.conf validation failed"
        fi
 
        (( opt[debug] )) && set -x

Reply via email to