[PATCH 1/6] selinux-policy-2.eclass: drop EAPI 7 support
Rahul Sandhu <[email protected]> Sat, 20 Jun 2026 07:21:20 +0000
| Newsgroups | gmane.linux.gentoo.devel |
|---|---|
| Message-ID | <[email protected]> |
Signed-off-by: Rahul Sandhu <[email protected]> --- eclass/selinux-policy-2.eclass | 258 ++++++++++++--------------------- 1 file changed, 92 insertions(+), 166 deletions(-) diff --git a/eclass/selinux-policy-2.eclass b/eclass/selinux-policy-2.eclass index d434251672f5..0ccd3706db80 100644 --- a/eclass/selinux-policy-2.eclass +++ b/eclass/selinux-policy-2.eclass @@ -7,7 +7,7 @@ # @ECLASS: selinux-policy-2.eclass # @MAINTAINER: # [email protected] -# @SUPPORTED_EAPIS: 7 8 +# @SUPPORTED_EAPIS: 8 # @BLURB: This eclass supports the deployment of the various SELinux modules in sec-policy # @DESCRIPTION: # The selinux-policy-2.eclass supports deployment of the various SELinux modules @@ -19,7 +19,7 @@ # manageable. case ${EAPI} in - 7|8) ;; + 8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac @@ -37,12 +37,8 @@ _SELINUX_POLICY_2_ECLASS=1 # This variable contains the version string of the selinux-base-policy package # that this module build depends on. It is used to patch with the appropriate # patch bundle(s) that are part of selinux-base-policy. -# EAPI <=7 packages had -rN and patchbundle named -rN -# EAPI 8 moved packages to _p, but kept patchbundles unchanged as -rN # Releases in 2026 made the patchbundles with _pN to match PV -if [[ ${EAPI} = 7 ]]; then - : "${BASEPOL:="${PVR}"}" -elif [[ ${EAPI} = 8 ]] && ver_test -lt 2.20260101; then +if ver_test -lt 2.20260101; then : "${BASEPOL:="${PV/_p/-r}"}" else : "${BASEPOL:="${PV}"}" @@ -64,17 +60,6 @@ fi # (space-separated) or a bash array. : "${POLICY_FILES:=""}" -if [[ ${EAPI} = 7 ]]; then - # @ECLASS_VARIABLE: POLICY_TYPES - # @DESCRIPTION: - # This variable informs the eclass for which SELinux policies the module should - # be built. Currently, Gentoo supports targeted, strict, mcs and mls. - # This variable is the same POLICY_TYPES variable that we tell SELinux - # users to set in make.conf. Therefore, it is not the module that should - # override it, but the user. - : "${POLICY_TYPES:="targeted strict mcs mls"}" -fi - # @ECLASS_VARIABLE: SELINUX_GIT_REPO # @DESCRIPTION: # When defined, this variable overrides the default repository URL as used by @@ -114,11 +99,9 @@ case ${BASEPOL} in ;; esac -if [[ ${EAPI} != 7 ]]; then - # Build all policy types by default - IUSE="+selinux_policy_types_targeted +selinux_policy_types_strict +selinux_policy_types_mcs +selinux_policy_types_mls" - REQUIRED_USE="|| ( selinux_policy_types_targeted selinux_policy_types_strict selinux_policy_types_mcs selinux_policy_types_mls )" -fi +# Build all policy types by default +IUSE="+selinux_policy_types_targeted +selinux_policy_types_strict +selinux_policy_types_mcs +selinux_policy_types_mls" +REQUIRED_USE="|| ( selinux_policy_types_targeted selinux_policy_types_strict selinux_policy_types_mcs selinux_policy_types_mls )" HOMEPAGE="https://wiki.gentoo.org/wiki/Project:SELinux" if [[ -n ${BASEPOL} && "${BASEPOL}" != "9999" ]]; then @@ -142,17 +125,10 @@ else _BASE_POLICY_VERSION="${_SELINUX_POLICY_UPSTREAM_PV}" fi -if [[ ${EAPI} = 7 ]]; then - RDEPEND=" - >=sys-apps/policycoreutils-2.5 - >=sec-policy/selinux-base-policy-${_BASE_POLICY_VERSION} - " -else - RDEPEND=" - >=sys-apps/policycoreutils-2.5 - >=sec-policy/selinux-base-policy-${_BASE_POLICY_VERSION}[${SELINUX_POLICY_USEDEP}] - " -fi +RDEPEND=" + >=sys-apps/policycoreutils-2.5 + >=sec-policy/selinux-base-policy-${_BASE_POLICY_VERSION}[${SELINUX_POLICY_USEDEP}] +" unset _BASE_POLICY_VERSION @@ -230,26 +206,16 @@ selinux-policy-2_src_prepare() { fi done - _selinux_prepare_modules() { - mkdir "${S}"/${1} || die "Failed to create directory ${S}/${1}" - cp "${S}"/refpolicy/doc/Makefile.example "${S}"/${1}/Makefile \ - || die "Failed to copy Makefile.example to ${S}/${1}/Makefile" - - cp ${modfiles} "${S}"/${1} \ - || die "Failed to copy the module files to ${S}/${1}" - } + for type in targeted strict mcs mls; do + if use "selinux_policy_types_${type}"; then + mkdir "${S}/${type}" || die "Failed to create directory ${S}/${type}" + cp "${S}/refpolicy/doc/Makefile.example" "${S}/${type}/Makefile" \ + || die "Failed to copy Makefile.example to ${S}/${type}/Makefile" - if [[ ${EAPI} = 7 ]]; then - for i in ${POLICY_TYPES}; do - _selinux_prepare_modules $i - done - else - for i in targeted strict mcs mls; do - if use selinux_policy_types_${i}; then - _selinux_prepare_modules $i - fi - done - fi + cp ${modfiles} "${S}/${type}" \ + || die "Failed to copy the module files to ${S}/${type}" + fi + done } # @FUNCTION: selinux-policy-2_src_compile @@ -273,23 +239,13 @@ selinux-policy-2_src_compile() { use ${useflag} && makeuse="${makeuse} -D use_${useflag}" done - _selinux_compile_modules() { - # Support USE flags in builds - export M4PARAM="${makeuse}" - emake NAME=$1 SHAREDIR="${ESYSROOT}"/usr/share/selinux -C "${S}"/${1} - } - - if [[ ${EAPI} = 7 ]]; then - for i in ${POLICY_TYPES}; do - _selinux_compile_modules $i - done - else - for i in targeted strict mcs mls; do - if use selinux_policy_types_${i}; then - _selinux_compile_modules $i - fi - done - fi + for type in targeted strict mcs mls; do + if use "selinux_policy_types_${type}"; then + # Support USE flags in builds + export M4PARAM="${makeuse}" + emake NAME="${type}" SHAREDIR="${ESYSROOT}/usr/share/selinux" -C "${S}/${type}" + fi + done } # @FUNCTION: selinux-policy-2_src_install @@ -299,34 +255,24 @@ selinux-policy-2_src_compile() { selinux-policy-2_src_install() { local BASEDIR="/usr/share/selinux" - _selinux_install_modules() { - for i in ${MODS}; do - einfo "Installing ${1} ${i} policy package" - insinto ${BASEDIR}/${1} - if [[ -f "${S}/${1}/${i}.pp" ]]; then - doins "${S}"/${1}/${i}.pp || die "Failed to add ${i}.pp to ${1}" - elif [[ -f "${S}/${1}/${i}.cil" ]]; then - doins "${S}"/${1}/${i}.cil || die "Failed to add ${i}.cil to ${1}" - fi - - if [[ "${POLICY_FILES[@]}" = *"${i}.if"* ]]; then - insinto ${BASEDIR}/${1}/include/3rd_party - doins "${S}"/${1}/${i}.if || die "Failed to add ${i}.if to ${1}" - fi - done - } + for type in targeted strict mcs mls; do + if use "selinux_policy_types_${type}"; then + for mod in ${MODS}; do + einfo "Installing ${type} ${mod} policy package" + insinto "${BASEDIR}/${type}" + if [[ -f "${S}/${type}/${mod}.pp" ]]; then + doins "${S}"/${type}/${mod}.pp || die "Failed to add ${mod}.pp to ${type}" + elif [[ -f "${S}/${type}/${mod}.cil" ]]; then + doins "${S}"/${type}/${mod}.cil || die "Failed to add ${mod}.cil to ${type}" + fi - if [[ ${EAPI} = 7 ]]; then - for i in ${POLICY_TYPES}; do - _selinux_install_modules $i - done - else - for i in targeted strict mcs mls; do - if use selinux_policy_types_${i}; then - _selinux_install_modules $i - fi - done - fi + if [[ "${POLICY_FILES[@]}" = *"${mod}.if"* ]]; then + insinto "${BASEDIR}/${type}/include/3rd_party" + doins "${S}/${type}/${mod}.if" || die "Failed to add ${mod}.if to ${type}" + fi + done + fi + done } # @FUNCTION: selinux-policy-2_pkg_postinst @@ -343,63 +289,53 @@ selinux-policy-2_pkg_postinst() { # build up the command in the case of multiple modules local COMMAND - _selinux_postinst() { - if [[ "${1}" = "strict" && "${MODS}" = "unconfined" ]]; then - einfo "Ignoring loading of unconfined module in strict module store." - continue - fi - - einfo "Inserting the following modules into the $i module store: ${MODS}" - - cd "${ROOT}/usr/share/selinux/${1}" || die "Could not enter /usr/share/selinux/${1}" - for i in ${MODS}; do - if [[ -f "${i}.pp" ]]; then - COMMAND="${i}.pp ${COMMAND}" - elif [[ -f "${i}.cil" ]]; then - COMMAND="${i}.cil ${COMMAND}" + for type in targeted strict mcs mls; do + if use "selinux_policy_types_${type}"; then + if [[ "${type}" = "strict" && "${MODS}" = "unconfined" ]]; then + einfo "Ignoring loading of unconfined module in strict module store." + continue fi - done - semodule ${root_opts} -s ${1} -i ${COMMAND} - if [[ $? -ne 0 ]]; then - ewarn "SELinux module load failed. Trying full reload..." + einfo "Inserting the following modules into the ${type} module store: ${MODS}" - semodule ${root_opts} -s ${1} -i ./*.pp + cd "${ROOT}/usr/share/selinux/${type}" || die "Could not enter /usr/share/selinux/${type}" + for i in ${MODS}; do + if [[ -f "${i}.pp" ]]; then + COMMAND="${i}.pp ${COMMAND}" + elif [[ -f "${i}.cil" ]]; then + COMMAND="${i}.cil ${COMMAND}" + fi + done + semodule ${root_opts} -s ${type} -i ${COMMAND} if [[ $? -ne 0 ]]; then - ewarn "Failed to reload SELinux policies." - ewarn "" - ewarn "If this is *not* the last SELinux module package being installed," - ewarn "then you can safely ignore this as the reloads will be retried" - ewarn "with other, recent modules." - ewarn "" - ewarn "If it is the last SELinux module package being installed however," - ewarn "then it is advised to look at the error above and take appropriate" - ewarn "action since the new SELinux policies are not loaded until the" - ewarn "command finished successfully." - ewarn "" - ewarn "To reload, run the following command:" - ewarn " semodule -i /usr/share/selinux/${1}/*.pp" + ewarn "SELinux module load failed. Trying full reload..." + + semodule ${root_opts} -s ${type} -i ./*.pp + + if [[ $? -ne 0 ]]; then + ewarn "Failed to reload SELinux policies." + ewarn "" + ewarn "If this is *not* the last SELinux module package being installed," + ewarn "then you can safely ignore this as the reloads will be retried" + ewarn "with other, recent modules." + ewarn "" + ewarn "If it is the last SELinux module package being installed however," + ewarn "then it is advised to look at the error above and take appropriate" + ewarn "action since the new SELinux policies are not loaded until the" + ewarn "command finished successfully." + ewarn "" + ewarn "To reload, run the following command:" + ewarn " semodule -i /usr/share/selinux/${type}/*.pp" + else + einfo "SELinux modules reloaded successfully." + fi else - einfo "SELinux modules reloaded successfully." + einfo "SELinux modules loaded successfully." fi - else - einfo "SELinux modules loaded successfully." + COMMAND="" fi - COMMAND="" - } - - if [[ ${EAPI} = 7 ]]; then - for i in ${POLICY_TYPES}; do - _selinux_postinst $i - done - else - for i in targeted strict mcs mls; do - if use selinux_policy_types_${i}; then - _selinux_postinst $i - fi - done - fi + done # Don't relabel when cross compiling if [[ -z ${ROOT} ]]; then @@ -458,28 +394,18 @@ selinux-policy-2_pkg_postrm() { COMMAND="-r ${i} ${COMMAND}" done - _selinux_postrm() { - einfo "Removing the following modules from the $1 module store: ${MODS}" - - semodule ${root_opts} -s ${1} ${COMMAND} - if [[ $? -ne 0 ]]; then - ewarn "SELinux module unload failed." - else - einfo "SELinux modules unloaded successfully." - fi - } + for type in targeted strict mcs mls; do + if use "selinux_policy_types_${type}"; then + einfo "Removing the following modules from the ${type} module store: ${MODS}" - if [[ ${EAPI} = 7 ]]; then - for i in ${POLICY_TYPES}; do - _selinux_postrm $i - done - else - for i in targeted strict mcs mls; do - if use selinux_policy_types_${i}; then - _selinux_postrm $i + semodule ${root_opts} -s ${type} ${COMMAND} + if [[ $? -ne 0 ]]; then + ewarn "SELinux module unload failed." + else + einfo "SELinux modules unloaded successfully." fi - done - fi + fi + done fi } -- 2.54.0