*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / sys-apps / selinux-python / selinux-python-2.9.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="6"
5 PYTHON_COMPAT=( python3_6 )
6 PYTHON_REQ_USE="xml"
7
8 inherit python-r1 toolchain-funcs
9
10 MY_P="${P//_/-}"
11
12 MY_RELEASEDATE="20190315"
13 SEPOL_VER="${PV}"
14 SELNX_VER="${PV}"
15 SEMNG_VER="${PV}"
16
17 IUSE=""
18 REQUIRED_USE="${PYTHON_REQUIRED_USE}"
19
20 DESCRIPTION="SELinux core utilities"
21 HOMEPAGE="https://github.com/SELinuxProject/selinux/wiki"
22
23 if [[ ${PV} == 9999 ]] ; then
24         inherit git-r3
25         EGIT_REPO_URI="https://github.com/SELinuxProject/selinux.git"
26         S="${WORKDIR}/${MY_P}/${PN#selinux-}"
27 else
28         SRC_URI="https://github.com/SELinuxProject/selinux/releases/download/${MY_RELEASEDATE}/${MY_P}.tar.gz"
29         KEYWORDS="amd64 ~arm64 ~mips x86"
30         S="${WORKDIR}/${MY_P}"
31 fi
32
33 LICENSE="GPL-2"
34 SLOT="0"
35
36 DEPEND=">=sys-libs/libselinux-${SELNX_VER}:=[python]
37         >=sys-libs/libsemanage-${SEMNG_VER}:=[python]
38         >=sys-libs/libsepol-${SEPOL_VER}:=
39         >=app-admin/setools-4.2.0[${PYTHON_USEDEP}]
40         dev-python/ipy[${PYTHON_USEDEP}]
41         !dev-python/sepolgen
42         ${PYTHON_DEPS}"
43
44 RDEPEND="${DEPEND}"
45
46 src_prepare() {
47         default
48         sed -i 's/-Werror//g' "${S}"/*/Makefile || die "Failed to remove Werror"
49
50         python_copy_sources
51 }
52
53 src_compile() {
54         building() {
55                 emake -C "${BUILD_DIR}" \
56                         CC="$(tc-getCC)" \
57                         LIBDIR="\$(PREFIX)/$(get_libdir)"
58         }
59         python_foreach_impl building
60 }
61
62 src_install() {
63         installation() {
64                 emake -C "${BUILD_DIR}" \
65                         DESTDIR="${D}" \
66                         LIBDIR="\$(PREFIX)/$(get_libdir)" \
67                         install
68                 python_optimize
69         }
70         python_foreach_impl installation
71
72         # Set version-specific scripts
73         for pyscript in audit2allow sepolgen-ifgen sepolicy chcat; do
74                 python_replicate_script "${ED}/usr/bin/${pyscript}"
75         done
76         for pyscript in semanage; do
77                 python_replicate_script "${ED}/usr/sbin/${pyscript}"
78         done
79
80         # Create sepolgen.conf with different devel location definition
81         if [[ -f /etc/selinux/config ]];
82         then
83                 local selinuxtype=$(awk -F'=' '/^SELINUXTYPE/ {print $2}' /etc/selinux/config);
84                 mkdir -p "${D}"/etc/selinux || die "Failed to create selinux directory";
85                 echo "SELINUX_DEVEL_PATH=/usr/share/selinux/${selinuxtype}/include:/usr/share/selinux/${selinuxtype}" > "${D}"/etc/selinux/sepolgen.conf;
86         else
87                 local selinuxtype="${POLICY_TYPES%% *}";
88                 if [[ -n "${selinuxtype}" ]];
89                 then
90                         echo "SELINUX_DEVEL_PATH=/usr/share/selinux/${selinuxtype}/include:/usr/share/selinux/${selinuxtype}" > "${D}"/etc/selinux/sepolgen.conf;
91                 else
92                         echo "SELINUX_DEVEL_PATH=/usr/share/selinux/strict/include:/usr/share/selinux/strict" > "${D}"/etc/selinux/sepolgen.conf;
93                 fi
94         fi
95 }