Skip to content

Commit d67b16b

Browse files
committed
sys-apps/selinux-python: Add from Gentoo
It's from Gentoo commit 4d201521b008785972a1f31e1284ecb847dc3831.
1 parent 6514fcc commit d67b16b

File tree

5 files changed

+369
-0
lines changed

5 files changed

+369
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DIST selinux-python-3.7.tar.gz 3652377 BLAKE2B 59fd7cab0034c175f42f6120ba665701945adcbd4e8af97a0dc2a1c79688a596b199528886ceea079a3f7a969258611fb660449d313d9e893de381293e786381 SHA512 036bc1f0e64cbbaade592dc7899a92765a0bac426140d7d3960f73bad6eb5f95d79d91e0f0e1604f88a991ebf59c4c90ccaaa4158f5dc4d3275ca2aed1673b09
2+
DIST selinux-python-3.8.1.tar.gz 3652823 BLAKE2B dde6081f55d646a6993083a000524b4ce834718f7cd555c8be88574f227f3d8ed24f390dc4568f3f66c1f3643a606779b6350ad28dfbfe2a1bd9d5a6798c37e0 SHA512 bad791411cff373cf749302d44205495a9d100ca6140ea895cb87a85f5d0b0cfaaf4b7418fca661fb3233d14951755d1c2d85961c731243c92622fdfb343734a
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
3+
<pkgmetadata>
4+
<maintainer type="project">
5+
<email>[email protected]</email>
6+
<name>SELinux Team</name>
7+
</maintainer>
8+
<longdescription>
9+
selinux-python contains the core python selinux utilities and libraries
10+
that are required for basic operation of a SELinux system. These
11+
include semanage, sepolicy and sepolgen.
12+
</longdescription>
13+
<upstream>
14+
<remote-id type="github">SELinuxProject/selinux</remote-id>
15+
</upstream>
16+
</pkgmetadata>
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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..12} )
6+
PYTHON_REQ_USE="xml(+)"
7+
8+
inherit python-r1 toolchain-funcs
9+
10+
MY_PV="${PV//_/-}"
11+
MY_P="${PN}-${MY_PV}"
12+
13+
DESCRIPTION="SELinux core utilities"
14+
HOMEPAGE="https://github.com/SELinuxProject/selinux/wiki"
15+
16+
if [[ ${PV} == 9999 ]] ; then
17+
inherit git-r3
18+
EGIT_REPO_URI="https://github.com/SELinuxProject/selinux.git"
19+
S="${WORKDIR}/${P}/${PN#selinux-}"
20+
else
21+
SRC_URI="https://github.com/SELinuxProject/selinux/releases/download/${MY_PV}/${MY_P}.tar.gz"
22+
KEYWORDS="amd64 arm arm64 ~riscv x86"
23+
S="${WORKDIR}/${MY_P}"
24+
fi
25+
26+
LICENSE="GPL-2"
27+
SLOT="0"
28+
IUSE="test"
29+
RESTRICT="!test? ( test )"
30+
REQUIRED_USE="${PYTHON_REQUIRED_USE}"
31+
32+
RDEPEND=">=sys-libs/libselinux-${PV}:=[python]
33+
>=sys-libs/libsemanage-${PV}:=[python(+)]
34+
>=sys-libs/libsepol-${PV}:=[static-libs(+)]
35+
>=app-admin/setools-4.2.0[${PYTHON_USEDEP}]
36+
>=sys-process/audit-1.5.1[python,${PYTHON_USEDEP}]
37+
${PYTHON_DEPS}"
38+
DEPEND="${RDEPEND}"
39+
BDEPEND="
40+
test? (
41+
${RDEPEND}
42+
>=sys-apps/secilc-${PV}
43+
)"
44+
45+
src_prepare() {
46+
default
47+
sed -i 's/-Werror//g' "${S}"/*/Makefile || die "Failed to remove Werror"
48+
49+
python_copy_sources
50+
}
51+
52+
src_compile() {
53+
building() {
54+
emake -C "${BUILD_DIR}" \
55+
CC="$(tc-getCC)" \
56+
LIBDIR="\$(PREFIX)/$(get_libdir)"
57+
}
58+
python_foreach_impl building
59+
}
60+
61+
src_test() {
62+
testing() {
63+
# The different subprojects have some interproject dependencies:
64+
# - audit2allow depens on sepolgen
65+
# - chcat depends on semanage
66+
# and maybe others.
67+
# Add all the modules of the individual subprojects to the
68+
# PYTHONPATH, so they get actually found and used. In
69+
# particular, already installed versions on the system are not
70+
# used.
71+
for dir in audit2allow chcat semanage sepolgen/src sepolicy ; do
72+
PYTHONPATH="${BUILD_DIR}/${dir}:${PYTHONPATH}"
73+
done
74+
PYTHONPATH=${PYTHONPATH} \
75+
emake -C "${BUILD_DIR}" \
76+
test
77+
}
78+
python_foreach_impl testing
79+
}
80+
81+
src_install() {
82+
installation() {
83+
emake -C "${BUILD_DIR}" \
84+
DESTDIR="${D}" \
85+
LIBDIR="\$(PREFIX)/$(get_libdir)" \
86+
install
87+
python_optimize
88+
}
89+
python_foreach_impl installation
90+
91+
# Set version-specific scripts
92+
for pyscript in audit2allow sepolgen-ifgen sepolicy chcat; do
93+
python_replicate_script "${ED}/usr/bin/${pyscript}"
94+
done
95+
for pyscript in semanage; do
96+
python_replicate_script "${ED}/usr/sbin/${pyscript}"
97+
done
98+
99+
# Create sepolgen.conf with different devel location definition
100+
mkdir -p "${D}"/etc/selinux || die "Failed to create selinux directory";
101+
if [[ -f /etc/selinux/config ]];
102+
then
103+
local selinuxtype=$(awk -F'=' '/^SELINUXTYPE/ {print $2}' /etc/selinux/config);
104+
echo "SELINUX_DEVEL_PATH=/usr/share/selinux/${selinuxtype}/include:/usr/share/selinux/${selinuxtype}" \
105+
> "${D}"/etc/selinux/sepolgen.conf || die "Failed to generate sepolgen"
106+
else
107+
local selinuxtype="${POLICY_TYPES%% *}";
108+
if [[ -n "${selinuxtype}" ]];
109+
then
110+
echo "SELINUX_DEVEL_PATH=/usr/share/selinux/${selinuxtype}/include:/usr/share/selinux/${selinuxtype}" \
111+
> "${D}"/etc/selinux/sepolgen.conf || die "Failed to generate sepolgen"
112+
else
113+
echo "SELINUX_DEVEL_PATH=/usr/share/selinux/strict/include:/usr/share/selinux/strict" \
114+
> "${D}"/etc/selinux/sepolgen.conf || die "Failed to generate sepolgen"
115+
fi
116+
fi
117+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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
9+
10+
MY_PV="${PV//_/-}"
11+
MY_P="${PN}-${MY_PV}"
12+
13+
DESCRIPTION="SELinux core utilities"
14+
HOMEPAGE="https://github.com/SELinuxProject/selinux/wiki"
15+
16+
if [[ ${PV} == 9999 ]] ; then
17+
inherit git-r3
18+
EGIT_REPO_URI="https://github.com/SELinuxProject/selinux.git"
19+
S="${WORKDIR}/${P}/${PN#selinux-}"
20+
else
21+
SRC_URI="https://github.com/SELinuxProject/selinux/releases/download/${MY_PV}/${MY_P}.tar.gz"
22+
KEYWORDS="~amd64 ~arm ~arm64 ~x86"
23+
S="${WORKDIR}/${MY_P}"
24+
fi
25+
26+
LICENSE="GPL-2"
27+
SLOT="0"
28+
IUSE="test"
29+
RESTRICT="!test? ( test )"
30+
REQUIRED_USE="${PYTHON_REQUIRED_USE}"
31+
32+
RDEPEND=">=sys-libs/libselinux-${PV}:=[python]
33+
>=sys-libs/libsemanage-${PV}:=[python(+)]
34+
>=sys-libs/libsepol-${PV}:=[static-libs(+)]
35+
>=app-admin/setools-4.2.0[${PYTHON_USEDEP}]
36+
>=sys-process/audit-1.5.1[python,${PYTHON_USEDEP}]
37+
${PYTHON_DEPS}"
38+
DEPEND="${RDEPEND}"
39+
BDEPEND="
40+
test? (
41+
${RDEPEND}
42+
>=sys-apps/secilc-${PV}
43+
)"
44+
45+
src_prepare() {
46+
default
47+
sed -i 's/-Werror//g' "${S}"/*/Makefile || die "Failed to remove Werror"
48+
49+
python_copy_sources
50+
}
51+
52+
src_compile() {
53+
building() {
54+
emake -C "${BUILD_DIR}" \
55+
CC="$(tc-getCC)" \
56+
LIBDIR="\$(PREFIX)/$(get_libdir)"
57+
}
58+
python_foreach_impl building
59+
}
60+
61+
src_test() {
62+
testing() {
63+
# The different subprojects have some interproject dependencies:
64+
# - audit2allow depens on sepolgen
65+
# - chcat depends on semanage
66+
# and maybe others.
67+
# Add all the modules of the individual subprojects to the
68+
# PYTHONPATH, so they get actually found and used. In
69+
# particular, already installed versions on the system are not
70+
# used.
71+
for dir in audit2allow chcat semanage sepolgen/src sepolicy ; do
72+
PYTHONPATH="${BUILD_DIR}/${dir}:${PYTHONPATH}"
73+
done
74+
PYTHONPATH=${PYTHONPATH} \
75+
emake -C "${BUILD_DIR}" \
76+
test
77+
}
78+
python_foreach_impl testing
79+
}
80+
81+
src_install() {
82+
installation() {
83+
emake -C "${BUILD_DIR}" \
84+
DESTDIR="${D}" \
85+
LIBDIR="\$(PREFIX)/$(get_libdir)" \
86+
install
87+
python_optimize
88+
}
89+
python_foreach_impl installation
90+
91+
# Set version-specific scripts
92+
for pyscript in audit2allow sepolgen-ifgen sepolicy chcat; do
93+
python_replicate_script "${ED}/usr/bin/${pyscript}"
94+
done
95+
for pyscript in semanage; do
96+
python_replicate_script "${ED}/usr/sbin/${pyscript}"
97+
done
98+
99+
# Create sepolgen.conf with different devel location definition
100+
mkdir -p "${D}"/etc/selinux || die "Failed to create selinux directory";
101+
if [[ -f /etc/selinux/config ]];
102+
then
103+
local selinuxtype=$(awk -F'=' '/^SELINUXTYPE/ {print $2}' /etc/selinux/config);
104+
echo "SELINUX_DEVEL_PATH=/usr/share/selinux/${selinuxtype}/include:/usr/share/selinux/${selinuxtype}" \
105+
> "${D}"/etc/selinux/sepolgen.conf || die "Failed to generate sepolgen"
106+
else
107+
local selinuxtype="${POLICY_TYPES%% *}";
108+
if [[ -n "${selinuxtype}" ]];
109+
then
110+
echo "SELINUX_DEVEL_PATH=/usr/share/selinux/${selinuxtype}/include:/usr/share/selinux/${selinuxtype}" \
111+
> "${D}"/etc/selinux/sepolgen.conf || die "Failed to generate sepolgen"
112+
else
113+
echo "SELINUX_DEVEL_PATH=/usr/share/selinux/strict/include:/usr/share/selinux/strict" \
114+
> "${D}"/etc/selinux/sepolgen.conf || die "Failed to generate sepolgen"
115+
fi
116+
fi
117+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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
9+
10+
MY_PV="${PV//_/-}"
11+
MY_P="${PN}-${MY_PV}"
12+
13+
DESCRIPTION="SELinux core utilities"
14+
HOMEPAGE="https://github.com/SELinuxProject/selinux/wiki"
15+
16+
if [[ ${PV} == 9999 ]] ; then
17+
inherit git-r3
18+
EGIT_REPO_URI="https://github.com/SELinuxProject/selinux.git"
19+
S="${WORKDIR}/${P}/${PN#selinux-}"
20+
else
21+
SRC_URI="https://github.com/SELinuxProject/selinux/releases/download/${MY_PV}/${MY_P}.tar.gz"
22+
KEYWORDS="~amd64 ~arm ~arm64 ~x86"
23+
S="${WORKDIR}/${MY_P}"
24+
fi
25+
26+
LICENSE="GPL-2"
27+
SLOT="0"
28+
IUSE="test"
29+
RESTRICT="!test? ( test )"
30+
REQUIRED_USE="${PYTHON_REQUIRED_USE}"
31+
32+
RDEPEND=">=sys-libs/libselinux-${PV}:=[python]
33+
>=sys-libs/libsemanage-${PV}:=[python(+)]
34+
>=sys-libs/libsepol-${PV}:=[static-libs(+)]
35+
>=app-admin/setools-4.2.0[${PYTHON_USEDEP}]
36+
>=sys-process/audit-1.5.1[python,${PYTHON_USEDEP}]
37+
${PYTHON_DEPS}"
38+
DEPEND="${RDEPEND}"
39+
BDEPEND="
40+
test? (
41+
${RDEPEND}
42+
>=sys-apps/secilc-${PV}
43+
)"
44+
45+
src_prepare() {
46+
default
47+
sed -i 's/-Werror//g' "${S}"/*/Makefile || die "Failed to remove Werror"
48+
49+
python_copy_sources
50+
}
51+
52+
src_compile() {
53+
building() {
54+
emake -C "${BUILD_DIR}" \
55+
CC="$(tc-getCC)" \
56+
LIBDIR="\$(PREFIX)/$(get_libdir)"
57+
}
58+
python_foreach_impl building
59+
}
60+
61+
src_test() {
62+
testing() {
63+
# The different subprojects have some interproject dependencies:
64+
# - audit2allow depens on sepolgen
65+
# - chcat depends on semanage
66+
# and maybe others.
67+
# Add all the modules of the individual subprojects to the
68+
# PYTHONPATH, so they get actually found and used. In
69+
# particular, already installed versions on the system are not
70+
# used.
71+
for dir in audit2allow chcat semanage sepolgen/src sepolicy ; do
72+
PYTHONPATH="${BUILD_DIR}/${dir}:${PYTHONPATH}"
73+
done
74+
PYTHONPATH=${PYTHONPATH} \
75+
emake -C "${BUILD_DIR}" \
76+
test
77+
}
78+
python_foreach_impl testing
79+
}
80+
81+
src_install() {
82+
installation() {
83+
emake -C "${BUILD_DIR}" \
84+
DESTDIR="${D}" \
85+
LIBDIR="\$(PREFIX)/$(get_libdir)" \
86+
install
87+
python_optimize
88+
}
89+
python_foreach_impl installation
90+
91+
# Set version-specific scripts
92+
for pyscript in audit2allow sepolgen-ifgen sepolicy chcat; do
93+
python_replicate_script "${ED}/usr/bin/${pyscript}"
94+
done
95+
for pyscript in semanage; do
96+
python_replicate_script "${ED}/usr/sbin/${pyscript}"
97+
done
98+
99+
# Create sepolgen.conf with different devel location definition
100+
mkdir -p "${D}"/etc/selinux || die "Failed to create selinux directory";
101+
if [[ -f /etc/selinux/config ]];
102+
then
103+
local selinuxtype=$(awk -F'=' '/^SELINUXTYPE/ {print $2}' /etc/selinux/config);
104+
echo "SELINUX_DEVEL_PATH=/usr/share/selinux/${selinuxtype}/include:/usr/share/selinux/${selinuxtype}" \
105+
> "${D}"/etc/selinux/sepolgen.conf || die "Failed to generate sepolgen"
106+
else
107+
local selinuxtype="${POLICY_TYPES%% *}";
108+
if [[ -n "${selinuxtype}" ]];
109+
then
110+
echo "SELINUX_DEVEL_PATH=/usr/share/selinux/${selinuxtype}/include:/usr/share/selinux/${selinuxtype}" \
111+
> "${D}"/etc/selinux/sepolgen.conf || die "Failed to generate sepolgen"
112+
else
113+
echo "SELINUX_DEVEL_PATH=/usr/share/selinux/strict/include:/usr/share/selinux/strict" \
114+
> "${D}"/etc/selinux/sepolgen.conf || die "Failed to generate sepolgen"
115+
fi
116+
fi
117+
}

0 commit comments

Comments
 (0)