From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 5255F158128 for ; Tue, 17 Jun 2025 03:00:54 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 06C233425A2 for ; Tue, 17 Jun 2025 03:00:54 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id ED3A31104DC; Tue, 17 Jun 2025 03:00:50 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id E16EE1104D9 for ; Tue, 17 Jun 2025 03:00:50 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 94EAF342680 for ; Tue, 17 Jun 2025 03:00:50 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id D4EB829D2 for ; Tue, 17 Jun 2025 03:00:48 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1750129237.34fc3d4b55f2425054d6737ff5c7b2b5a5e61b1b.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/emerge-webrsync X-VCS-Directories: bin/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 34fc3d4b55f2425054d6737ff5c7b2b5a5e61b1b X-VCS-Branch: master Date: Tue, 17 Jun 2025 03:00:48 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: bce5705c-0d73-4b7c-a956-571ac0d1897d X-Archives-Hash: 81db257f7d0130c3feb3b914e70ce02b commit: 34fc3d4b55f2425054d6737ff5c7b2b5a5e61b1b Author: Kerin Millar plushkava net> AuthorDate: Mon Jun 16 02:21:31 2025 +0000 Commit: Sam James gentoo 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 plushkava.net> Signed-off-by: Sam James 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() {