commit:     b71bd1001468d367e55d3e581e43ef3c0630f2e5
Author:     Jason A. Donenfeld <Jason <AT> zx2c4 <DOT> com>
AuthorDate: Mon Mar  7 13:06:29 2016 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Mar  8 22:50:29 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=b71bd100

eapply_user: allow empty directories (bug 573920)

Without this, an empty directory in
/etc/portage/patches/$cat/$pkg will result in an fatal error.

X-Gentoo-Bug:     573920
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=573920
Signed-off-by:    Jason A. Donenfeld <Jason <AT> zx2c4.com>

 bin/phase-helpers.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 80f5946..1a9ee7b 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -1089,6 +1089,9 @@ if ___eapi_has_eapply_user; then
                local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches
 
                local d applied
+               local prev_shopt=$(shopt -p nullglob)
+               shopt -s nullglob
+
                # possibilities:
                # 1. ${CATEGORY}/${P}-${PR} (note: -r0 desired to avoid applying
                #    ${P} twice)
@@ -1096,12 +1099,14 @@ if ___eapi_has_eapply_user; then
                # 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 [[ -d ${d} ]]; then
+                       if [[ -n $(echo "${d}"/*.diff) || -n $(echo 
"${d}"/*.patch) ]]; then
                                eapply "${d}"
                                applied=1
                        fi
                done
 
+               ${prev_shopt}
+
                [[ -n ${applied} ]] && ewarn "User patches applied."
        }
 fi

Reply via email to