1 |
commit: 7d2c4fb609454b76d30c42fc7a0bb720decc39a3 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Aug 6 07:40:19 2017 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Aug 11 16:05:27 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=7d2c4fb6 |
7 |
|
8 |
eapply_user: combine sort for all dirs (bug 608880) |
9 |
|
10 |
Combine the patch basenames from all matched directories into a |
11 |
list, and apply them in POSIX sorted order. This allows patches in |
12 |
more-specific directories to override patches of the same basename found |
13 |
in less-specific directories. An empty patch (or /dev/null symlink) |
14 |
negates a patch with the same basename found in a less-specific |
15 |
directory. |
16 |
|
17 |
This behavior is much more flexible and intuitive than the previous one, |
18 |
while remaining backward-compatible to some extent. |
19 |
|
20 |
NOTE: The implementation uses an associative array, which requires bash |
21 |
version 4 or later. |
22 |
|
23 |
X-Gentoo-bug: 608880 |
24 |
X-Gentoo-bug-url: https://bugs.gentoo.org/608880 |
25 |
Reviewed-by: Manuel RĂ¼ger <mrueg <AT> gentoo.org> |
26 |
|
27 |
bin/phase-helpers.sh | 35 ++++++++++++++++++++++++++++------- |
28 |
1 file changed, 28 insertions(+), 7 deletions(-) |
29 |
|
30 |
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh |
31 |
index 4b9b12b70..c02257eb6 100644 |
32 |
--- a/bin/phase-helpers.sh |
33 |
+++ b/bin/phase-helpers.sh |
34 |
@@ -1094,23 +1094,44 @@ if ___eapi_has_eapply_user; then |
35 |
|
36 |
local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches |
37 |
|
38 |
- local d applied |
39 |
+ local applied d f |
40 |
+ local -A _eapply_user_patches |
41 |
local prev_shopt=$(shopt -p nullglob) |
42 |
shopt -s nullglob |
43 |
|
44 |
- # possibilities: |
45 |
+ # Patches from all matched directories are combined into a |
46 |
+ # sorted (POSIX order) list of the patch basenames. Patches |
47 |
+ # in more-specific directories override patches of the same |
48 |
+ # basename found in less-specific directories. An empty patch |
49 |
+ # (or /dev/null symlink) negates a patch with the same |
50 |
+ # basename found in a less-specific directory. |
51 |
+ # |
52 |
+ # order of specificity: |
53 |
# 1. ${CATEGORY}/${P}-${PR} (note: -r0 desired to avoid applying |
54 |
# ${P} twice) |
55 |
# 2. ${CATEGORY}/${P} |
56 |
# 3. ${CATEGORY}/${PN} |
57 |
# all of the above may be optionally followed by a slot |
58 |
- for d in "${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{,:${SLOT%/*}}; do |
59 |
- if [[ -n $(echo "${d}"/*.diff) || -n $(echo "${d}"/*.patch) ]]; then |
60 |
- eapply "${d}" |
61 |
- applied=1 |
62 |
- fi |
63 |
+ for d in "${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{:${SLOT%/*},}; do |
64 |
+ for f in "${d}"/*; do |
65 |
+ if [[ ( ${f} == *.diff || ${f} == *.patch ) && |
66 |
+ -z ${_eapply_user_patches[${f##*/}]} ]]; then |
67 |
+ _eapply_user_patches[${f##*/}]=${f} |
68 |
+ fi |
69 |
+ done |
70 |
done |
71 |
|
72 |
+ if [[ ${#_eapply_user_patches[@]} -gt 0 ]]; then |
73 |
+ while read -r -d '' f; do |
74 |
+ f=${_eapply_user_patches[${f}]} |
75 |
+ if [[ -s ${f} ]]; then |
76 |
+ eapply "${f}" |
77 |
+ applied=1 |
78 |
+ fi |
79 |
+ done < <(printf -- '%s\0' "${!_eapply_user_patches[@]}" | |
80 |
+ LC_ALL=C sort -z) |
81 |
+ fi |
82 |
+ |
83 |
${prev_shopt} |
84 |
|
85 |
[[ -n ${applied} ]] && ewarn "User patches applied." |