summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2015-08-08 13:49:04 -0700
committerRobin H. Johnson <robbat2@gentoo.org>2015-08-08 17:38:18 -0700
commit56bd759df1d0c750a065b8c845e93d5dfa6b549d (patch)
tree3f91093cdb475e565ae857f1c5a7fd339e2d781e /sys-libs/libsemanage
downloadgentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.gz
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.bz2
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.zip
proj/gentoo: Initial commit
This commit represents a new era for Gentoo: Storing the gentoo-x86 tree in Git, as converted from CVS. This commit is the start of the NEW history. Any historical data is intended to be grafted onto this point. Creation process: 1. Take final CVS checkout snapshot 2. Remove ALL ChangeLog* files 3. Transform all Manifests to thin 4. Remove empty Manifests 5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$ 5.1. Do not touch files with -kb/-ko keyword flags. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> X-Thanks: Alec Warner <antarus@gentoo.org> - did the GSoC 2006 migration tests X-Thanks: Robin H. Johnson <robbat2@gentoo.org> - infra guy, herding this project X-Thanks: Nguyen Thai Ngoc Duy <pclouds@gentoo.org> - Former Gentoo developer, wrote Git features for the migration X-Thanks: Brian Harring <ferringb@gentoo.org> - wrote much python to improve cvs2svn X-Thanks: Rich Freeman <rich0@gentoo.org> - validation scripts X-Thanks: Patrick Lauer <patrick@gentoo.org> - Gentoo dev, running new 2014 work in migration X-Thanks: Michał Górny <mgorny@gentoo.org> - scripts, QA, nagging X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed
Diffstat (limited to 'sys-libs/libsemanage')
-rw-r--r--sys-libs/libsemanage/Manifest3
-rw-r--r--sys-libs/libsemanage/files/0001-libsemanage-do-not-copy-contexts-in-semanage_migrate.patch208
-rw-r--r--sys-libs/libsemanage/libsemanage-2.2-r2.ebuild91
-rw-r--r--sys-libs/libsemanage/libsemanage-2.3-r4.ebuild104
-rw-r--r--sys-libs/libsemanage/libsemanage-2.4-r1.ebuild127
-rw-r--r--sys-libs/libsemanage/libsemanage-9999.ebuild137
-rw-r--r--sys-libs/libsemanage/metadata.xml9
7 files changed, 679 insertions, 0 deletions
diff --git a/sys-libs/libsemanage/Manifest b/sys-libs/libsemanage/Manifest
new file mode 100644
index 000000000000..f95583eccd84
--- /dev/null
+++ b/sys-libs/libsemanage/Manifest
@@ -0,0 +1,3 @@
+DIST libsemanage-2.2.tar.gz 138208 SHA256 11f60bfa0f1c6063cd9bd99ce0cb4acc9d6d9e9b8d7743d39e847bcd7803bd75 SHA512 09032b1b322fec7346164939ade118034812cb538ebc72121640d4ac5c89d2a66b59caa465027cfbebb590dee039a26d4345eafedf365d7f6ad0b5e90377d50f WHIRLPOOL 49170c5ee9ff57dcc4a15aa72386f37993f76436f0da25808c60dab2d03ba52932d0d4fa753c326900d83d2fae30f8bcf659251f17327783f2e2be3deb4842f4
+DIST libsemanage-2.3.tar.gz 138231 SHA256 03e09e35e611c286e446bef92b6023ef2623815996f5a53394bb02e49a312e4b SHA512 defe3bbdbe51abdaa13a39f693c33446d8a1a8509ac1eb25c7770da2df6487bcb0ca31259d02b4531d4c81db5e221e94e95bec97f6a1a155e1de2f65e6f0da34 WHIRLPOOL 943d4d300aa8ad49c411b10b41c0c3e751c46dbcbbe129bdd1d2e975e231c58391d6ecdee6b27699fff9f6e6facf5b48fc8d57c2ff68692694c7de430750fac9
+DIST libsemanage-2.4.tar.gz 151173 SHA256 1a4cace4ef16786531ec075c0e7b2f961e2fee5dc86c5f983a689058899a6484 SHA512 54f993253b22207b053daf4d34e72c65c72279866416089b6c0f047ef77bca3e307eac0ce6dfe40bd14e2e47e79841b358d5607501779f38d9b5f7c35f3b7729 WHIRLPOOL 7303c06515ed59b5756a87d08aff07671e51d26ce9fa452ca75643dd0ce4658571dc69d86434c943d691a4ab0d90cbdccdaa27e5aaec5fdf8057cf2d5d30631e
diff --git a/sys-libs/libsemanage/files/0001-libsemanage-do-not-copy-contexts-in-semanage_migrate.patch b/sys-libs/libsemanage/files/0001-libsemanage-do-not-copy-contexts-in-semanage_migrate.patch
new file mode 100644
index 000000000000..8e523dcbf7e3
--- /dev/null
+++ b/sys-libs/libsemanage/files/0001-libsemanage-do-not-copy-contexts-in-semanage_migrate.patch
@@ -0,0 +1,208 @@
+From 9caebebd598de737f27cdc8d5253a2cebd67d5a9 Mon Sep 17 00:00:00 2001
+From: Jason Zaman <jason@perfinion.com>
+Date: Wed, 22 Apr 2015 18:27:09 +0400
+Subject: [PATCH] libsemanage: do not copy contexts in semanage_migrate_store
+
+The modules from the old store were previously copied to the new one
+using setfscreatecon and shutil.copy2(). Now that refpolicy has rules
+about the new policy location[1], copying the contexts is redundant.
+
+More importantly, the setcreatefscon caused a constraint violation[2]
+which made the migration fail. In python3, shutil.copy2() copies xattrs
+as well which again causes problems. shutil.copy() is enough for our
+needs here as it will copy the file and permissions in both py2 and 3.
+We do not need the extra things that copy2() does (mtime, xattr, etc).
+
+[1] http://oss.tresys.com/pipermail/refpolicy/2014-December/007511.html
+
+[2]
+type=AVC msg=audit(1429438272.872:1869): avc: denied { create } for pid=28739 comm="semanage_migrat" name="strict" scontext=staff_u:sysadm_r:semanage_t tcontext=system_u:object_r:semanage_store_t tclass=dir permissive=0
+ constrain dir { create relabelfrom relabelto } ((u1 == u2 -Fail-) or (t1 == can_change_object_identity -Fail-) ); Constraint DENIED
+allow semanage_t semanage_store_t:dir create;
+
+Signed-off-by: Jason Zaman <jason@perfinion.com>
+---
+ libsemanage/utils/semanage_migrate_store | 77 ++++++++------------------------
+ 1 file changed, 18 insertions(+), 59 deletions(-)
+
+diff --git a/libsemanage/utils/semanage_migrate_store b/libsemanage/utils/semanage_migrate_store
+index 03b492e..2f85e9c 100755
+--- a/libsemanage/utils/semanage_migrate_store
++++ b/libsemanage/utils/semanage_migrate_store
+@@ -8,7 +8,6 @@ import shutil
+ import sys
+ from optparse import OptionParser
+
+-import bz2
+ import ctypes
+
+ sepol = ctypes.cdll.LoadLibrary('libsepol.so')
+@@ -21,41 +20,20 @@ except:
+ exit(1)
+
+
+-
+-
+-# For some reason this function doesn't exist in libselinux :\
+-def copy_with_context(src, dst):
++def copy_file(src, dst):
+ if DEBUG:
+ print("copying %s to %s" % (src, dst))
+ try:
+- con = selinux.lgetfilecon_raw(src)[1]
+- except:
+- print("Could not get file context of %s" % src, file=sys.stderr)
+- exit(1)
+-
+- try:
+- selinux.setfscreatecon_raw(con)
+- except:
+- print("Could not set fs create context: %s" %con, file=sys.stderr)
+- exit(1)
+-
+- try:
+- shutil.copy2(src, dst)
++ shutil.copy(src, dst)
+ except OSError as the_err:
+ (err, strerr) = the_err.args
+ print("Could not copy %s to %s, %s" %(src, dst, strerr), file=sys.stderr)
+ exit(1)
+
+- try:
+- selinux.setfscreatecon_raw(None)
+- except:
+- print("Could not reset fs create context. May need to relabel system.", file=sys.stderr)
+
+-def create_dir_from(src, dst, mode):
++def create_dir(dst, mode):
+ if DEBUG: print("Making directory %s" % dst)
+ try:
+- con = selinux.lgetfilecon_raw(src)[1]
+- selinux.setfscreatecon_raw(con)
+ os.makedirs(dst, mode)
+ except OSError as the_err:
+ (err, stderr) = the_err.args
+@@ -65,28 +43,18 @@ def create_dir_from(src, dst, mode):
+ print("Error creating %s" % dst, file=sys.stderr)
+ exit(1)
+
+- try:
+- selinux.setfscreatecon_raw(None)
+- except:
+- print("Could not reset fs create context. May need to relabel system.", file=sys.stderr)
+
+-def create_file_from(src, dst):
++def create_file(dst):
+ if DEBUG: print("Making file %s" % dst)
+ try:
+- con = selinux.lgetfilecon_raw(src)[1]
+- selinux.setfscreatecon_raw(con)
+ open(dst, 'a').close()
+ except OSError as the_err:
+ (err, stderr) = the_err.args
+ print("Error creating %s" % dst, file=sys.stderr)
+ exit(1)
+
+- try:
+- selinux.setfscreatecon_raw(None)
+- except:
+- print("Could not reset fs create context. May need to relabel system.", file=sys.stderr)
+
+-def copy_module(store, name, con, base):
++def copy_module(store, name, base):
+ if DEBUG: print("Install module %s" % name)
+ (file, ext) = os.path.splitext(name)
+ if ext != ".pp":
+@@ -94,8 +62,6 @@ def copy_module(store, name, con, base):
+ print("warning: %s has invalid extension, skipping" % name, file=sys.stderr)
+ return
+ try:
+- selinux.setfscreatecon_raw(con)
+-
+ if base:
+ root = oldstore_path(store)
+ else:
+@@ -105,7 +71,7 @@ def copy_module(store, name, con, base):
+
+ os.mkdir("%s/%s" % (bottomdir, file))
+
+- copy_with_context(os.path.join(root, name), "%s/%s/hll" % (bottomdir, file))
++ copy_file(os.path.join(root, name), "%s/%s/hll" % (bottomdir, file))
+
+ # This is the ext file that will eventually be used to choose a compiler
+ efile = open("%s/%s/lang_ext" % (bottomdir, file), "w+", 0o600)
+@@ -116,15 +82,11 @@ def copy_module(store, name, con, base):
+ print("Error installing module %s" % name, file=sys.stderr)
+ exit(1)
+
+- try:
+- selinux.setfscreatecon_raw(None)
+- except:
+- print("Could not reset fs create context. May need to relabel system.", file=sys.stderr)
+
+-def disable_module(file, root, name, disabledmodules):
++def disable_module(file, name, disabledmodules):
+ if DEBUG: print("Disabling %s" % name)
+ (disabledname, disabledext) = os.path.splitext(file)
+- create_file_from(os.path.join(root, name), "%s/%s" % (disabledmodules, disabledname))
++ create_file("%s/%s" % (disabledmodules, disabledname))
+
+ def migrate_store(store):
+
+@@ -138,17 +100,14 @@ def migrate_store(store):
+ print("Migrating from %s to %s" % (oldstore, newstore))
+
+ # Build up new directory structure
+- create_dir_from(oldstore, "%s/%s" % (newroot_path(), store), 0o755)
+- create_dir_from(oldstore, newstore, 0o700)
+- create_dir_from(oldstore, newmodules, 0o700)
+- create_dir_from(oldstore, bottomdir, 0o700)
+- create_dir_from(oldstore, disabledmodules, 0o700)
+-
+- # use whatever the file context of bottomdir is for the module directories
+- con = selinux.lgetfilecon_raw(bottomdir)[1]
++ create_dir("%s/%s" % (newroot_path(), store), 0o755)
++ create_dir(newstore, 0o700)
++ create_dir(newmodules, 0o700)
++ create_dir(bottomdir, 0o700)
++ create_dir(disabledmodules, 0o700)
+
+ # Special case for base since it was in a different location
+- copy_module(store, "base.pp", con, 1)
++ copy_module(store, "base.pp", 1)
+
+ # Dir structure built, start copying files
+ for root, dirs, files in os.walk(oldstore):
+@@ -161,7 +120,7 @@ def migrate_store(store):
+ newname = "seusers.local"
+ else:
+ newname = name
+- copy_with_context(os.path.join(root, name), os.path.join(newstore, newname))
++ copy_file(os.path.join(root, name), os.path.join(newstore, newname))
+
+ elif root == oldmodules:
+ # This should be the modules directory
+@@ -171,9 +130,9 @@ def migrate_store(store):
+ print("Error installing module %s, name conflicts with base" % name, file=sys.stderr)
+ exit(1)
+ elif ext == ".disabled":
+- disable_module(file, root, name, disabledmodules)
++ disable_module(file, name, disabledmodules)
+ else:
+- copy_module(store, name, con, 0)
++ copy_module(store, name, 0)
+
+ def rebuild_policy():
+ # Ok, the modules are loaded, lets try to rebuild the policy
+@@ -287,7 +246,7 @@ if __name__ == "__main__":
+ "preserve_tunables" ]
+
+
+- create_dir_from(oldroot_path(), newroot_path(), 0o755)
++ create_dir(newroot_path(), 0o755)
+
+ stores = None
+ if TYPE is not None:
+--
+2.0.5
+
diff --git a/sys-libs/libsemanage/libsemanage-2.2-r2.ebuild b/sys-libs/libsemanage/libsemanage-2.2-r2.ebuild
new file mode 100644
index 000000000000..2d6bc07413ea
--- /dev/null
+++ b/sys-libs/libsemanage/libsemanage-2.2-r2.ebuild
@@ -0,0 +1,91 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="5"
+PYTHON_COMPAT=( python2_7 python3_3 )
+
+inherit multilib python-r1 toolchain-funcs eutils multilib-minimal
+
+SEPOL_VER="2.2"
+SELNX_VER="2.2.2-r1"
+
+DESCRIPTION="SELinux kernel and policy management library"
+HOMEPAGE="http://userspace.selinuxproject.org"
+SRC_URI="http://userspace.selinuxproject.org/releases/20131030/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="amd64 x86"
+IUSE="python"
+
+RDEPEND=">=sys-libs/libsepol-${SEPOL_VER}
+ >=sys-libs/libselinux-${SELNX_VER}
+ dev-libs/ustr
+ sys-process/audit"
+DEPEND="${RDEPEND}
+ sys-devel/bison
+ sys-devel/flex
+ python? (
+ >=dev-lang/swig-2.0.4-r1
+ virtual/pkgconfig
+ ${PYTHON_DEPS}
+ )"
+
+# tests are not meant to be run outside of the
+# full SELinux userland repo
+RESTRICT="test"
+
+src_prepare() {
+ echo "# Set this to true to save the linked policy." >> "${S}/src/semanage.conf"
+ echo "# This is normally only useful for analysis" >> "${S}/src/semanage.conf"
+ echo "# or debugging of policy." >> "${S}/src/semanage.conf"
+ echo "save-linked=false" >> "${S}/src/semanage.conf"
+ echo >> "${S}/src/semanage.conf"
+ echo "# Set this to 0 to disable assertion checking." >> "${S}/src/semanage.conf"
+ echo "# This should speed up building the kernel policy" >> "${S}/src/semanage.conf"
+ echo "# from policy modules, but may leave you open to" >> "${S}/src/semanage.conf"
+ echo "# dangerous rules which assertion checking" >> "${S}/src/semanage.conf"
+ echo "# would catch." >> "${S}/src/semanage.conf"
+ echo "expand-check=1" >> "${S}/src/semanage.conf"
+ echo >> "${S}/src/semanage.conf"
+ echo "# Modules in the module store can be compressed" >> "${S}/src/semanage.conf"
+ echo "# with bzip2. Set this to the bzip2 blocksize" >> "${S}/src/semanage.conf"
+ echo "# 1-9 when compressing. The higher the number," >> "${S}/src/semanage.conf"
+ echo "# the more memory is traded off for disk space." >> "${S}/src/semanage.conf"
+ echo "# Set to 0 to disable bzip2 compression." >> "${S}/src/semanage.conf"
+ echo "bzip-blocksize=0" >> "${S}/src/semanage.conf"
+ echo >> "${S}/src/semanage.conf"
+ echo "# Reduce memory usage for bzip2 compression and" >> "${S}/src/semanage.conf"
+ echo "# decompression of modules in the module store." >> "${S}/src/semanage.conf"
+ echo "bzip-small=true" >> "${S}/src/semanage.conf"
+
+ epatch_user
+
+ multilib_copy_sources
+}
+
+multilib_src_compile() {
+ emake AR="$(tc-getAR)" CC="$(tc-getCC)" all || die
+
+ if multilib_is_native_abi && use python; then
+ building() {
+ python_export PYTHON_INCLUDEDIR PYTHON_LIBPATH
+ emake CC="$(tc-getCC)" PYINC="-I${PYTHON_INCLUDEDIR}" PYTHONLBIDIR="${PYTHON_LIBPATH}" PYPREFIX="${EPYTHON##*/}" "$@"
+ }
+ python_foreach_impl building swigify
+ python_foreach_impl building pywrap
+ fi
+}
+
+multilib_src_install() {
+ LIBDIR="\$(PREFIX)/$(get_libdir)" SHLIBDIR="\$(PREFIX)/$(get_libdir)" \
+ emake DESTDIR="${D}" install
+
+ if multilib_is_native_abi && use python; then
+ installation() {
+ emake DESTDIR="${D}" install-pywrap
+ }
+ python_foreach_impl installation
+ fi
+}
diff --git a/sys-libs/libsemanage/libsemanage-2.3-r4.ebuild b/sys-libs/libsemanage/libsemanage-2.3-r4.ebuild
new file mode 100644
index 000000000000..3e52b94dee8f
--- /dev/null
+++ b/sys-libs/libsemanage/libsemanage-2.3-r4.ebuild
@@ -0,0 +1,104 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="5"
+PYTHON_COMPAT=( python2_7 python3_3 python3_4 )
+
+inherit multilib python-r1 toolchain-funcs eutils multilib-minimal
+
+MY_P="${P//_/-}"
+
+SEPOL_VER="2.3"
+SELNX_VER="2.3"
+
+DESCRIPTION="SELinux kernel and policy management library"
+HOMEPAGE="http://userspace.selinuxproject.org"
+SRC_URI="https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/20140506/${MY_P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="amd64 x86"
+IUSE="python"
+
+RDEPEND=">=sys-libs/libsepol-${SEPOL_VER}[${MULTILIB_USEDEP}]
+ >=sys-libs/libselinux-${SELNX_VER}[${MULTILIB_USEDEP}]
+ >=sys-process/audit-2.2.2[${MULTILIB_USEDEP}]
+ >=dev-libs/ustr-1.0.4-r2[${MULTILIB_USEDEP}]
+ "
+DEPEND="${RDEPEND}
+ sys-devel/bison
+ sys-devel/flex
+ python? (
+ >=dev-lang/swig-2.0.4-r1
+ virtual/pkgconfig
+ ${PYTHON_DEPS}
+ )"
+
+# tests are not meant to be run outside of the
+# full SELinux userland repo
+RESTRICT="test"
+
+S="${WORKDIR}/${MY_P}"
+
+src_prepare() {
+ echo "# Set this to true to save the linked policy." >> "${S}/src/semanage.conf"
+ echo "# This is normally only useful for analysis" >> "${S}/src/semanage.conf"
+ echo "# or debugging of policy." >> "${S}/src/semanage.conf"
+ echo "save-linked=false" >> "${S}/src/semanage.conf"
+ echo >> "${S}/src/semanage.conf"
+ echo "# Set this to 0 to disable assertion checking." >> "${S}/src/semanage.conf"
+ echo "# This should speed up building the kernel policy" >> "${S}/src/semanage.conf"
+ echo "# from policy modules, but may leave you open to" >> "${S}/src/semanage.conf"
+ echo "# dangerous rules which assertion checking" >> "${S}/src/semanage.conf"
+ echo "# would catch." >> "${S}/src/semanage.conf"
+ echo "expand-check=1" >> "${S}/src/semanage.conf"
+ echo >> "${S}/src/semanage.conf"
+ echo "# Modules in the module store can be compressed" >> "${S}/src/semanage.conf"
+ echo "# with bzip2. Set this to the bzip2 blocksize" >> "${S}/src/semanage.conf"
+ echo "# 1-9 when compressing. The higher the number," >> "${S}/src/semanage.conf"
+ echo "# the more memory is traded off for disk space." >> "${S}/src/semanage.conf"
+ echo "# Set to 0 to disable bzip2 compression." >> "${S}/src/semanage.conf"
+ echo "bzip-blocksize=0" >> "${S}/src/semanage.conf"
+ echo >> "${S}/src/semanage.conf"
+ echo "# Reduce memory usage for bzip2 compression and" >> "${S}/src/semanage.conf"
+ echo "# decompression of modules in the module store." >> "${S}/src/semanage.conf"
+ echo "bzip-small=true" >> "${S}/src/semanage.conf"
+
+ epatch_user
+
+ multilib_copy_sources
+}
+
+multilib_src_compile() {
+ emake \
+ AR="$(tc-getAR)" \
+ CC="$(tc-getCC)" \
+ LIBDIR="${EPREFIX}/usr/$(get_libdir)" \
+ all
+
+ if multilib_is_native_abi && use python; then
+ building_py() {
+ python_export PYTHON_INCLUDEDIR PYTHON_LIBPATH
+ emake CC="$(tc-getCC)" PYINC="-I${PYTHON_INCLUDEDIR}" PYTHONLBIDIR="${PYTHON_LIBPATH}" PYPREFIX="${EPYTHON##*/}" "$@"
+ python_optimize # bug 531638
+ }
+ python_foreach_impl building_py swigify
+ python_foreach_impl building_py pywrap
+ fi
+}
+
+multilib_src_install() {
+ emake \
+ LIBDIR="${ED}/usr/$(get_libdir)" \
+ SHLIBDIR="${ED}/usr/$(get_libdir)" \
+ DESTDIR="${ED}" install
+
+ if multilib_is_native_abi && use python; then
+ installation_py() {
+ emake DESTDIR="${ED}" LIBDIR="${ED}/usr/$(get_libdir)" \
+ SHLIBDIR="${ED}/usr/$(get_libdir)" install-pywrap
+ }
+ python_foreach_impl installation_py
+ fi
+}
diff --git a/sys-libs/libsemanage/libsemanage-2.4-r1.ebuild b/sys-libs/libsemanage/libsemanage-2.4-r1.ebuild
new file mode 100644
index 000000000000..f28af4cb58c8
--- /dev/null
+++ b/sys-libs/libsemanage/libsemanage-2.4-r1.ebuild
@@ -0,0 +1,127 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="5"
+PYTHON_COMPAT=( python2_7 python3_3 python3_4 )
+
+inherit multilib python-r1 toolchain-funcs eutils multilib-minimal
+
+MY_P="${P//_/-}"
+
+SEPOL_VER="${PV}"
+SELNX_VER="${PV}"
+
+DESCRIPTION="SELinux kernel and policy management library"
+HOMEPAGE="https://github.com/SELinuxProject/selinux/wiki"
+SRC_URI="https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/20150202/${MY_P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="amd64 x86"
+IUSE="python"
+
+RDEPEND=">=sys-libs/libsepol-${SEPOL_VER}[${MULTILIB_USEDEP}]
+ >=sys-libs/libselinux-${SELNX_VER}[${MULTILIB_USEDEP}]
+ >=sys-process/audit-2.2.2[${MULTILIB_USEDEP}]
+ >=dev-libs/ustr-1.0.4-r2[${MULTILIB_USEDEP}]
+ "
+DEPEND="${RDEPEND}
+ sys-devel/bison
+ sys-devel/flex
+ python? (
+ >=dev-lang/swig-2.0.4-r1
+ virtual/pkgconfig
+ ${PYTHON_DEPS}
+ )"
+
+# tests are not meant to be run outside of the
+# full SELinux userland repo
+RESTRICT="test"
+
+S="${WORKDIR}/${MY_P}"
+
+src_prepare() {
+ echo "# Set this to true to save the linked policy." >> "${S}/src/semanage.conf"
+ echo "# This is normally only useful for analysis" >> "${S}/src/semanage.conf"
+ echo "# or debugging of policy." >> "${S}/src/semanage.conf"
+ echo "save-linked=false" >> "${S}/src/semanage.conf"
+ echo >> "${S}/src/semanage.conf"
+ echo "# Set this to 0 to disable assertion checking." >> "${S}/src/semanage.conf"
+ echo "# This should speed up building the kernel policy" >> "${S}/src/semanage.conf"
+ echo "# from policy modules, but may leave you open to" >> "${S}/src/semanage.conf"
+ echo "# dangerous rules which assertion checking" >> "${S}/src/semanage.conf"
+ echo "# would catch." >> "${S}/src/semanage.conf"
+ echo "expand-check=1" >> "${S}/src/semanage.conf"
+ echo >> "${S}/src/semanage.conf"
+ echo "# Modules in the module store can be compressed" >> "${S}/src/semanage.conf"
+ echo "# with bzip2. Set this to the bzip2 blocksize" >> "${S}/src/semanage.conf"
+ echo "# 1-9 when compressing. The higher the number," >> "${S}/src/semanage.conf"
+ echo "# the more memory is traded off for disk space." >> "${S}/src/semanage.conf"
+ echo "# Set to 0 to disable bzip2 compression." >> "${S}/src/semanage.conf"
+ echo "bzip-blocksize=0" >> "${S}/src/semanage.conf"
+ echo >> "${S}/src/semanage.conf"
+ echo "# Reduce memory usage for bzip2 compression and" >> "${S}/src/semanage.conf"
+ echo "# decompression of modules in the module store." >> "${S}/src/semanage.conf"
+ echo "bzip-small=true" >> "${S}/src/semanage.conf"
+
+ epatch "${FILESDIR}/0001-libsemanage-do-not-copy-contexts-in-semanage_migrate.patch"
+
+ epatch_user
+
+ multilib_copy_sources
+}
+
+multilib_src_compile() {
+ emake \
+ AR="$(tc-getAR)" \
+ CC="$(tc-getCC)" \
+ LIBDIR="${EPREFIX}/usr/$(get_libdir)" \
+ all
+
+ if multilib_is_native_abi && use python; then
+ building_py() {
+ python_export PYTHON_INCLUDEDIR PYTHON_LIBPATH
+ emake CC="$(tc-getCC)" PYINC="-I${PYTHON_INCLUDEDIR}" PYTHONLBIDIR="${PYTHON_LIBPATH}" PYPREFIX="${EPYTHON##*/}" "$@"
+ }
+ python_foreach_impl building_py swigify
+ python_foreach_impl building_py pywrap
+ fi
+}
+
+multilib_src_install() {
+ emake \
+ LIBDIR="${ED}/usr/$(get_libdir)" \
+ SHLIBDIR="${ED}/usr/$(get_libdir)" \
+ DESTDIR="${ED}" install
+
+ if multilib_is_native_abi && use python; then
+ installation_py() {
+ emake DESTDIR="${ED}" LIBDIR="${ED}/usr/$(get_libdir)" \
+ SHLIBDIR="${ED}/usr/$(get_libdir)" install-pywrap
+ python_optimize # bug 531638
+ }
+ python_foreach_impl installation_py
+ fi
+}
+
+pkg_postinst() {
+ # Migrate the SELinux semanage configuration store if not done already
+ local selinuxtype=$(awk -F'=' '/SELINUXTYPE=/ {print $2}' /etc/selinux/config);
+ if [ -n "${selinuxtype}" ] && [ ! -d /var/lib/selinux/${mcs}/active ] ; then
+ ewarn "Since the 2.4 SELinux userspace, the policy module store is moved"
+ ewarn "from /etc/selinux to /var/lib/selinux. The migration will be run now."
+ ewarn "If there are any issues, it can be done manually by running:"
+ ewarn "/usr/libexec/selinux/semanage_migrate_store"
+ ewarn "For more information, please see"
+ ewarn "- https://github.com/SELinuxProject/selinux/wiki/Policy-Store-Migration"
+ fi
+
+ # Run the store migration without rebuilds
+ for POLICY_TYPE in ${POLICY_TYPES} ; do
+ if [ ! -d "${ROOT}/var/lib/selinux/${POLICY_TYPE}/active" ] ; then
+ einfo "Migrating store ${POLICY_TYPE} (without policy rebuild)."
+ /usr/libexec/selinux/semanage_migrate_store -n -s "${POLICY_TYPE}" || die "Failed to migrate store ${POLICY_TYPE}"
+ fi
+ done
+}
diff --git a/sys-libs/libsemanage/libsemanage-9999.ebuild b/sys-libs/libsemanage/libsemanage-9999.ebuild
new file mode 100644
index 000000000000..5132051ba8c2
--- /dev/null
+++ b/sys-libs/libsemanage/libsemanage-9999.ebuild
@@ -0,0 +1,137 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="5"
+PYTHON_COMPAT=( python2_7 python3_3 python3_4 )
+
+inherit multilib python-r1 toolchain-funcs eutils multilib-minimal
+
+MY_P="${P//_/-}"
+MY_RELEASEDATE="20150202"
+
+SEPOL_VER="${PV}"
+SELNX_VER="${PV}"
+
+DESCRIPTION="SELinux kernel and policy management library"
+HOMEPAGE="https://github.com/SELinuxProject/selinux/wiki"
+
+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://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/20150202/${MY_P}.tar.gz"
+ KEYWORDS="~amd64 ~x86"
+ S="${WORKDIR}/${MY_P}"
+fi
+
+LICENSE="GPL-2"
+SLOT="0"
+IUSE="python"
+
+RDEPEND=">=sys-libs/libsepol-${SEPOL_VER}[${MULTILIB_USEDEP}]
+ >=sys-libs/libselinux-${SELNX_VER}[${MULTILIB_USEDEP}]
+ >=sys-process/audit-2.2.2[${MULTILIB_USEDEP}]
+ >=dev-libs/ustr-1.0.4-r2[${MULTILIB_USEDEP}]
+ "
+DEPEND="${RDEPEND}
+ sys-devel/bison
+ sys-devel/flex
+ python? (
+ >=dev-lang/swig-2.0.4-r1
+ virtual/pkgconfig
+ ${PYTHON_DEPS}
+ )"
+
+# tests are not meant to be run outside of the
+# full SELinux userland repo
+RESTRICT="test"
+
+src_prepare() {
+ echo "# Set this to true to save the linked policy." >> "${S}/src/semanage.conf"
+ echo "# This is normally only useful for analysis" >> "${S}/src/semanage.conf"
+ echo "# or debugging of policy." >> "${S}/src/semanage.conf"
+ echo "save-linked=false" >> "${S}/src/semanage.conf"
+ echo >> "${S}/src/semanage.conf"
+ echo "# Set this to 0 to disable assertion checking." >> "${S}/src/semanage.conf"
+ echo "# This should speed up building the kernel policy" >> "${S}/src/semanage.conf"
+ echo "# from policy modules, but may leave you open to" >> "${S}/src/semanage.conf"
+ echo "# dangerous rules which assertion checking" >> "${S}/src/semanage.conf"
+ echo "# would catch." >> "${S}/src/semanage.conf"
+ echo "expand-check=1" >> "${S}/src/semanage.conf"
+ echo >> "${S}/src/semanage.conf"
+ echo "# Modules in the module store can be compressed" >> "${S}/src/semanage.conf"
+ echo "# with bzip2. Set this to the bzip2 blocksize" >> "${S}/src/semanage.conf"
+ echo "# 1-9 when compressing. The higher the number," >> "${S}/src/semanage.conf"
+ echo "# the more memory is traded off for disk space." >> "${S}/src/semanage.conf"
+ echo "# Set to 0 to disable bzip2 compression." >> "${S}/src/semanage.conf"
+ echo "bzip-blocksize=0" >> "${S}/src/semanage.conf"
+ echo >> "${S}/src/semanage.conf"
+ echo "# Reduce memory usage for bzip2 compression and" >> "${S}/src/semanage.conf"
+ echo "# decompression of modules in the module store." >> "${S}/src/semanage.conf"
+ echo "bzip-small=true" >> "${S}/src/semanage.conf"
+
+ if [[ ${PV} != 9999 ]] ; then
+ # If wanted for live builds, please use /etc/portage/patches
+ epatch "${FILESDIR}/0001-libsemanage-do-not-copy-contexts-in-semanage_migrate.patch"
+ fi
+
+ epatch_user
+
+ multilib_copy_sources
+}
+
+multilib_src_compile() {
+ emake \
+ AR="$(tc-getAR)" \
+ CC="$(tc-getCC)" \
+ LIBDIR="${EPREFIX}/usr/$(get_libdir)" \
+ all
+
+ if multilib_is_native_abi && use python; then
+ building_py() {
+ python_export PYTHON_INCLUDEDIR PYTHON_LIBPATH
+ emake CC="$(tc-getCC)" PYINC="-I${PYTHON_INCLUDEDIR}" PYTHONLBIDIR="${PYTHON_LIBPATH}" PYPREFIX="${EPYTHON##*/}" "$@"
+ }
+ python_foreach_impl building_py swigify
+ python_foreach_impl building_py pywrap
+ fi
+}
+
+multilib_src_install() {
+ emake \
+ LIBDIR="${ED}/usr/$(get_libdir)" \
+ SHLIBDIR="${ED}/usr/$(get_libdir)" \
+ DESTDIR="${ED}" install
+
+ if multilib_is_native_abi && use python; then
+ installation_py() {
+ emake DESTDIR="${ED}" LIBDIR="${ED}/usr/$(get_libdir)" \
+ SHLIBDIR="${ED}/usr/$(get_libdir)" install-pywrap
+ python_optimize # bug 531638
+ }
+ python_foreach_impl installation_py
+ fi
+}
+
+pkg_postinst() {
+ # Migrate the SELinux semanage configuration store if not done already
+ local selinuxtype=$(awk -F'=' '/SELINUXTYPE=/ {print $2}' /etc/selinux/config);
+ if [ -n "${selinuxtype}" ] && [ ! -d /var/lib/selinux/${mcs}/active ] ; then
+ ewarn "Since the 2.4 SELinux userspace, the policy module store is moved"
+ ewarn "from /etc/selinux to /var/lib/selinux. The migration will be run now."
+ ewarn "If there are any issues, it can be done manually by running:"
+ ewarn "/usr/libexec/selinux/semanage_migrate_store"
+ ewarn "For more information, please see"
+ ewarn "- https://github.com/SELinuxProject/selinux/wiki/Policy-Store-Migration"
+ fi
+
+ # Run the store migration without rebuilds
+ for POLICY_TYPE in ${POLICY_TYPES} ; do
+ if [ ! -d "${ROOT}/var/lib/selinux/${POLICY_TYPE}/active" ] ; then
+ einfo "Migrating store ${POLICY_TYPE} (without policy rebuild)."
+ /usr/libexec/selinux/semanage_migrate_store -n -s "${POLICY_TYPE}" || die "Failed to migrate store ${POLICY_TYPE}"
+ fi
+ done
+}
diff --git a/sys-libs/libsemanage/metadata.xml b/sys-libs/libsemanage/metadata.xml
new file mode 100644
index 000000000000..83c24ee19582
--- /dev/null
+++ b/sys-libs/libsemanage/metadata.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <herd>selinux</herd>
+ <longdescription>SELinux policy management libraries</longdescription>
+ <upstream>
+ <remote-id type="github">SELinuxProject/selinux</remote-id>
+ </upstream>
+</pkgmetadata>