1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python{2_7,3_3,3_4} )
9 inherit multilib python-r1 toolchain-funcs eutils bash-completion-r1
13 MY_RELEASEDATE="20150202"
21 DESCRIPTION="SELinux core utilities"
22 HOMEPAGE="https://github.com/SELinuxProject/selinux/wiki"
24 if [[ ${PV} == 9999 ]] ; then
26 EGIT_REPO_URI="https://github.com/SELinuxProject/selinux.git"
27 SRC_URI="https://dev.gentoo.org/~perfinion/distfiles/policycoreutils-extra-${EXTRAS_VER}.tar.bz2"
28 S1="${WORKDIR}/${MY_P}/${PN}"
29 S2="${WORKDIR}/policycoreutils-extra"
32 SRC_URI="https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/${MY_RELEASEDATE}/${MY_P}.tar.gz
33 https://dev.gentoo.org/~perfinion/distfiles/policycoreutils-extra-${EXTRAS_VER}.tar.bz2"
34 KEYWORDS="~amd64 ~x86"
35 S1="${WORKDIR}/${MY_P}"
36 S2="${WORKDIR}/policycoreutils-extra"
43 DEPEND=">=sys-libs/libselinux-${SELNX_VER}:=[python]
45 >=sys-libs/libcap-1.10-r10:=
46 >=sys-libs/libsemanage-${SEMNG_VER}:=[python]
48 >=sys-libs/libsepol-${SEPOL_VER}:=
50 dev-python/ipy[${PYTHON_USEDEP}]
55 audit? ( >=sys-process/audit-1.5.1 )
56 pam? ( sys-libs/pam:= )
59 ### libcgroup -> seunshare
60 ### dbus -> restorecond
62 # pax-utils for scanelf used by rlpkg
66 !<sys-apps/openrc-0.14"
69 # Override default one because we need the SRC_URI ones even in case of 9999 ebuilds
70 if [[ ${PV} == 9999 ]] ; then
81 cd "${S}" || die "Failed to switch to ${S}"
82 if [[ ${PV} != 9999 ]] ; then
83 # If needed for live ebuilds please use /etc/portage/patches
84 epatch "${FILESDIR}/0010-remove-sesandbox-support.patch"
85 epatch "${FILESDIR}/0020-disable-autodetection-of-pam-and-audit.patch"
86 epatch "${FILESDIR}/0030-make-inotify-check-use-flag-triggered.patch"
87 epatch "${FILESDIR}/0040-reverse-access-check-in-run_init.patch"
88 epatch "${FILESDIR}/0070-remove-symlink-attempt-fails-with-gentoo-sandbox-approach.patch"
89 epatch "${FILESDIR}/0110-build-mcstrans-bug-472912.patch"
90 epatch "${FILESDIR}/0120-build-failure-for-mcscolor-for-CONTEXT__CONTAINS.patch"
93 # rlpkg is more useful than fixfiles
94 sed -i -e '/^all/s/fixfiles//' "${S}/scripts/Makefile" \
95 || die "fixfiles sed 1 failed"
96 sed -i -e '/fixfiles/d' "${S}/scripts/Makefile" \
97 || die "fixfiles sed 2 failed"
101 sed -i 's/-Werror//g' "${S1}"/*/Makefile || die "Failed to remove Werror"
104 # Our extra code is outside the regular directory, so set it to the extra
105 # directory. We really should optimize this as it is ugly, but the extra
106 # code is needed for Gentoo at the same time that policycoreutils is present
107 # (so we cannot use an additional package for now).
114 emake -C "${BUILD_DIR}" \
115 AUDIT_LOG_PRIVS="y" \
116 AUDITH="$(usex audit)" \
118 INOTIFYH="$(usex dbus)" \
121 PYLIBVER="${EPYTHON}" \
122 LIBDIR="\$(PREFIX)/$(get_libdir)"
124 S="${S1}" # Regular policycoreutils
125 python_foreach_impl building
126 S="${S2}" # Extra set
127 python_foreach_impl building
131 # Python scripts are present in many places. There are no extension modules.
132 installation-policycoreutils() {
133 einfo "Installing policycoreutils"
134 emake -C "${BUILD_DIR}" DESTDIR="${D}" \
135 AUDITH="$(usex audit)" \
137 INOTIFYH="$(usex dbus)" \
140 PYLIBVER="${EPYTHON}" \
141 LIBDIR="\$(PREFIX)/$(get_libdir)" \
146 installation-extras() {
147 einfo "Installing policycoreutils-extra"
148 emake -C "${BUILD_DIR}" DESTDIR="${D}" INOTIFYH="$(usex dbus)" SHLIBDIR="${D}$(get_libdir)/rc" install
152 S="${S1}" # policycoreutils
153 python_foreach_impl installation-policycoreutils
155 python_foreach_impl installation-extras
156 S="${S1}" # back for later
158 # remove redhat-style init script
159 rm -fR "${D}/etc/rc.d" || die
161 # compatibility symlinks
162 dosym /sbin/setfiles /usr/sbin/setfiles
163 bashcomp_alias setsebool getsebool
165 # location for policy definitions
166 dodir /var/lib/selinux
167 keepdir /var/lib/selinux
169 # Set version-specific scripts
170 for pyscript in audit2allow sepolgen-ifgen sepolicy chcat; do
171 python_replicate_script "${ED}/usr/bin/${pyscript}"
173 for pyscript in semanage rlpkg; do
174 python_replicate_script "${ED}/usr/sbin/${pyscript}"
177 dodir /usr/share/doc/${PF}/mcstrans/examples
178 cp -dR "${S1}"/mcstrans/share/examples/* "${D}/usr/share/doc/${PF}/mcstrans/examples" || die
182 # The selinux_gentoo init script is no longer needed with recent OpenRC
183 elog "The selinux_gentoo init script has been removed in this version as it is not required after OpenRC 0.13."
185 for POLICY_TYPE in ${POLICY_TYPES} ; do
186 # There have been some changes to the policy store, rebuilding now.
187 # https://marc.info/?l=selinux&m=143757277819717&w=2
188 einfo "Rebuilding store ${POLICY_TYPE} (without re-loading)."
189 semodule -s "${POLICY_TYPE}" -n -B || die "Failed to rebuild policy store ${POLICY_TYPE}"