Always use a single `=` for bash tests, remove superfluous `;`s from the end of lines, always have `then` and `do` on the same line as their respective `if` and `for`/`while` statements.
Signed-off-by: Rahul Sandhu <[email protected]> --- eclass/selinux-policy-2.eclass | 76 +++++++++++++++++----------------- 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/eclass/selinux-policy-2.eclass b/eclass/selinux-policy-2.eclass index 265ac4bae1fe..6c345e2771a6 100644 --- a/eclass/selinux-policy-2.eclass +++ b/eclass/selinux-policy-2.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2025 Gentoo Authors +# Copyright 1999-2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # Eclass for installing SELinux policy, and optionally @@ -55,7 +55,7 @@ _SELINUX_POLICY_2_ECLASS=1 # (space-separated) or a bash array. : "${POLICY_FILES:=""}" -if [[ ${EAPI} == 7 ]]; then +if [[ ${EAPI} = 7 ]]; then # @ECLASS_VARIABLE: POLICY_TYPES # @DESCRIPTION: # This variable informs the eclass for which SELinux policies the module should @@ -91,7 +91,7 @@ case ${BASEPOL} in EGIT_CHECKOUT_DIR="${WORKDIR}/refpolicy";; esac -if [[ ${EAPI} == 7 ]]; then +if [[ ${EAPI} = 7 ]]; then IUSE="" else # Build all policy types by default @@ -121,7 +121,7 @@ else _BASE_POLICY_VERSION="${PV}" fi -if [[ ${EAPI} == 7 ]]; then +if [[ ${EAPI} = 7 ]]; then RDEPEND=">=sys-apps/policycoreutils-2.5 >=sec-policy/selinux-base-policy-${_BASE_POLICY_VERSION}" else @@ -173,10 +173,10 @@ selinux-policy-2_src_unpack() { # content. selinux-policy-2_src_prepare() { local modfiles - local add_interfaces=0; + local add_interfaces=0 # Create 3rd_party location for user-contributed policies - cd "${S}/refpolicy/policy/modules" && mkdir 3rd_party; + cd "${S}/refpolicy/policy/modules" && mkdir 3rd_party # Patch the sources with the base patchbundle if [[ -n ${BASEPOL} ]] && [[ "${BASEPOL}" != "9999" ]]; then @@ -190,19 +190,18 @@ selinux-policy-2_src_prepare() { eapply_user # Copy additional files to the 3rd_party/ location - if [[ "$(declare -p POLICY_FILES 2>/dev/null 2>&1)" == "declare -a"* ]] || + if [[ "$(declare -p POLICY_FILES 2>/dev/null 2>&1)" = "declare -a"* ]] || [[ -n ${POLICY_FILES} ]]; then - add_interfaces=1; + add_interfaces=1 cd "${S}/refpolicy/policy/modules" - for POLFILE in ${POLICY_FILES[@]}; - do - cp "${FILESDIR}/${POLFILE}" 3rd_party/ || die "Could not copy ${POLFILE} to 3rd_party/ location"; + for POLFILE in ${POLICY_FILES[@]}; do + cp "${FILESDIR}/${POLFILE}" 3rd_party/ || die "Could not copy ${POLFILE} to 3rd_party/ location" done fi # Apply the additional patches referred 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 + if [[ "$(declare -p POLICY_PATCH 2>/dev/null 2>&1)" = "declare -a"* ]]; then [[ -n ${POLICY_PATCH[*]} ]] && eapply -d "${S}/refpolicy/policy/modules" -- "${POLICY_PATCH[@]}" else [[ -n ${POLICY_PATCH} ]] && eapply -d "${S}/refpolicy/policy/modules" -- ${POLICY_PATCH} @@ -227,7 +226,7 @@ selinux-policy-2_src_prepare() { || die "Failed to copy the module files to ${S}/${1}" } - if [[ ${EAPI} == 7 ]]; then + if [[ ${EAPI} = 7 ]]; then for i in ${POLICY_TYPES}; do _selinux_prepare_modules $i done @@ -248,8 +247,7 @@ selinux-policy-2_src_compile() { local makeuse="" # We use IUSE instead of USE so that other variables set in the ebuild # environment, such as architecture ones, are not included. - for useflag in ${IUSE}; - do + for useflag in ${IUSE}; do # Advance past a possible '+' character: that is NOT part of the USE flag, # but instead indicates whether it is enabled by default. useflag="${useflag##+}" @@ -257,7 +255,7 @@ selinux-policy-2_src_compile() { # Only additional USE flags defined in our consumers should be added to # build options: SELINUX_POLICY_TYPES should NOT be passed to the policy # build system. - [[ "${useflag}" == selinux_policy_types_* ]] && continue + [[ "${useflag}" = selinux_policy_types_* ]] && continue use ${useflag} && makeuse="${makeuse} -D use_${useflag}" done @@ -268,7 +266,7 @@ selinux-policy-2_src_compile() { emake NAME=$1 SHAREDIR="${EPREFIX}"/usr/share/selinux -C "${S}"/${1} } - if [[ ${EAPI} == 7 ]]; then + if [[ ${EAPI} = 7 ]]; then for i in ${POLICY_TYPES}; do _selinux_compile_modules $i done @@ -292,20 +290,20 @@ selinux-policy-2_src_install() { for i in ${MODS}; do einfo "Installing ${1} ${i} policy package" insinto ${BASEDIR}/${1} - if [[ -f "${S}/${1}/${i}.pp" ]] ; then + 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 + 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 + 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 } - if [[ ${EAPI} == 7 ]]; then + if [[ ${EAPI} = 7 ]]; then for i in ${POLICY_TYPES}; do _selinux_install_modules $i done @@ -333,25 +331,25 @@ selinux-policy-2_pkg_postinst() { local COMMAND _selinux_postinst() { - if [[ "${1}" == "strict" ]] && [[ "${MODS}" = "unconfined" ]]; then - einfo "Ignoring loading of unconfined module in strict module store."; - continue; + 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 + for i in ${MODS}; do + if [[ -f "${i}.pp" ]]; then COMMAND="${i}.pp ${COMMAND}" - elif [[ -f "${i}.cil" ]] ; then + elif [[ -f "${i}.cil" ]]; then COMMAND="${i}.cil ${COMMAND}" fi done semodule ${root_opts} -s ${1} -i ${COMMAND} if [[ $? -ne 0 ]]; then - ewarn "SELinux module load failed. Trying full reload..."; + ewarn "SELinux module load failed. Trying full reload..." semodule ${root_opts} -s ${1} -i ./*.pp @@ -375,10 +373,10 @@ selinux-policy-2_pkg_postinst() { else einfo "SELinux modules loaded successfully." fi - COMMAND=""; + COMMAND="" } - if [[ ${EAPI} == 7 ]]; then + if [[ ${EAPI} = 7 ]]; then for i in ${POLICY_TYPES}; do _selinux_postinst $i done @@ -393,14 +391,14 @@ selinux-policy-2_pkg_postinst() { # Don't relabel when cross compiling if [[ -z ${ROOT} ]]; then # Relabel depending packages - local PKGSET=""; - if [[ -x /usr/bin/qdepends ]] ; then - PKGSET=$(/usr/bin/qdepends -Cq -r -Q ${CATEGORY}/${PN} | grep -v "sec-policy/selinux-"); - elif [[ -x /usr/bin/equery ]] ; then - PKGSET=$(/usr/bin/equery -Cq depends ${CATEGORY}/${PN} | grep -v "sec-policy/selinux-"); + local PKGSET="" + if [[ -x /usr/bin/qdepends ]]; then + PKGSET=$(/usr/bin/qdepends -Cq -r -Q ${CATEGORY}/${PN} | grep -v "sec-policy/selinux-") + elif [[ -x /usr/bin/equery ]]; then + PKGSET=$(/usr/bin/equery -Cq depends ${CATEGORY}/${PN} | grep -v "sec-policy/selinux-") fi - if [[ -n "${PKGSET}" ]] ; then - rlpkg ${PKGSET}; + if [[ -n "${PKGSET}" ]]; then + rlpkg ${PKGSET} fi fi } @@ -429,13 +427,13 @@ selinux-policy-2_pkg_postrm() { semodule ${root_opts} -s ${1} ${COMMAND} if [[ $? -ne 0 ]]; then - ewarn "SELinux module unload failed."; + ewarn "SELinux module unload failed." else einfo "SELinux modules unloaded successfully." fi } - if [[ ${EAPI} == 7 ]]; then + if [[ ${EAPI} = 7 ]]; then for i in ${POLICY_TYPES}; do _selinux_postrm $i done -- 2.50.1
