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 8537F1580E0 for ; Sun, 01 Jun 2025 21:47:55 +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 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 721043430E3 for ; Sun, 01 Jun 2025 21:47:55 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 1F9C9110480; Sun, 01 Jun 2025 21:47:45 +0000 (UTC) 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 bobolink.gentoo.org (Postfix) with ESMTPS id 1705311047E for ; Sun, 01 Jun 2025 21:47:45 +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)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C23EF34308C for ; Sun, 01 Jun 2025 21:47:44 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 614A12529 for ; Sun, 01 Jun 2025 21:47:42 +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: <1748814121.d11490f9d83baefc1dad02d9be63c74e4c1da04f.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/phase-helpers.sh X-VCS-Directories: bin/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: d11490f9d83baefc1dad02d9be63c74e4c1da04f X-VCS-Branch: master Date: Sun, 01 Jun 2025 21:47:42 +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: fd51a6e3-bb0a-4082-8391-2d4dfa80b00d X-Archives-Hash: 3f9540849fcd58d3615f2b9b2c54f8bd commit: d11490f9d83baefc1dad02d9be63c74e4c1da04f Author: Kerin Millar plushkava net> AuthorDate: Fri May 30 11:16:51 2025 +0000 Commit: Sam James gentoo org> CommitDate: Sun Jun 1 21:42:01 2025 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=d11490f9 phase-helpers.sh: don't perform a dry run in _eapply_patch() Presently, the _eapply_patch() function executes a dry run of patch(1) to determine whether the patch can be applied without fuzz. It then proceeds to execute patch(1) for application, instructing the utility to be silent in the case that a fuzz factor of zero is permissible. Going about it in this way is wasteful. Instead, execute patch(1) just once while capturing its output. In the case that the patch is applied successfully, convey the output to STDOUT only if it matches a pattern identifying a fuzz factor. Otherwise, if the patch was unsuccessfully applied, convey the output to STDERR. Also, localise IFS so as to guarantee that the positional parameters are joined by a space in the diagnostic message. Signed-off-by: Kerin Millar plushkava.net> Signed-off-by: Sam James gentoo.org> bin/phase-helpers.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh index a3f7050e9f..be70c4b20e 100644 --- a/bin/phase-helpers.sh +++ b/bin/phase-helpers.sh @@ -982,8 +982,7 @@ if ___eapi_has_eapply; then local -a operands options _eapply_patch() { - local prefix=$1 patch=$2 - local -a patch_opts + local prefix=$1 patch=$2 output IFS shift 2 ebegin "${prefix:-Applying }${patch##*/}" @@ -991,16 +990,17 @@ if ___eapi_has_eapply; then # -f to avoid interactivity # -g0 to guarantee no VCS interaction # --no-backup-if-mismatch not to pollute the sources - patch_opts=( -p1 -f -g0 --no-backup-if-mismatch "$@" ) - - # Try applying with -F0 first, output a verbose warning - # if fuzz factor is necessary - if "${patch_cmd}" "${patch_opts[@]}" --dry-run -s -F0 < "${patch}" &>/dev/null; then - patch_opts+=( -s -F0 ) - fi - - "${patch_cmd}" "${patch_opts[@]}" < "${patch}" - if ! eend "$?"; then + set -- -p1 -f -g0 --no-backup-if-mismatch "$@" + if output=$(LC_ALL= LC_MESSAGES=C "${patch_cmd}" "$@" < "${patch}" 2>&1); then + # The patch was successfully applied. Maintain + # silence unless applied with fuzz. + if [[ ${output} == *[0-9]' with fuzz '[0-9]* ]]; then + printf '%s\n' "${output}" + fi + eend 0 + else + printf '%s\n' "${output}" >&2 + eend 1 __helpers_die "patch -p1 $* failed with ${patch}" fi }