Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

selinux: update eclass, libsepol to 3.1 and semodule-utils #172

Merged
merged 6 commits into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions acct-group/messagebus/messagebus-0-r1.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2019-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit acct-group

ACCT_GROUP_ID=101
7 changes: 7 additions & 0 deletions acct-group/messagebus/metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="project">
<email>freedesktop-bugs@gentoo.org</email>
</maintainer>
</pkgmetadata>
11 changes: 11 additions & 0 deletions acct-user/messagebus/messagebus-0-r1.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2019-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit acct-user

ACCT_USER_ID=101
ACCT_USER_GROUPS=( messagebus )

acct-user_add_deps
7 changes: 7 additions & 0 deletions acct-user/messagebus/metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="project">
<email>freedesktop-bugs@gentoo.org</email>
</maintainer>
</pkgmetadata>
62 changes: 23 additions & 39 deletions eclass/selinux-policy-2.eclass
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 1999-2015 Gentoo Foundation
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Eclass for installing SELinux policy, and optionally
Expand All @@ -7,7 +7,7 @@
# @ECLASS: selinux-policy-2.eclass
# @MAINTAINER:
# selinux@gentoo.org
# @SUPPORTED_EAPIS: 5 6
# @SUPPORTED_EAPIS: 6 7
# @BLURB: This eclass supports the deployment of the various SELinux modules in sec-policy
# @DESCRIPTION:
# The selinux-policy-2.eclass supports deployment of the various SELinux modules
Expand Down Expand Up @@ -75,8 +75,8 @@
: ${SELINUX_GIT_BRANCH:="master"};

case "${EAPI:-0}" in
0|1|2|3|4) die "EAPI<5 is not supported";;
5|6) : ;;
0|1|2|3|4|5) die "EAPI<6 is not supported";;
6|7) : ;;
*) die "unknown EAPI" ;;
esac

Expand All @@ -87,10 +87,6 @@ case ${BASEPOL} in
EGIT_CHECKOUT_DIR="${WORKDIR}/refpolicy";;
esac

if [[ ${EAPI:-0} == 5 ]]; then
inherit eutils
fi

IUSE=""

HOMEPAGE="https://wiki.gentoo.org/wiki/Project:SELinux"
Expand All @@ -117,9 +113,15 @@ else
RDEPEND=">=sys-apps/policycoreutils-2.0.82
>=sec-policy/selinux-base-policy-${PV}"
fi
DEPEND="${RDEPEND}
sys-devel/m4
>=sys-apps/checkpolicy-2.0.21"
if [[ ${EAPI} == 6 ]]; then
DEPEND="${RDEPEND}
sys-devel/m4
>=sys-apps/checkpolicy-2.0.21"
else
DEPEND="${RDEPEND}"
BDEPEND="sys-devel/m4
>=sys-apps/checkpolicy-2.0.21"
fi

EXPORT_FUNCTIONS src_unpack src_prepare src_compile src_install pkg_postinst pkg_postrm

Expand Down Expand Up @@ -156,25 +158,13 @@ selinux-policy-2_src_prepare() {
# Patch the sources with the base patchbundle
if [[ -n ${BASEPOL} ]] && [[ "${BASEPOL}" != "9999" ]]; then
cd "${S}"
if [[ ${EAPI:-0} == 5 ]]; then
EPATCH_MULTI_MSG="Applying SELinux policy updates ... " \
EPATCH_SUFFIX="patch" \
EPATCH_SOURCE="${WORKDIR}" \
EPATCH_FORCE="yes" \
epatch
else
einfo "Applying SELinux policy updates ... "
eapply -p0 "${WORKDIR}/0001-full-patch-against-stable-release.patch"
fi
einfo "Applying SELinux policy updates ... "
eapply -p0 "${WORKDIR}/0001-full-patch-against-stable-release.patch"
fi

# Call in epatch_user. We do this early on as we start moving
# Call in eapply_user. We do this early on as we start moving
# files left and right hereafter.
if [[ ${EAPI:-0} == 5 ]]; then
epatch_user
else
eapply_user
fi
eapply_user

# Copy additional files to the 3rd_party/ location
if [[ "$(declare -p POLICY_FILES 2>/dev/null 2>&1)" == "declare -a"* ]] ||
Expand All @@ -189,18 +179,12 @@ selinux-policy-2_src_prepare() {

# Apply the additional patches refered to by the module ebuild.
# But first some magic to differentiate between bash arrays and strings
if [[ "$(declare -p POLICY_PATCH 2>/dev/null 2>&1)" == "declare -a"* ]] ||
[[ -n ${POLICY_PATCH} ]]; then
cd "${S}/refpolicy/policy/modules"
for POLPATCH in ${POLICY_PATCH[@]};
do
if [[ ${EAPI:-0} == 5 ]]; then
epatch "${POLPATCH}"
else
eapply "${POLPATCH}"
fi
done
fi
cd "${S}/refpolicy/policy/modules"
for POLPATCH in ${POLICY_PATCH[@]};
do
einfo "Installing ${POLPATCH}"
eapply -p0 "${POLPATCH}"
done

# Collect only those files needed for this particular module
for i in ${MODS}; do
Expand Down
2 changes: 2 additions & 0 deletions sys-apps/semodule-utils/Manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DIST semodule-utils-3.1.tar.gz 14257 BLAKE2B c8c9a1ce7c9c4f53b1f4c728d16b149fdc284f4cff8b4fce0cb59b77d37d6d7e9bf2102c7177c4eaf94677af6147e42d8d0bd55c0bf3a358968d0162d5a6c65a SHA512 b92794bbfbce5834ee7f62fddb40b5506e9291e8fa7c5d669b2e281089b8f8dc40c4522ea287ac5deffdaee751442ba8e691e2ac45fdd378b60d5d6b2527d157
DIST semodule-utils-3.2.tar.gz 14260 BLAKE2B 35c071c96071028d4a912a89b88d02672f1fb8c2d8d23c3cb472b607dad55acdf351ef870b4d52bb2bed7b816a199c18947afcd16e77b66268822288feb4af2a SHA512 f937647cc22f7ed719908bad64415d706fd97cf1dce484dbca2484b05b3295de40e31bec643b6caaf4e8be742b1f911428d393c5e2d1d0ae39a2a37fd3be9bc1
12 changes: 12 additions & 0 deletions sys-apps/semodule-utils/metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="project">
<email>selinux@gentoo.org</email>
<name>SELinux Team</name>
</maintainer>
<upstream>
<remote-id type="cpe">cpe:/a:redhat:policycoreutils</remote-id>
<remote-id type="github">SELinuxProject/selinux</remote-id>
</upstream>
</pkgmetadata>
52 changes: 52 additions & 0 deletions sys-apps/semodule-utils/semodule-utils-3.1.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI="7"

inherit toolchain-funcs

MY_RELEASEDATE="20200710"
SEPOL_VER="${PV}"
SELNX_VER="${PV}"

MY_P="${P//_/-}"
IUSE=""

if [[ ${PV} == *9999 ]] ; then
inherit git-r3
EGIT_REPO_URI="https://github.com/SELinuxProject/selinux.git"
S="${WORKDIR}/${MY_P}/${PN}"
else
SRC_URI="https://github.com/SELinuxProject/selinux/releases/download/${MY_RELEASEDATE}/${MY_P}.tar.gz"
KEYWORDS="amd64 ~arm ~arm64 ~mips x86"
S="${WORKDIR}/${MY_P}"
fi

DESCRIPTION="SELinux policy module utilities"
HOMEPAGE="https://github.com/SELinuxProject/selinux/wiki"

LICENSE="GPL-2"
SLOT="0"

DEPEND=">=sys-libs/libsepol-${SEPOL_VER}:="

# flatcar changes: add a weak blocker on policycoreutils-2.4
# to prevent file collisions
# policycoreutils-2.4 and semodule-utils provide the same files
RDEPEND="${DEPEND}
!=sys-apps/policycoreutils-2.4-r2
"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If semodule-utils requires Flatcar changes, then why don't we move it to coreos-overlay?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right - it's an edge case actually: starting from policycoreutils-2.7, semodule-utils becomes a single entity; see this commit: SELinuxProject/selinux@c9c97d6.

In the current way we upgrade the things, semodule-utils needs to be installed after the policycoreutils upgrade - otherwise semodule-utils-3.1 will collide with some files provided by policycoreutils-2.4.

This blocker allows portage to first upgrade policycoreutils then install semodule-utils.

We can certainly move semodule-utils to ::coreos-overlay but we would need to move it back in ::portage-stable once the upgrade done. :)


src_prepare() {
default

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

src_compile() {
emake CC="$(tc-getCC)"
}

src_install() {
emake DESTDIR="${D}" install
}
41 changes: 41 additions & 0 deletions sys-apps/semodule-utils/semodule-utils-3.2.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI="7"

inherit toolchain-funcs

IUSE=""

if [[ ${PV} == *9999 ]] ; then
inherit git-r3
EGIT_REPO_URI="https://github.com/SELinuxProject/selinux.git"
S="${WORKDIR}/${P}/${PN}"
else
SRC_URI="https://github.com/SELinuxProject/selinux/releases/download/${PV}/${P}.tar.gz"
KEYWORDS="~amd64 ~arm ~arm64 ~mips ~x86"
fi

DESCRIPTION="SELinux policy module utilities"
HOMEPAGE="https://github.com/SELinuxProject/selinux/wiki"

LICENSE="GPL-2"
SLOT="0"

DEPEND=">=sys-libs/libsepol-${PV}:="

RDEPEND="${DEPEND}"

src_prepare() {
default

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

src_compile() {
emake CC="$(tc-getCC)"
}

src_install() {
emake DESTDIR="${D}" install
}
41 changes: 41 additions & 0 deletions sys-apps/semodule-utils/semodule-utils-9999.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI="7"

inherit toolchain-funcs

IUSE=""

if [[ ${PV} == *9999 ]] ; then
inherit git-r3
EGIT_REPO_URI="https://github.com/SELinuxProject/selinux.git"
S="${WORKDIR}/${P}/${PN}"
else
SRC_URI="https://github.com/SELinuxProject/selinux/releases/download/${PV}/${P}.tar.gz"
KEYWORDS="~amd64 ~arm ~arm64 ~mips ~x86"
fi

DESCRIPTION="SELinux policy module utilities"
HOMEPAGE="https://github.com/SELinuxProject/selinux/wiki"

LICENSE="GPL-2"
SLOT="0"

DEPEND=">=sys-libs/libsepol-${PV}:="

RDEPEND="${DEPEND}"

src_prepare() {
default

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

src_compile() {
emake CC="$(tc-getCC)"
}

src_install() {
emake DESTDIR="${D}" install
}
Loading