Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.gentoo.dev > #70396

[gentoo-dev] [PATCH v4 2/5] selinux-policy-2.eclass: respect the sanctity of -rN for EAPI=8

From Rahul Sandhu <nvraxn@posteo.uk>
Newsgroups linux.gentoo.dev
Subject [gentoo-dev] [PATCH v4 2/5] selinux-policy-2.eclass: respect the sanctity of -rN for EAPI=8
Date 2026-04-07 17:20 +0200
Message-ID <MHgnD-dnM7-5@gated-at.bofh.it> (permalink)
References <MHgnD-dnM7-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Currently, ebuild revisions are molested by the versioning of policy
patch bundles. -rN is reserved _exclusively_ for ebuild revisions; they
should not be relied upon for versioning tarballs.

Right now, this poses a problem: we can't revbump any ebuilds without
breaking SRC_URI. This is because the BASEPOL variable, which is then
later used to fetch the patchbundle in SRC_URI, is set to ${PVR} by
default.

To remedy this, transform a PV of XXX_pN to XXX-rN for EAPI=8. We can't
do this for EAPI=7, sadly, as this would break the existing conventions
for naming that are used by our consumers.

Signed-off-by: Rahul Sandhu <nvraxn@posteo.uk>
---
 eclass/selinux-policy-2.eclass | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/eclass/selinux-policy-2.eclass b/eclass/selinux-policy-2.eclass
index fff8adea6ae9..9a3a7037a2c3 100644
--- a/eclass/selinux-policy-2.eclass
+++ b/eclass/selinux-policy-2.eclass
@@ -37,7 +37,12 @@ _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.
-: "${BASEPOL:="${PVR}"}"
+# For EAPI 8 and above, _pN corresponds to -rN in the patch bundle(s).
+if [[ ${EAPI} = 7 ]]; then
+	: "${BASEPOL:="${PVR}"}"
+else
+	: "${BASEPOL:="${PV/_p/-r}"}"
+fi
 
 # @ECLASS_VARIABLE: POLICY_PATCH
 # @DESCRIPTION:
@@ -90,6 +95,12 @@ fi
 # This variable contains the USE dependency constraints for policy packages.
 SELINUX_POLICY_USEDEP="selinux_policy_types_targeted(-)?,selinux_policy_types_strict(-)?,selinux_policy_types_mcs(-)?,selinux_policy_types_mls(-)?"
 
+# @ECLASS_VARIABLE: _SELINUX_POLICY_UPSTREAM_PV
+# @INTERNAL
+# @DESCRIPTION:
+# Internal variable representing (spoofed) upstream refpolicy version.
+_SELINUX_POLICY_UPSTREAM_PV=$(ver_cut 1-2)
+
 case ${BASEPOL} in
 	9999)
 		inherit git-r3
@@ -108,11 +119,11 @@ fi
 HOMEPAGE="https://wiki.gentoo.org/wiki/Project:SELinux"
 if [[ -n ${BASEPOL} && "${BASEPOL}" != "9999" ]]; then
 	SRC_URI="
-		https://github.com/SELinuxProject/refpolicy/releases/download/RELEASE_${PV/./_}/refpolicy-${PV}.tar.bz2
+		https://github.com/SELinuxProject/refpolicy/releases/download/RELEASE_${_SELINUX_POLICY_UPSTREAM_PV/./_}/refpolicy-${_SELINUX_POLICY_UPSTREAM_PV}.tar.bz2
 		https://dev.gentoo.org/~perfinion/patches/selinux-base-policy/patchbundle-selinux-base-policy-${BASEPOL}.tar.bz2
 	"
 elif [[ "${BASEPOL}" != "9999" ]]; then
-	SRC_URI="https://github.com/SELinuxProject/refpolicy/releases/download/RELEASE_${PV/./_}/refpolicy-${PV}.tar.bz2"
+	SRC_URI="https://github.com/SELinuxProject/refpolicy/releases/download/RELEASE_${_SELINUX_POLICY_UPSTREAM_PV/./_}/refpolicy-${_SELINUX_POLICY_UPSTREAM_PV}.tar.bz2"
 fi
 
 LICENSE="GPL-2"
@@ -124,7 +135,7 @@ S="${WORKDIR}"
 if [[ -n ${BASEPOL} ]]; then
 	_BASE_POLICY_VERSION="${BASEPOL}"
 else
-	_BASE_POLICY_VERSION="${PV}"
+	_BASE_POLICY_VERSION="${_SELINUX_POLICY_UPSTREAM_PV}"
 fi
 
 if [[ ${EAPI} = 7 ]]; then
-- 
2.53.0

Back to linux.gentoo.dev | Previous | Next | Find similar


Thread

[gentoo-dev] [PATCH v4 2/5] selinux-policy-2.eclass: respect the sanctity of -rN for EAPI=8 Rahul Sandhu <nvraxn@posteo.uk> - 2026-04-07 17:20 +0200

csiph-web