From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id DC5961396D0 for ; Fri, 11 Aug 2017 16:06:51 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 182E2E0CB9; Fri, 11 Aug 2017 16:06:51 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D9647E0CB9 for ; Fri, 11 Aug 2017 16:06:50 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8302D33B864 for ; Fri, 11 Aug 2017 16:06:49 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 222073E99 for ; Fri, 11 Aug 2017 16:06:48 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1502467527.7d2c4fb609454b76d30c42fc7a0bb720decc39a3.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/phase-helpers.sh X-VCS-Directories: bin/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 7d2c4fb609454b76d30c42fc7a0bb720decc39a3 X-VCS-Branch: master Date: Fri, 11 Aug 2017 16:06:48 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 15d4d79c-bdb9-4084-a89e-e2476be3df74 X-Archives-Hash: 0d207ec5290abbff2307b9f7180f4afc commit: 7d2c4fb609454b76d30c42fc7a0bb720decc39a3 Author: Zac Medico gentoo org> AuthorDate: Sun Aug 6 07:40:19 2017 +0000 Commit: Zac Medico gentoo org> CommitDate: Fri Aug 11 16:05:27 2017 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=7d2c4fb6 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 gentoo.org> bin/phase-helpers.sh | 35 ++++++++++++++++++++++++++++------- 1 file 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."