Skip to content

Commit 42379ec

Browse files
committed
sys-apps/policycoreutils: Sync with Gentoo
It's from Gentoo commit b854c7e78dfbd4c9afcadf9d2beb92e9cd24424b.
1 parent 3ce9a13 commit 42379ec

File tree

4 files changed

+387
-92
lines changed

4 files changed

+387
-92
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
DIST policycoreutils-3.7.tar.gz 757142 BLAKE2B 95794d48ef80882803199af5330f0ac4f1cee6710562a559e3d8fd94475d117286f8b612ffc5dc9027f4f8f4cd55e82ddb4d328e91d6c9846b18460c9bee159b SHA512 30e3413b15df0bf1a994d2b3a03a719f89b3ee521a708b92fcc684822152145722cb3ef28fd5b7c42b779281b0bd4d69d65c0bc2605eec1af3f388609d985500
2+
DIST policycoreutils-3.8.1.tar.gz 758726 BLAKE2B cda4c6a967a156874d6adcadbda546d8cf30d19622e0bec85ade88eccf730e4dd143eb7b07678826e1284aaa2fe316c24f828d28f422e15694d38d4e06035b78 SHA512 e14df87d163eec46a57bb7496db77090bd310554b2af1b68c66d9ef2f160bc4ac17305fb889a5415489baeabfd47946c0e37e6ad4dd14e392529c802ad06290b
23
DIST policycoreutils-extra-1.37.tar.bz2 8809 BLAKE2B a7f6122c2e27f54b018174e962bd7f4c14af04e09bbb5300bde6967ea7f2dc5cd03b5787919a4e7f5288bcbc6747922962b5bd3b588ab1e3a035fbff4910d8f5 SHA512 0a85cd7cf279256b5e1927f9dfdd89626a1c8b77b0aeb62b496e7e8d1dccbaa315e39f9308fb2df7270f0bc1c10787b19990e7365cad74b47b61e30394c8b23f

sdk_container/src/third_party/portage-stable/sys-apps/policycoreutils/policycoreutils-3.7.ebuild

Lines changed: 50 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -17,45 +17,32 @@ HOMEPAGE="https://github.com/SELinuxProject/selinux/wiki"
1717
if [[ ${PV} == 9999 ]]; then
1818
inherit git-r3
1919
EGIT_REPO_URI="https://github.com/SELinuxProject/selinux.git"
20-
SRC_URI="!vanilla? ( https://dev.gentoo.org/~perfinion/distfiles/policycoreutils-extra-${EXTRAS_VER}.tar.bz2 )"
20+
SRC_URI="https://dev.gentoo.org/~perfinion/distfiles/policycoreutils-extra-${EXTRAS_VER}.tar.bz2"
2121
S1="${WORKDIR}/${P}/${PN}"
2222
S2="${WORKDIR}/policycoreutils-extra"
2323
S="${S1}"
2424
else
2525
SRC_URI="https://github.com/SELinuxProject/selinux/releases/download/${MY_PV}/${MY_P}.tar.gz
26-
!vanilla? ( https://dev.gentoo.org/~perfinion/distfiles/policycoreutils-extra-${EXTRAS_VER}.tar.bz2 )"
27-
KEYWORDS="amd64 ~arm ~arm64 ~riscv x86"
26+
https://dev.gentoo.org/~perfinion/distfiles/policycoreutils-extra-${EXTRAS_VER}.tar.bz2"
27+
KEYWORDS="amd64 arm arm64 ~riscv x86"
2828
S1="${WORKDIR}/${MY_P}"
2929
S2="${WORKDIR}/policycoreutils-extra"
3030
S="${S1}"
3131
fi
3232

3333
LICENSE="GPL-2"
3434
SLOT="0"
35-
IUSE="audit pam split-usr vanilla +python"
36-
REQUIRED_USE="
37-
!vanilla? ( python ${PYTHON_REQUIRED_USE} )
38-
"
39-
40-
DEPEND="
41-
python? (
42-
>=sys-libs/libselinux-${PV}:=[python,${PYTHON_USEDEP}]
43-
>=sys-libs/libsemanage-${PV}:=[python(+),${PYTHON_USEDEP}]
44-
audit? ( >=sys-process/audit-1.5.1[python,${PYTHON_USEDEP}] )
45-
${PYTHON_DEPS}
46-
)
47-
!python? (
48-
>=sys-libs/libselinux-${PV}:=
49-
>=sys-libs/libsemanage-${PV}:=
50-
audit? ( >=sys-process/audit-1.5.1 )
51-
)
35+
IUSE="audit pam split-usr"
36+
REQUIRED_USE="${PYTHON_REQUIRED_USE}"
37+
38+
DEPEND=">=sys-libs/libselinux-${PV}:=[python,${PYTHON_USEDEP}]
39+
>=sys-libs/libsemanage-${PV}:=[python(+),${PYTHON_USEDEP}]
5240
>=sys-libs/libsepol-${PV}:=
5341
sys-libs/libcap-ng:=
42+
>=app-admin/setools-4.2.0[${PYTHON_USEDEP}]
43+
audit? ( >=sys-process/audit-1.5.1[python,${PYTHON_USEDEP}] )
5444
pam? ( sys-libs/pam:= )
55-
!vanilla? (
56-
>=app-admin/setools-4.2.0[${PYTHON_USEDEP}]
57-
)
58-
"
45+
${PYTHON_DEPS}"
5946

6047
# Avoid dependency loop in the cross-compile case, bug #755173
6148
# (Still exists in native)
@@ -66,7 +53,7 @@ RDEPEND="${DEPEND}
6653
app-misc/pax-utils"
6754

6855
PDEPEND="sys-apps/semodule-utils
69-
python? ( sys-apps/selinux-python )"
56+
sys-apps/selinux-python"
7057

7158
src_unpack() {
7259
# Override default one because we need the SRC_URI ones even in case of 9999 ebuilds
@@ -84,96 +71,69 @@ src_prepare() {
8471
eapply "${FILESDIR}/policycoreutils-3.1-0001-newrole-not-suid.patch"
8572
fi
8673

87-
if ! use vanilla; then
88-
# rlpkg is more useful than fixfiles
89-
sed -i -e '/^all/s/fixfiles//' "${S}/scripts/Makefile" \
90-
|| die "fixfiles sed 1 failed"
91-
sed -i -e '/fixfiles/d' "${S}/scripts/Makefile" \
92-
|| die "fixfiles sed 2 failed"
93-
fi
74+
# rlpkg is more useful than fixfiles
75+
sed -i -e '/^all/s/fixfiles//' "${S}/scripts/Makefile" \
76+
|| die "fixfiles sed 1 failed"
77+
sed -i -e '/fixfiles/d' "${S}/scripts/Makefile" \
78+
|| die "fixfiles sed 2 failed"
9479

9580
eapply_user
9681

9782
sed -i 's/-Werror//g' "${S1}"/*/Makefile || die "Failed to remove Werror"
9883

99-
if ! use vanilla; then
100-
python_copy_sources
101-
# Our extra code is outside the regular directory, so set it to the extra
102-
# directory. We really should optimize this as it is ugly, but the extra
103-
# code is needed for Gentoo at the same time that policycoreutils is present
104-
# (so we cannot use an additional package for now).
105-
S="${S2}"
106-
python_copy_sources
107-
fi
84+
python_copy_sources
85+
# Our extra code is outside the regular directory, so set it to the extra
86+
# directory. We really should optimize this as it is ugly, but the extra
87+
# code is needed for Gentoo at the same time that policycoreutils is present
88+
# (so we cannot use an additional package for now).
89+
S="${S2}"
90+
python_copy_sources
10891
}
10992

11093
src_compile() {
11194
building() {
112-
local build_dir=${1}
113-
emake -C "${build_dir}" \
95+
emake -C "${BUILD_DIR}" \
11496
AUDIT_LOG_PRIVS="y" \
11597
AUDITH="$(usex audit y n)" \
11698
PAMH="$(usex pam y n)" \
11799
SESANDBOX="n" \
118100
CC="$(tc-getCC)" \
119101
LIBDIR="\$(PREFIX)/$(get_libdir)"
120102
}
121-
if ! use vanilla; then
122-
building_with_python() {
123-
building "${BUILD_DIR}"
124-
}
125-
S="${S1}" # Regular policycoreutils
126-
python_foreach_impl building_with_python
127-
S="${S2}" # Extra set
128-
python_foreach_impl building_with_python
129-
unset -f building_with_python
130-
else
131-
S="${S1}" # Regular policycoreutils
132-
building "${S}"
133-
fi
134-
unset -f building
103+
S="${S1}" # Regular policycoreutils
104+
python_foreach_impl building
105+
S="${S2}" # Extra set
106+
python_foreach_impl building
135107
}
136108

137109
src_install() {
138-
installation-policycoreutils-base() {
139-
local build_dir=${1}
110+
# Python scripts are present in many places. There are no extension modules.
111+
installation-policycoreutils() {
140112
einfo "Installing policycoreutils"
141-
emake -C "${build_dir}" DESTDIR="${D}" \
113+
emake -C "${BUILD_DIR}" DESTDIR="${D}" \
142114
AUDIT_LOG_PRIVS="y" \
143115
AUDITH="$(usex audit y n)" \
144116
PAMH="$(usex pam y n)" \
145117
SESANDBOX="n" \
146118
CC="$(tc-getCC)" \
147119
LIBDIR="\$(PREFIX)/$(get_libdir)" \
148120
install
121+
python_optimize
149122
}
150123

151-
if ! use vanilla; then
152-
# Python scripts are present in many places. There are no extension modules.
153-
installation-policycoreutils() {
154-
installation-policycoreutils-base "${BUILD_DIR}"
155-
python_optimize
156-
}
157-
158-
installation-extras() {
159-
einfo "Installing policycoreutils-extra"
160-
emake -C "${BUILD_DIR}" \
161-
DESTDIR="${D}" \
162-
install
163-
python_optimize
164-
}
165-
166-
S="${S1}" # policycoreutils
167-
python_foreach_impl installation-policycoreutils
168-
S="${S2}" # extras
169-
python_foreach_impl installation-extras
170-
S="${S1}" # back for later
171-
unset -f installation-extras installation-policycoreutils
172-
else
173-
S="${S1}" # policycoreutils
174-
installation-policycoreutils-base "${S}"
175-
fi
176-
unset -f installation-policycoreutils-base
124+
installation-extras() {
125+
einfo "Installing policycoreutils-extra"
126+
emake -C "${BUILD_DIR}" \
127+
DESTDIR="${D}" \
128+
install
129+
python_optimize
130+
}
131+
132+
S="${S1}" # policycoreutils
133+
python_foreach_impl installation-policycoreutils
134+
S="${S2}" # extras
135+
python_foreach_impl installation-extras
136+
S="${S1}" # back for later
177137

178138
# remove redhat-style init script
179139
rm -fR "${D}/etc/rc.d" || die
@@ -192,12 +152,10 @@ src_install() {
192152
dodir /var/lib/selinux
193153
keepdir /var/lib/selinux
194154

195-
if ! use vanilla; then
196-
# Set version-specific scripts
197-
for pyscript in rlpkg; do
198-
python_replicate_script "${ED}/usr/sbin/${pyscript}"
199-
done
200-
fi
155+
# Set version-specific scripts
156+
for pyscript in rlpkg; do
157+
python_replicate_script "${ED}/usr/sbin/${pyscript}"
158+
done
201159
}
202160

203161
pkg_postinst() {
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# Copyright 1999-2025 Gentoo Authors
2+
# Distributed under the terms of the GNU General Public License v2
3+
4+
EAPI="8"
5+
PYTHON_COMPAT=( python3_{10..13} )
6+
PYTHON_REQ_USE="xml(+)"
7+
8+
inherit python-r1 toolchain-funcs bash-completion-r1
9+
10+
MY_PV="${PV//_/-}"
11+
MY_P="${PN}-${MY_PV}"
12+
EXTRAS_VER="1.37"
13+
14+
DESCRIPTION="SELinux core utilities"
15+
HOMEPAGE="https://github.com/SELinuxProject/selinux/wiki"
16+
17+
if [[ ${PV} == 9999 ]]; then
18+
inherit git-r3
19+
EGIT_REPO_URI="https://github.com/SELinuxProject/selinux.git"
20+
SRC_URI="https://dev.gentoo.org/~perfinion/distfiles/policycoreutils-extra-${EXTRAS_VER}.tar.bz2"
21+
S1="${WORKDIR}/${P}/${PN}"
22+
S2="${WORKDIR}/policycoreutils-extra"
23+
S="${S1}"
24+
else
25+
SRC_URI="https://github.com/SELinuxProject/selinux/releases/download/${MY_PV}/${MY_P}.tar.gz
26+
https://dev.gentoo.org/~perfinion/distfiles/policycoreutils-extra-${EXTRAS_VER}.tar.bz2"
27+
KEYWORDS="~amd64 ~arm ~arm64 ~x86"
28+
S1="${WORKDIR}/${MY_P}"
29+
S2="${WORKDIR}/policycoreutils-extra"
30+
S="${S1}"
31+
fi
32+
33+
LICENSE="GPL-2"
34+
SLOT="0"
35+
IUSE="audit pam split-usr"
36+
REQUIRED_USE="${PYTHON_REQUIRED_USE}"
37+
38+
DEPEND=">=sys-libs/libselinux-${PV}:=[python,${PYTHON_USEDEP}]
39+
>=sys-libs/libsemanage-${PV}:=[python(+),${PYTHON_USEDEP}]
40+
>=sys-libs/libsepol-${PV}:=
41+
sys-libs/libcap-ng:=
42+
>=app-admin/setools-4.2.0[${PYTHON_USEDEP}]
43+
audit? ( >=sys-process/audit-1.5.1[python,${PYTHON_USEDEP}] )
44+
pam? ( sys-libs/pam:= )
45+
${PYTHON_DEPS}"
46+
47+
# Avoid dependency loop in the cross-compile case, bug #755173
48+
# (Still exists in native)
49+
BDEPEND="sys-devel/gettext"
50+
51+
# pax-utils for scanelf used by rlpkg
52+
RDEPEND="${DEPEND}
53+
app-misc/pax-utils"
54+
55+
PDEPEND="sys-apps/semodule-utils
56+
sys-apps/selinux-python"
57+
58+
src_unpack() {
59+
# Override default one because we need the SRC_URI ones even in case of 9999 ebuilds
60+
default
61+
if [[ ${PV} == 9999 ]] ; then
62+
git-r3_src_unpack
63+
fi
64+
}
65+
66+
src_prepare() {
67+
S="${S1}"
68+
cd "${S}" || die "Failed to switch to ${S}"
69+
if [[ ${PV} != 9999 ]] ; then
70+
# If needed for live ebuilds please use /etc/portage/patches
71+
eapply "${FILESDIR}/policycoreutils-3.1-0001-newrole-not-suid.patch"
72+
fi
73+
74+
# rlpkg is more useful than fixfiles
75+
sed -i -e '/^all/s/fixfiles//' "${S}/scripts/Makefile" \
76+
|| die "fixfiles sed 1 failed"
77+
sed -i -e '/fixfiles/d' "${S}/scripts/Makefile" \
78+
|| die "fixfiles sed 2 failed"
79+
80+
eapply_user
81+
82+
sed -i 's/-Werror//g' "${S1}"/*/Makefile || die "Failed to remove Werror"
83+
84+
python_copy_sources
85+
# Our extra code is outside the regular directory, so set it to the extra
86+
# directory. We really should optimize this as it is ugly, but the extra
87+
# code is needed for Gentoo at the same time that policycoreutils is present
88+
# (so we cannot use an additional package for now).
89+
S="${S2}"
90+
python_copy_sources
91+
}
92+
93+
src_compile() {
94+
building() {
95+
emake -C "${BUILD_DIR}" \
96+
AUDIT_LOG_PRIVS="y" \
97+
AUDITH="$(usex audit y n)" \
98+
PAMH="$(usex pam y n)" \
99+
SESANDBOX="n" \
100+
CC="$(tc-getCC)" \
101+
LIBDIR="\$(PREFIX)/$(get_libdir)"
102+
}
103+
S="${S1}" # Regular policycoreutils
104+
python_foreach_impl building
105+
S="${S2}" # Extra set
106+
python_foreach_impl building
107+
}
108+
109+
src_install() {
110+
# Python scripts are present in many places. There are no extension modules.
111+
installation-policycoreutils() {
112+
einfo "Installing policycoreutils"
113+
emake -C "${BUILD_DIR}" DESTDIR="${D}" \
114+
AUDIT_LOG_PRIVS="y" \
115+
AUDITH="$(usex audit y n)" \
116+
PAMH="$(usex pam y n)" \
117+
SESANDBOX="n" \
118+
CC="$(tc-getCC)" \
119+
LIBDIR="\$(PREFIX)/$(get_libdir)" \
120+
install
121+
python_optimize
122+
}
123+
124+
installation-extras() {
125+
einfo "Installing policycoreutils-extra"
126+
emake -C "${BUILD_DIR}" \
127+
DESTDIR="${D}" \
128+
install
129+
python_optimize
130+
}
131+
132+
S="${S1}" # policycoreutils
133+
python_foreach_impl installation-policycoreutils
134+
S="${S2}" # extras
135+
python_foreach_impl installation-extras
136+
S="${S1}" # back for later
137+
138+
# remove redhat-style init script
139+
rm -fR "${D}/etc/rc.d" || die
140+
141+
# compatibility symlinks
142+
if use split-usr; then
143+
dosym ../../sbin/setfiles /usr/sbin/setfiles
144+
else
145+
# remove sestatus symlink
146+
rm -f "${D}"/usr/sbin/sestatus || die
147+
fi
148+
149+
bashcomp_alias setsebool getsebool
150+
151+
# location for policy definitions
152+
dodir /var/lib/selinux
153+
keepdir /var/lib/selinux
154+
155+
# Set version-specific scripts
156+
for pyscript in rlpkg; do
157+
python_replicate_script "${ED}/usr/sbin/${pyscript}"
158+
done
159+
}
160+
161+
pkg_postinst() {
162+
for POLICY_TYPE in ${POLICY_TYPES} ; do
163+
# There have been some changes to the policy store, rebuilding now.
164+
# https://marc.info/?l=selinux&m=143757277819717&w=2
165+
einfo "Rebuilding store ${POLICY_TYPE} in '${ROOT:-/}' (without re-loading)."
166+
semodule -p "${ROOT:-/}" -s "${POLICY_TYPE}" -n -B || die "Failed to rebuild policy store ${POLICY_TYPE}"
167+
done
168+
}

0 commit comments

Comments
 (0)