Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH v2] eapply: Output verbosely only if patch fails to apply with -F0
Date: Wed, 27 Nov 2019 19:18:13
Message-Id: 20191127191745.532807-1-mgorny@gentoo.org
1 12d0c48ad disabled silent output for eapply, in order to obtain fuzz
2 factors in build logs. However, this also causes eapply to report all
3 patched files which can make logs unreadable when there are no fuzz
4 factors to be reported. Instead, use verbose output only when applying
5 the patch with -F0 fails.
6
7 To achieve that, attempt to apply each patch with -F0 --dry-run first.
8 If this succeeds, just silently apply the patch for real. If it
9 doesn't, output an explicit eqawarn that the patch does not apply
10 cleanly and retry with the default fuzz factor and verbose output.
11 Non-silenced output applies both to successful application with fuzz
12 and to failure.
13
14 Signed-off-by: Michał Górny <mgorny@g.o>
15 ---
16 bin/phase-helpers.sh | 16 ++++++++++++++--
17 1 file changed, 14 insertions(+), 2 deletions(-)
18
19 Changes in v2:
20 - added original path to output
21
22 diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
23 index 60f8d3243..b5691bd70 100644
24 --- a/bin/phase-helpers.sh
25 +++ b/bin/phase-helpers.sh
26 @@ -995,8 +995,20 @@ if ___eapi_has_eapply; then
27 # -f to avoid interactivity
28 # -g0 to guarantee no VCS interaction
29 # --no-backup-if-mismatch not to pollute the sources
30 - ${patch_cmd} -p1 -f -g0 --no-backup-if-mismatch \
31 - "${patch_options[@]}" < "${f}"
32 + local all_opts=(
33 + -p1 -f -g0 --no-backup-if-mismatch
34 + "${patch_options[@]}"
35 + )
36 + # try applying with -F0 first, output a verbose warning
37 + # if fuzz factor is necessary
38 + if ${patch_cmd} "${all_opts[@]}" --dry-run -s -F0 \
39 + < "${f}" &>/dev/null; then
40 + all_opts+=( -s -F0 )
41 + else
42 + eqawarn " ${f}: patch failed to apply without a fuzz factor, please rebase"
43 + fi
44 +
45 + ${patch_cmd} "${all_opts[@]}" < "${f}"
46 failed=${?}
47 if ! eend "${failed}"; then
48 __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}"
49 --
50 2.24.0

Replies