commit:     a0be96d697774e1d79685290f3a0547dba118673
Author:     Krzesimir Nowak <knowak <AT> microsoft <DOT> com>
AuthorDate: Wed Jun 29 15:05:23 2022 +0000
Commit:     Kenton Groombridge <concord <AT> gentoo <DOT> org>
CommitDate: Thu Jun 30 17:03:24 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a0be96d6

eclass/selinux-policy-2: fix POLICY_PATCH applying

eapply as implemented in portage has some heuristics to find out where
the parameters that should be passed to patch utility end and actual
diff/patch files begin. It first tries to find -- which is the
explicit way of separating parameters from input files. Since there's
none, it tries to find a first non-option. And it finds the refpolicy
directory as a first non-option, while it is supposed to be a value of
the -d parameter. The said directory is then treated as an input
directory, which is expected to contain at least one patch or diff
file. Since there's none, eapply fails.

Help eapply's heuristics by explicitly delimiting the parameters from
input files with --.

Bug: https://bugs.gentoo.org/794682
Signed-off-by: Krzesimir Nowak <knowak <AT> microsoft.com>
Closes: https://github.com/gentoo/gentoo/pull/26148
Signed-off-by: Kenton Groombridge <concord <AT> gentoo.org>

 eclass/selinux-policy-2.eclass | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/eclass/selinux-policy-2.eclass b/eclass/selinux-policy-2.eclass
index 81d982f749c1..b2d53a2aac0b 100644
--- a/eclass/selinux-policy-2.eclass
+++ b/eclass/selinux-policy-2.eclass
@@ -159,7 +159,7 @@ selinux-policy-2_src_prepare() {
        if [[ -n ${BASEPOL} ]] && [[ "${BASEPOL}" != "9999" ]]; then
                cd "${S}"
                einfo "Applying SELinux policy updates ... "
-               eapply -p0 
"${WORKDIR}/0001-full-patch-against-stable-release.patch"
+               eapply -p0 -- 
"${WORKDIR}/0001-full-patch-against-stable-release.patch"
        fi
 
        # Call in eapply_user. We do this early on as we start moving
@@ -180,9 +180,9 @@ selinux-policy-2_src_prepare() {
        # Apply the additional patches refered to by the module ebuild.
        # But first some magic to differentiate between bash arrays and strings
        if [[ "$(declare -p POLICY_PATCH 2>/dev/null 2>&1)" == "declare -a"* 
]]; then
-               [[ -n ${POLICY_PATCH[*]} ]] && eapply -d 
"${S}/refpolicy/policy/modules" "${POLICY_PATCH[@]}"
+               [[ -n ${POLICY_PATCH[*]} ]] && eapply -d 
"${S}/refpolicy/policy/modules" -- "${POLICY_PATCH[@]}"
        else
-               [[ -n ${POLICY_PATCH} ]] && eapply -d 
"${S}/refpolicy/policy/modules" ${POLICY_PATCH}
+               [[ -n ${POLICY_PATCH} ]] && eapply -d 
"${S}/refpolicy/policy/modules" -- ${POLICY_PATCH}
        fi
 
        # Collect only those files needed for this particular module

Reply via email to