diff options
author | Zac Medico <zmedico@gentoo.org> | 2017-08-06 00:40:19 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2017-08-11 09:05:27 -0700 |
commit | 7d2c4fb609454b76d30c42fc7a0bb720decc39a3 (patch) | |
tree | 64398eb4074e13f9398e6801caa77c6938fd4e5e | |
parent | GitSync.retrieve_head: return str, not bytes (bug 625888) (diff) | |
download | portage-7d2c4fb609454b76d30c42fc7a0bb720decc39a3.tar.gz portage-7d2c4fb609454b76d30c42fc7a0bb720decc39a3.tar.bz2 portage-7d2c4fb609454b76d30c42fc7a0bb720decc39a3.zip |
eapply_user: combine sort for all dirs (bug 608880)
Combine the patch basenames from all matched directories into a
list, and apply them in POSIX sorted order. This allows patches in
more-specific directories to override patches of the same basename found
in less-specific directories. An empty patch (or /dev/null symlink)
negates a patch with the same basename found in a less-specific
directory.
This behavior is much more flexible and intuitive than the previous one,
while remaining backward-compatible to some extent.
NOTE: The implementation uses an associative array, which requires bash
version 4 or later.
X-Gentoo-bug: 608880
X-Gentoo-bug-url: https://bugs.gentoo.org/608880
Reviewed-by: Manuel RĂ¼ger <mrueg@gentoo.org>
-rw-r--r-- | bin/phase-helpers.sh | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh index 4b9b12b70..c02257eb6 100644 --- a/bin/phase-helpers.sh +++ b/bin/phase-helpers.sh @@ -1094,23 +1094,44 @@ if ___eapi_has_eapply_user; then local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches - local d applied + local applied d f + local -A _eapply_user_patches local prev_shopt=$(shopt -p nullglob) shopt -s nullglob - # possibilities: + # Patches from all matched directories are combined into a + # sorted (POSIX order) list of the patch basenames. Patches + # in more-specific directories override patches of the same + # basename found in less-specific directories. An empty patch + # (or /dev/null symlink) negates a patch with the same + # basename found in a less-specific directory. + # + # order of specificity: # 1. ${CATEGORY}/${P}-${PR} (note: -r0 desired to avoid applying # ${P} twice) # 2. ${CATEGORY}/${P} # 3. ${CATEGORY}/${PN} # all of the above may be optionally followed by a slot - for d in "${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{,:${SLOT%/*}}; do - if [[ -n $(echo "${d}"/*.diff) || -n $(echo "${d}"/*.patch) ]]; then - eapply "${d}" - applied=1 - fi + for d in "${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{:${SLOT%/*},}; do + for f in "${d}"/*; do + if [[ ( ${f} == *.diff || ${f} == *.patch ) && + -z ${_eapply_user_patches[${f##*/}]} ]]; then + _eapply_user_patches[${f##*/}]=${f} + fi + done done + if [[ ${#_eapply_user_patches[@]} -gt 0 ]]; then + while read -r -d '' f; do + f=${_eapply_user_patches[${f}]} + if [[ -s ${f} ]]; then + eapply "${f}" + applied=1 + fi + done < <(printf -- '%s\0' "${!_eapply_user_patches[@]}" | + LC_ALL=C sort -z) + fi + ${prev_shopt} [[ -n ${applied} ]] && ewarn "User patches applied." |