commit:     0da2f7f852bc0168e9f857f93b93cf1df8567d4e
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Fri May 30 05:52:05 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jun  1 21:41:59 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=0da2f7f8

phase-helpers.sh: render the exit status of _eapply_patch() meaningful

It isn't necessary to know the exact exit status value of the patch(1)
utility. PMS only requires for eapply() to return a non-zero status in
the case that something goes wrong and nonfatal is in effect.

Even if that were not the case, having _eapply_patch() be implemented as
an impure function that sets a variable in an upper scope just to convey
an exit status value is a rather odd way of going about things.

Simplify all of this by ensuring that _eapply_patch() returns non-zero
in the nonfatal case. Note that it takes advantange of the preceding
commit to do so; it is now guaranteed that __helpers_die() returns
something other than 0, where nonfatal is in effect. Consequently,
eapply() can now respond directly to the return value, rather than
proceed to consult the 'failed' variable, which has been eliminated.

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

 bin/phase-helpers.sh | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index bef0abbcc9..ddc446d738 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -978,7 +978,7 @@ fi
 
 if ___eapi_has_eapply; then
        eapply() {
-               local f failed patch_cmd path
+               local f patch_cmd path
                local -a files operands options
 
                _eapply_get_files() {
@@ -1010,8 +1010,7 @@ if ___eapi_has_eapply; then
                        fi
 
                        "${patch_cmd}" "${patch_opts[@]}" < "${patch}"
-                       failed=${?}
-                       if ! eend "${failed}"; then
+                       if ! eend "$?"; then
                                __helpers_die "patch -p1 $* failed with 
${patch}"
                        fi
                }
@@ -1055,20 +1054,12 @@ if ___eapi_has_eapply; then
 
                                einfo "Applying patches from ${path} ..."
                                for f in "${files[@]}"; do
-                                       _eapply_patch "${f}" '  ' 
"${options[@]}"
-
-                                       # in case of nonfatal
-                                       [[ ${failed} -ne 0 ]] && return 
"${failed}"
+                                       _eapply_patch "${f}" '  ' 
"${options[@]}" || return
                                done
                        else
-                               _eapply_patch "${path}" '' "${options[@]}"
-
-                               # In case of nonfatal
-                               [[ ${failed} -ne 0 ]] && return "${failed}"
+                               _eapply_patch "${path}" '' "${options[@]}" || 
return
                        fi
                done
-
-               return 0
        }
 fi
 

Reply via email to