commit: 4a315c41b43867320b27e882bb1427ac553e683c
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 27 18:49:37 2019 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Nov 27 19:38:46 2019 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=4a315c41
eapply: Output verbosely only if patch fails to apply with -F0
12d0c48ad disabled silent output for eapply, in order to obtain fuzz
factors in build logs. However, this also causes eapply to report all
patched files which can make logs unreadable when there are no fuzz
factors to be reported. Instead, use verbose output only when applying
the patch with -F0 fails.
To achieve that, attempt to apply each patch with -F0 --dry-run first.
If this succeeds, just silently apply the patch for real. If it
doesn't, output an explicit eqawarn that the patch does not apply
cleanly and retry with the default fuzz factor and verbose output.
Non-silenced output applies both to successful application with fuzz
and to failure.
Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
bin/phase-helpers.sh | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 60f8d3243..b5691bd70 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -995,8 +995,20 @@ 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_cmd} -p1 -f -g0 --no-backup-if-mismatch \
- "${patch_options[@]}" < "${f}"
+ local all_opts=(
+ -p1 -f -g0 --no-backup-if-mismatch
+ "${patch_options[@]}"
+ )
+ # try applying with -F0 first, output a verbose warning
+ # if fuzz factor is necessary
+ if ${patch_cmd} "${all_opts[@]}" --dry-run -s -F0 \
+ < "${f}" &>/dev/null; then
+ all_opts+=( -s -F0 )
+ else
+ eqawarn " ${f}: patch failed to apply
without a fuzz factor, please rebase"
+ fi
+
+ ${patch_cmd} "${all_opts[@]}" < "${f}"
failed=${?}
if ! eend "${failed}"; then
__helpers_die "patch -p1 ${patch_options[*]}
failed with ${f}"