commit: 34fc3d4b55f2425054d6737ff5c7b2b5a5e61b1b
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Mon Jun 16 02:21:31 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jun 17 03:00:37 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=34fc3d4b
emerge-webrsync: drop the r variable from four functions
Presently, four functions declare a variable named 'r', whose purpose is
to store the ultimate return value of the function. These functions are
listed beneath.
- check_file_digest()
- check_file_signature_gemato()
- check_file_signature_gpg_unwrapped()
- do_latest_snapshot()
Render the 'r' variable unnecessary through some minor refactoring of
these functions.
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, 15 insertions(+), 29 deletions(-)
diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
index eddfc9957a..fba23610d8 100755
--- a/bin/emerge-webrsync
+++ b/bin/emerge-webrsync
@@ -224,27 +224,25 @@ fetch_file() {
check_file_digest() {
local digest=$1 file=$2
- local digest_content md5sum_output r=1
+ local digest_content md5sum_output
[[ ${PORTAGE_QUIET} -eq 1 ]] || einfo "Checking digest ..."
if type -P md5sum > /dev/null; then
md5sum_output=$(md5sum "${file}")
digest_content=$(< "${digest}")
- [[ "${md5sum_output%%[[:space:]]*}" =
"${digest_content%%[[:space:]]*}" ]] && r=0
+ [[ "${md5sum_output%%[[:space:]]*}" =
"${digest_content%%[[:space:]]*}" ]]
elif type -P md5 > /dev/null; then
- [[ "$(md5 -q "${file}")" == "$(cut -d ' ' -f 1 "${digest}")" ]]
&& r=0
+ [[ "$(md5 -q "${file}")" == "$(cut -d ' ' -f 1 "${digest}")" ]]
else
die "cannot check digest: no suitable md5/md5sum binaries found"
fi
-
- return "${r}"
}
check_file_signature_gemato() {
local signature=$1 file=$2
local -a gemato_args
- local key r=1
+ local key
if type -P gemato > /dev/null; then
if [[ -n ${PORTAGE_GPG_KEY} ]] ; then
@@ -273,20 +271,15 @@ check_file_signature_gemato() {
[[ ${PORTAGE_QUIET} == 1 ]] && gemato_args+=( --quiet )
[[ ${do_debug} == 1 ]] && gemato_args+=( --debug )
- gemato "${gemato_args[@]}" -- "${signature}" "${file}"
- r=$?
-
- if [[ ${r} -ne 0 ]]; then
- # Exit early since it's typically inappropriate to
- # try other mirrors in this case (it may indicate
- # a keyring problem).
+ if ! gemato "${gemato_args[@]}" -- "${signature}" "${file}";
then
+ # Exit early since it's typically inappropriate to try
+ # other mirrors in this case (it may indicate a keyring
+ # problem).
die "signature verification failed"
fi
else
return 127
fi
-
- return "${r}"
}
check_file_signature_gpg_unwrapped() {
@@ -450,7 +443,7 @@ sync_local() {
do_snapshot() {
local ignore_timestamp=$1 date=$2
- local snapshot_timestamp compression{,s} utc_seconds have_files
signature digest mirror file name r=1
+ local snapshot_timestamp compression{,s} utc_seconds have_files
signature digest mirror file name
type -P xzcat > /dev/null && compressions="${compressions}
${repo_name}:xz portage:xz"
type -P bzcat > /dev/null && compressions="${compressions}
${repo_name}:bz2 portage:bz2"
@@ -519,24 +512,23 @@ do_snapshot() {
break 2
else
# Remove files and use a different mirror
- rm -f "${DISTDIR}/${file}"
"${DISTDIR}/${digest}" "${DISTDIR}/${signature}"
+ rm -f
"${DISTDIR}"/{"$file","$digest","$signature"}
fi
done
done
if (( have_files )); then
- sync_local "${DISTDIR}/${file}" && r=0
+ sync_local "${DISTDIR}/${file}" \
+ && { ${keep} || rm -f
"${DISTDIR}"/{"$file","$digest","$signature"}; }
else
ewarn "${date} snapshot was not found"
+ false
fi
-
- ${keep} || rm -f "${DISTDIR}/${file}" "${DISTDIR}/${digest}"
"${DISTDIR}/${signature}"
- return "${r}"
}
do_latest_snapshot() {
local timestamp_{difference,problem} snapshot_date{,_seconds}
approx_snapshot_time existing_timestamp start_{hour,time}
- local min_time_diff attempts=0 r=1
+ local min_time_diff attempts=0
[[ ${PORTAGE_QUIET} -eq 1 ]] || einfo "Fetching most recent snapshot
..."
@@ -598,17 +590,11 @@ do_latest_snapshot() {
while read -r line ; do
ewarn "${line}"
done
- r=0
break
fi
- if do_snapshot 0 "${snapshot_date}"; then
- r=0
- break;
- fi
+ do_snapshot 0 "${snapshot_date}" && break
done
-
- return "${r}"
}
usage() {