libpcre, libselinux, libsepol: upgraded packages to upstream

Upgraded dev-libs/libpcre to version 8.44 on amd64, arm
Upgraded sys-libs/libselinux to version 3.0 on arm
Upgraded sys-libs/libsepol to version 3.0 on amd64, arm

BUG=chromium:1099670
TEST=CQ passes

Cq-Depend: chromium:2336767
Change-Id: Ib258db8ac0903fa0a57c23e881dec94ce3fdd859
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/portage-stable/+/2335834
Tested-by: Allen Webb <allenwebb@google.com>
Reviewed-by: Allen Webb <allenwebb@google.com>
diff --git a/dev-libs/libpcre/Manifest b/dev-libs/libpcre/Manifest
index ce74278..1cf3383 100644
--- a/dev-libs/libpcre/Manifest
+++ b/dev-libs/libpcre/Manifest
@@ -1 +1 @@
-DIST pcre-8.41.tar.bz2 1561874 SHA256 e62c7eac5ae7c0e7286db61ff82912e1c0b7a0c13706616e94a7dd729321b530 SHA512 cc9cdbeb98c010fe4f093a019bebfb91965dae4c6a48f8e49c38ec8df7d9da7f0d32c12fc58f22c51f1c2f010e72b65bcbf8bbf180060e93edf464fa9a7c3551 WHIRLPOOL 24d891c4f6580af20aa07a166038a2bacb52cdb305987f8b91b2fecae65e7b5277d3ef0b26ddbb3a33fd34794e6340e77df6a321e770b3aca4393d1ed144cf64
+DIST pcre-8.44.tar.bz2 1577611 BLAKE2B ef8d5737ca1f4c72f12c8726956ce5d3bad13aa8303b7c3b5d25499e3027ddc2edcdb937d9ad2bdd437a8885f1af8757ba194aa0b2f236b6e6a3a18d2ec8f138 SHA512 f26d850aab5228799e58ac8c2306fb313889332c39e29b118ef1de57677c5c90f970d68d3f475cabc64f8b982a77f04eca990ff1057f3ccf5e19bd137997c4ac
diff --git a/dev-libs/libpcre/files/libpcre-8.41-sljit_mips-label-statement-fix.patch b/dev-libs/libpcre/files/libpcre-8.41-sljit_mips-label-statement-fix.patch
deleted file mode 100644
index 0494ccc..0000000
--- a/dev-libs/libpcre/files/libpcre-8.41-sljit_mips-label-statement-fix.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-diff -Naurp pcre-8.41.orig/sljit/sljitNativeMIPS_common.c pcre-8.41/sljit/sljitNativeMIPS_common.c
---- pcre-8.41.orig/sljit/sljitNativeMIPS_common.c	2017-05-07 11:32:25.000000000 -0400
-+++ pcre-8.41/sljit/sljitNativeMIPS_common.c	2017-07-29 17:50:24.508909742 -0400
-@@ -503,9 +503,11 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
- #ifdef SLJIT_IS_FPU_AVAILABLE
- 		return SLJIT_IS_FPU_AVAILABLE;
- #elif defined(__GNUC__)
-+	{
- 		sljit_sw fir;
- 		asm ("cfc1 %0, $0" : "=r"(fir));
- 		return (fir >> 22) & 0x1;
-+	}
- #else
- #error "FIR check is not implemented for this architecture"
- #endif
diff --git a/dev-libs/libpcre/libpcre-8.41-r1.ebuild b/dev-libs/libpcre/libpcre-8.44.ebuild
similarity index 80%
rename from dev-libs/libpcre/libpcre-8.41-r1.ebuild
rename to dev-libs/libpcre/libpcre-8.44.ebuild
index c829a6e..3f5012c 100644
--- a/dev-libs/libpcre/libpcre-8.41-r1.ebuild
+++ b/dev-libs/libpcre/libpcre-8.44.ebuild
@@ -1,9 +1,9 @@
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=5
+EAPI=7
 
-inherit eutils multilib libtool flag-o-matic toolchain-funcs multilib-minimal
+inherit multilib libtool flag-o-matic toolchain-funcs multilib-minimal preserve-libs usr-ldscript
 
 DESCRIPTION="Perl-compatible regular expression library"
 HOMEPAGE="http://www.pcre.org/"
@@ -29,13 +29,10 @@
 	libedit? ( dev-libs/libedit )
 	readline? ( sys-libs/readline:0= )
 "
-DEPEND="
-	${RDEPEND}
+DEPEND="${RDEPEND}"
+BDEPEND="
 	virtual/pkgconfig
 "
-RDEPEND="
-	${RDEPEND}
-"
 
 S="${WORKDIR}/${MY_P}"
 
@@ -44,12 +41,11 @@
 )
 
 PATCHES=(
-	"${FILESDIR}"/${PN}-8.41-sljit_mips-label-statement-fix.patch
 	"${FILESDIR}"/${PN}-8.41-fix-stack-size-detection.patch
 )
 
 src_prepare() {
-	epatch "${PATCHES[@]}"
+	default
 	sed -i -e "s:-lpcre ::" libpcrecpp.pc.in || die
 	elibtoolize
 }
@@ -59,18 +55,18 @@
 		--with-match-limit-recursion=$(usex recursion-limit 8192 MATCH_LIMIT)
 		$(multilib_native_use_enable bzip2 pcregrep-libbz2)
 		$(use_enable cxx cpp)
-		$(use_enable jit) $(use_enable jit pcregrep-jit)
+		$(use_enable jit)
+		$(use_enable jit pcregrep-jit)
 		$(use_enable pcre16)
 		$(use_enable pcre32)
 		$(multilib_native_use_enable libedit pcretest-libedit)
 		$(multilib_native_use_enable readline pcretest-libreadline)
 		$(use_enable static-libs static)
-		$(use_enable unicode utf) $(use_enable unicode unicode-properties)
+		$(use_enable unicode utf)
+		$(use_enable unicode unicode-properties)
 		$(multilib_native_use_enable zlib pcregrep-libz)
 		--enable-pcre8
 		--enable-shared
-		--htmldir="${EPREFIX}"/usr/share/doc/${PF}/html
-		--docdir="${EPREFIX}"/usr/share/doc/${PF}
 	)
 	ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
 }
@@ -88,7 +84,7 @@
 }
 
 multilib_src_install_all() {
-	prune_libtool_files
+	find "${ED}" -type f -name "*.la" -delete || die
 }
 
 pkg_preinst() {
diff --git a/metadata/md5-cache/dev-libs/libpcre-8.41-r1 b/metadata/md5-cache/dev-libs/libpcre-8.44
similarity index 65%
rename from metadata/md5-cache/dev-libs/libpcre-8.41-r1
rename to metadata/md5-cache/dev-libs/libpcre-8.44
index df48ce5..4bbb338 100644
--- a/metadata/md5-cache/dev-libs/libpcre-8.41-r1
+++ b/metadata/md5-cache/dev-libs/libpcre-8.44
@@ -1,14 +1,15 @@
+BDEPEND=virtual/pkgconfig >=app-portage/elt-patches-20170815
 DEFINED_PHASES=compile configure install postinst preinst prepare test
-DEPEND=bzip2? ( app-arch/bzip2 ) zlib? ( sys-libs/zlib ) libedit? ( dev-libs/libedit ) readline? ( sys-libs/readline:0= ) virtual/pkgconfig >=app-portage/elt-patches-20170815
+DEPEND=bzip2? ( app-arch/bzip2 ) zlib? ( sys-libs/zlib ) libedit? ( dev-libs/libedit ) readline? ( sys-libs/readline:0= )
 DESCRIPTION=Perl-compatible regular expression library
-EAPI=5
+EAPI=7
 HOMEPAGE=http://www.pcre.org/
-IUSE=bzip2 +cxx +jit libedit pcre16 pcre32 +readline +recursion-limit static-libs unicode zlib abi_x86_32 abi_x86_64 abi_x86_x32 abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_ppc_32 abi_ppc_64 abi_s390_32 abi_s390_64 abi_arm_32 abi_arm_64
+IUSE=bzip2 +cxx +jit libedit pcre16 pcre32 +readline +recursion-limit static-libs unicode zlib abi_x86_32 abi_x86_64 abi_x86_x32 abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_ppc_32 abi_ppc_64 abi_s390_32 abi_s390_64 abi_arm_32 abi_arm_64 split-usr
 KEYWORDS=*
 LICENSE=BSD
 RDEPEND=bzip2? ( app-arch/bzip2 ) zlib? ( sys-libs/zlib ) libedit? ( dev-libs/libedit ) readline? ( sys-libs/readline:0= )
 REQUIRED_USE=readline? ( !libedit ) libedit? ( !readline )
 SLOT=3
-SRC_URI=mirror://sourceforge/pcre/pcre-8.41.tar.bz2 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.bz2
-_eclasses_=eutils	06133990e861be0fe60c2b428fd025d9	flag-o-matic	5d5921a298e95441da2f85be419894c0	libtool	f143db5a74ccd9ca28c1234deffede96	multibuild	40fe59465edacd730c644ec2bc197809	multilib	2477ebe553d3e4d2c606191fe6c33602	multilib-build	1979aa0ff4d356d32507ca4650d9f37d	multilib-minimal	8bddda43703ba94d8341f4e247f97566	toolchain-funcs	605c126bed8d87e4378d5ff1645330cb
-_md5_=e94fc8bff73ffb89434133a0f7975e2f
+SRC_URI=mirror://sourceforge/pcre/pcre-8.44.tar.bz2 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.44.tar.bz2
+_eclasses_=eutils	06133990e861be0fe60c2b428fd025d9	flag-o-matic	5d5921a298e95441da2f85be419894c0	libtool	f143db5a74ccd9ca28c1234deffede96	multibuild	40fe59465edacd730c644ec2bc197809	multilib	2477ebe553d3e4d2c606191fe6c33602	multilib-build	1979aa0ff4d356d32507ca4650d9f37d	multilib-minimal	8bddda43703ba94d8341f4e247f97566	preserve-libs	ef207dc62baddfddfd39a164d9797648	toolchain-funcs	605c126bed8d87e4378d5ff1645330cb	usr-ldscript	766f0a506b45f02361ad1b8ca205b7e1
+_md5_=7d4e770e0e43995c68d769c3f6c87c93
diff --git a/metadata/md5-cache/sys-libs/libselinux-2.7 b/metadata/md5-cache/sys-libs/libselinux-2.7
deleted file mode 100644
index 39af7a2..0000000
--- a/metadata/md5-cache/sys-libs/libselinux-2.7
+++ /dev/null
@@ -1,14 +0,0 @@
-DEFINED_PHASES=compile configure install postinst prepare test
-DEPEND=>=sys-libs/libsepol-2.7:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?,abi_arm_32(-)?,abi_arm_64(-)?] !pcre2? ( >=dev-libs/libpcre-8.33-r1:=[static-libs?,abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?,abi_arm_32(-)?,abi_arm_64(-)?] ) pcre2? ( dev-libs/libpcre2:=[static-libs?,abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?,abi_arm_32(-)?,abi_arm_64(-)?] ) python? ( python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7 ) python_targets_python3_6? ( dev-lang/python:3.6 ) >=dev-lang/python-exec-2:=[python_targets_python2_7(-)?,python_targets_python3_6(-)?,-python_single_target_python2_7(-),-python_single_target_python3_6(-)] ) ruby? ( ruby_targets_ruby22? ( dev-lang/ruby:2.2 ) ruby_targets_ruby23? ( dev-lang/ruby:2.3 ) ) virtual/pkgconfig python? ( >=dev-lang/swig-2.0.9 )
-DESCRIPTION=SELinux userland library
-EAPI=5
-HOMEPAGE=https://github.com/SELinuxProject/selinux/wiki
-IUSE=pcre2 python ruby static-libs ruby_targets_ruby21 ruby_targets_ruby22 ruby_targets_ruby23 python_targets_python2_7 python_targets_python3_6 abi_x86_32 abi_x86_64 abi_x86_x32 abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_ppc_32 abi_ppc_64 abi_s390_32 abi_s390_64 abi_arm_32 abi_arm_64
-KEYWORDS=*
-LICENSE=public-domain
-RDEPEND=>=sys-libs/libsepol-2.7:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?,abi_arm_32(-)?,abi_arm_64(-)?] !pcre2? ( >=dev-libs/libpcre-8.33-r1:=[static-libs?,abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?,abi_arm_32(-)?,abi_arm_64(-)?] ) pcre2? ( dev-libs/libpcre2:=[static-libs?,abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?,abi_arm_32(-)?,abi_arm_64(-)?] ) python? ( python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7 ) python_targets_python3_6? ( dev-lang/python:3.6 ) >=dev-lang/python-exec-2:=[python_targets_python2_7(-)?,python_targets_python3_6(-)?,-python_single_target_python2_7(-),-python_single_target_python3_6(-)] ) ruby? ( ruby_targets_ruby22? ( dev-lang/ruby:2.2 ) ruby_targets_ruby23? ( dev-lang/ruby:2.3 ) )
-REQUIRED_USE=python? ( || ( python_targets_python2_7 python_targets_python3_6 ) )
-SLOT=0
-SRC_URI=https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/20170804/libselinux-2.7.tar.gz
-_eclasses_=eutils	06133990e861be0fe60c2b428fd025d9	multibuild	40fe59465edacd730c644ec2bc197809	multilib	2477ebe553d3e4d2c606191fe6c33602	multilib-build	1979aa0ff4d356d32507ca4650d9f37d	multilib-minimal	8bddda43703ba94d8341f4e247f97566	python-r1	ce1cd23cfdc1848e8e32743efe34f299	python-utils-r1	931c328767d245c08a16a3f87be9ce9c	toolchain-funcs	605c126bed8d87e4378d5ff1645330cb
-_md5_=a597a209d1dc5a382fce62bc89507a6e
diff --git a/metadata/md5-cache/sys-libs/libselinux-3.0 b/metadata/md5-cache/sys-libs/libselinux-3.0
new file mode 100644
index 0000000..df79090
--- /dev/null
+++ b/metadata/md5-cache/sys-libs/libselinux-3.0
@@ -0,0 +1,14 @@
+DEFINED_PHASES=compile configure install postinst prepare test
+DEPEND=>=sys-libs/libsepol-3.0:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?,abi_arm_32(-)?,abi_arm_64(-)?] !pcre2? ( >=dev-libs/libpcre-8.33-r1:=[static-libs?,abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?,abi_arm_32(-)?,abi_arm_64(-)?] ) pcre2? ( dev-libs/libpcre2:=[static-libs?,abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?,abi_arm_32(-)?,abi_arm_64(-)?] ) python? ( python_targets_python3_6? ( dev-lang/python:3.6 ) python_targets_python3_7? ( dev-lang/python:3.7 ) python_targets_python3_8? ( dev-lang/python:3.8 ) >=dev-lang/python-exec-2:=[python_targets_python3_6(-)?,python_targets_python3_7(-)?,python_targets_python3_8(-)?,-python_single_target_python3_6(-),-python_single_target_python3_7(-),-python_single_target_python3_8(-)] ) ruby? ( ruby_targets_ruby24? ( dev-lang/ruby:2.4 ) ruby_targets_ruby25? ( dev-lang/ruby:2.5 ) ruby_targets_ruby26? ( dev-lang/ruby:2.6 ) ) elibc_musl? ( sys-libs/fts-standalone ) virtual/pkgconfig python? ( >=dev-lang/swig-2.0.9 ) ruby? ( >=dev-lang/swig-2.0.9 )
+DESCRIPTION=SELinux userland library
+EAPI=6
+HOMEPAGE=https://github.com/SELinuxProject/selinux/wiki
+IUSE=pcre2 python ruby static-libs ruby_targets_ruby24 ruby_targets_ruby25 ruby_targets_ruby26 python_targets_python3_6 python_targets_python3_7 python_targets_python3_8 abi_x86_32 abi_x86_64 abi_x86_x32 abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_ppc_32 abi_ppc_64 abi_s390_32 abi_s390_64 abi_arm_32 abi_arm_64
+KEYWORDS=*
+LICENSE=public-domain
+RDEPEND=>=sys-libs/libsepol-3.0:=[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?,abi_arm_32(-)?,abi_arm_64(-)?] !pcre2? ( >=dev-libs/libpcre-8.33-r1:=[static-libs?,abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?,abi_arm_32(-)?,abi_arm_64(-)?] ) pcre2? ( dev-libs/libpcre2:=[static-libs?,abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?,abi_arm_32(-)?,abi_arm_64(-)?] ) python? ( python_targets_python3_6? ( dev-lang/python:3.6 ) python_targets_python3_7? ( dev-lang/python:3.7 ) python_targets_python3_8? ( dev-lang/python:3.8 ) >=dev-lang/python-exec-2:=[python_targets_python3_6(-)?,python_targets_python3_7(-)?,python_targets_python3_8(-)?,-python_single_target_python3_6(-),-python_single_target_python3_7(-),-python_single_target_python3_8(-)] ) ruby? ( ruby_targets_ruby24? ( dev-lang/ruby:2.4 ) ruby_targets_ruby25? ( dev-lang/ruby:2.5 ) ruby_targets_ruby26? ( dev-lang/ruby:2.6 ) ) elibc_musl? ( sys-libs/fts-standalone )
+REQUIRED_USE=python? ( || ( python_targets_python3_6 python_targets_python3_7 python_targets_python3_8 ) )
+SLOT=0
+SRC_URI=https://github.com/SELinuxProject/selinux/releases/download/20191204/libselinux-3.0.tar.gz
+_eclasses_=multibuild	40fe59465edacd730c644ec2bc197809	multilib	2477ebe553d3e4d2c606191fe6c33602	multilib-build	1979aa0ff4d356d32507ca4650d9f37d	multilib-minimal	8bddda43703ba94d8341f4e247f97566	python-r1	ce1cd23cfdc1848e8e32743efe34f299	python-utils-r1	931c328767d245c08a16a3f87be9ce9c	toolchain-funcs	605c126bed8d87e4378d5ff1645330cb
+_md5_=d18f4ba0459d1c20a8b803aaa00e56cf
diff --git a/metadata/md5-cache/sys-libs/libsepol-2.7 b/metadata/md5-cache/sys-libs/libsepol-2.7
deleted file mode 100644
index 19de9f7..0000000
--- a/metadata/md5-cache/sys-libs/libsepol-2.7
+++ /dev/null
@@ -1,12 +0,0 @@
-DEFINED_PHASES=compile configure install prepare test
-DESCRIPTION=SELinux binary policy representation library
-EAPI=5
-HOMEPAGE=https://github.com/SELinuxProject/selinux/wiki
-IUSE=abi_x86_32 abi_x86_64 abi_x86_x32 abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_ppc_32 abi_ppc_64 abi_s390_32 abi_s390_64 abi_arm_32 abi_arm_64
-KEYWORDS=*
-LICENSE=GPL-2
-RESTRICT=test
-SLOT=0
-SRC_URI=https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/20170804/libsepol-2.7.tar.gz
-_eclasses_=eutils	06133990e861be0fe60c2b428fd025d9	multibuild	40fe59465edacd730c644ec2bc197809	multilib	2477ebe553d3e4d2c606191fe6c33602	multilib-build	1979aa0ff4d356d32507ca4650d9f37d	multilib-minimal	8bddda43703ba94d8341f4e247f97566	toolchain-funcs	605c126bed8d87e4378d5ff1645330cb
-_md5_=64774297ba15e0b4b39c12651e437092
diff --git a/metadata/md5-cache/sys-libs/libsepol-2.7-r1 b/metadata/md5-cache/sys-libs/libsepol-2.7-r1
deleted file mode 100644
index 19de9f7..0000000
--- a/metadata/md5-cache/sys-libs/libsepol-2.7-r1
+++ /dev/null
@@ -1,12 +0,0 @@
-DEFINED_PHASES=compile configure install prepare test
-DESCRIPTION=SELinux binary policy representation library
-EAPI=5
-HOMEPAGE=https://github.com/SELinuxProject/selinux/wiki
-IUSE=abi_x86_32 abi_x86_64 abi_x86_x32 abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_ppc_32 abi_ppc_64 abi_s390_32 abi_s390_64 abi_arm_32 abi_arm_64
-KEYWORDS=*
-LICENSE=GPL-2
-RESTRICT=test
-SLOT=0
-SRC_URI=https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/20170804/libsepol-2.7.tar.gz
-_eclasses_=eutils	06133990e861be0fe60c2b428fd025d9	multibuild	40fe59465edacd730c644ec2bc197809	multilib	2477ebe553d3e4d2c606191fe6c33602	multilib-build	1979aa0ff4d356d32507ca4650d9f37d	multilib-minimal	8bddda43703ba94d8341f4e247f97566	toolchain-funcs	605c126bed8d87e4378d5ff1645330cb
-_md5_=64774297ba15e0b4b39c12651e437092
diff --git a/metadata/md5-cache/sys-libs/libsepol-3.0 b/metadata/md5-cache/sys-libs/libsepol-3.0
new file mode 100644
index 0000000..a410fc9
--- /dev/null
+++ b/metadata/md5-cache/sys-libs/libsepol-3.0
@@ -0,0 +1,12 @@
+DEFINED_PHASES=compile configure install prepare test
+DESCRIPTION=SELinux binary policy representation library
+EAPI=6
+HOMEPAGE=https://github.com/SELinuxProject/selinux/wiki
+IUSE=abi_x86_32 abi_x86_64 abi_x86_x32 abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_ppc_32 abi_ppc_64 abi_s390_32 abi_s390_64 abi_arm_32 abi_arm_64
+KEYWORDS=*
+LICENSE=GPL-2
+RESTRICT=test
+SLOT=0
+SRC_URI=https://github.com/SELinuxProject/selinux/releases/download/20191204/libsepol-3.0.tar.gz
+_eclasses_=multibuild	40fe59465edacd730c644ec2bc197809	multilib	2477ebe553d3e4d2c606191fe6c33602	multilib-build	1979aa0ff4d356d32507ca4650d9f37d	multilib-minimal	8bddda43703ba94d8341f4e247f97566	toolchain-funcs	605c126bed8d87e4378d5ff1645330cb
+_md5_=fc22c08760b31395806ff5f9fc821191
diff --git a/sys-libs/libselinux/Manifest b/sys-libs/libselinux/Manifest
index 56398b4..6e63ee2 100644
--- a/sys-libs/libselinux/Manifest
+++ b/sys-libs/libselinux/Manifest
@@ -1 +1 @@
-DIST libselinux-2.7.tar.gz 187574 SHA256 d0fec0769b3ad60aa7baf9b9a4b7a056827769dc2dadda0dc0eb59b3d1c18c57 SHA512 415d10306692d4323455b61fb61d7e56e53b9144276ff206d72760e1df9b04ab07c62a4d6f04bf4e5fa708f9f14b21a9801069b16ece0a0aade886950941ab8d WHIRLPOOL dd9175c91fa8f6f87add7b0ad1b90706b1fb203ade866b42d886faeb3710e1138fc08a2d7d371fbc8c9480148f8fdec6f0a6dd3f7142f194da580365cd527351
+DIST libselinux-3.0.tar.gz 212096 BLAKE2B 7502c77243928adfc445f55357b0e894087859c3a83e2beb446c31818362d10111c3e52b970150638c055f96cccca6fccde79440026201a2a48bfda3565c27d3 SHA512 6fd8c3711e25cb1363232e484268609b71d823975537b3863e403836222eba026abce8ca198f64dba6f4c1ea4deb7ecef68a0397b9656a67b363e4d74409cd95
diff --git a/sys-libs/libselinux/files/0001-libselinux-Use-Python-distutils-to-install-SELinux-p.patch b/sys-libs/libselinux/files/0001-libselinux-Use-Python-distutils-to-install-SELinux-p.patch
new file mode 100644
index 0000000..896876a
--- /dev/null
+++ b/sys-libs/libselinux/files/0001-libselinux-Use-Python-distutils-to-install-SELinux-p.patch
@@ -0,0 +1,205 @@
+From 2efa06857575e4118e91ca250b6b92da68b130d5 Mon Sep 17 00:00:00 2001
+From: Petr Lautrbach <plautrba@redhat.com>
+Date: Fri, 7 Jun 2019 17:35:44 +0200
+Subject: [PATCH] libselinux: Use Python distutils to install SELinux python
+ bindings
+
+Follow officially documented way how to build C extension modules using
+distutils - https://docs.python.org/3.8/extending/building.html#building
+
+Fixes:
+
+- selinux python module fails to load when it's built using SWIG-4.0:
+
+>>> import selinux
+Traceback (most recent call last):
+  File "<stdin>", line 1, in <module>
+  File "/usr/lib64/python3.7/site-packages/selinux/__init__.py", line 13, in <module>
+    from . import _selinux
+ImportError: cannot import name '_selinux' from 'selinux' (/usr/lib64/python3.7/site-packages/selinux/__init__.py)
+
+SWIG-4.0 changed (again?) its behavior so that it uses: from . import _selinux
+which looks for _selinux module in the same directory as where __init__.py is -
+$(PYLIBDIR)/site-packages/selinux. But _selinux module is installed into
+$(PYLIBDIR)/site-packages/ since a9604c30a5e2f ("libselinux: Change the location
+of _selinux.so").
+
+- audit2why python module fails to build with Python 3.8
+
+cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -DOVERRIDE_GETTID=0 -I../include -D_GNU_SOURCE -DDISABLE_RPM -DNO_ANDROID_BACKEND -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8  -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L. -shared -o python-3.8audit2why.so python-3.8audit2why.lo -lselinux -l:libsepol.a  -Wl,-soname,audit2why.so,--version-script=audit2why.map,-z,defs
+/usr/bin/ld: python-3.8audit2why.lo: in function `finish':
+/builddir/build/BUILD/libselinux-2.9/src/audit2why.c:166: undefined reference to `PyArg_ParseTuple'
+/usr/bin/ld: python-3.8audit2why.lo: in function `_Py_INCREF':
+/usr/include/python3.8/object.h:449: undefined reference to `_Py_NoneStruct'
+/usr/bin/ld: /usr/include/python3.8/object.h:449: undefined reference to `_Py_NoneStruct'
+/usr/bin/ld: python-3.8audit2why.lo: in function `check_booleans':
+/builddir/build/BUILD/libselinux-2.9/src/audit2why.c:84: undefined reference to `PyExc_RuntimeError'
+...
+
+It's related to the following Python change
+https://docs.python.org/dev/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build
+
+Python distutils adds correct link options automatically.
+
+- selinux python module doesn't provide any Python metadata
+
+When selinux python module was built manually, it didn't provide any metadata.
+distutils takes care about that so that selinux Python module is visible for
+pip:
+
+$ pip3 list | grep selinux
+selinux              2.9
+
+Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
+---
+ libselinux/src/.gitignore |  2 +-
+ libselinux/src/Makefile   | 36 ++++++++----------------------------
+ libselinux/src/setup.py   | 24 ++++++++++++++++++++++++
+ 3 files changed, 33 insertions(+), 29 deletions(-)
+ create mode 100644 libselinux/src/setup.py
+
+diff --git libselinux/src/.gitignore libselinux/src/.gitignore
+index 4dcc3b3b..428afe5a 100644
+--- libselinux/src/.gitignore
++++ libselinux/src/.gitignore
+@@ -1,4 +1,4 @@
+ selinux.py
+-selinuxswig_wrap.c
++selinuxswig_python_wrap.c
+ selinuxswig_python_exception.i
+ selinuxswig_ruby_wrap.c
+diff --git libselinux/src/Makefile libselinux/src/Makefile
+index e9ed0383..2b1696a0 100644
+--- libselinux/src/Makefile
++++ libselinux/src/Makefile
+@@ -36,7 +36,7 @@ TARGET=libselinux.so
+ LIBPC=libselinux.pc
+ SWIGIF= selinuxswig_python.i selinuxswig_python_exception.i
+ SWIGRUBYIF= selinuxswig_ruby.i
+-SWIGCOUT= selinuxswig_wrap.c
++SWIGCOUT= selinuxswig_python_wrap.c
+ SWIGPYOUT= selinux.py
+ SWIGRUBYCOUT= selinuxswig_ruby_wrap.c
+ SWIGLOBJ:= $(patsubst %.c,$(PYPREFIX)%.lo,$(SWIGCOUT))
+@@ -55,7 +55,7 @@ ifeq ($(LIBSEPOLA),)
+         LDLIBS_LIBSEPOLA := -l:libsepol.a
+ endif
+ 
+-GENERATED=$(SWIGCOUT) $(SWIGRUBYCOUT) selinuxswig_python_exception.i
++GENERATED=$(SWIGCOUT) $(SWIGRUBYCOUT) $(SWIGCOUT) selinuxswig_python_exception.i
+ SRCS= $(filter-out $(GENERATED) audit2why.c, $(sort $(wildcard *.c)))
+ 
+ MAX_STACK_SIZE=32768
+@@ -125,25 +125,18 @@ DISABLE_FLAGS+= -DNO_ANDROID_BACKEND
+ SRCS:= $(filter-out label_backends_android.c, $(SRCS))
+ endif
+ 
+-SWIG = swig -Wall -python -o $(SWIGCOUT) -outdir ./ $(DISABLE_FLAGS)
+-
+ SWIGRUBY = swig -Wall -ruby -o $(SWIGRUBYCOUT) -outdir ./ $(DISABLE_FLAGS)
+ 
+ all: $(LIBA) $(LIBSO) $(LIBPC)
+ 
+-pywrap: all $(SWIGFILES) $(AUDIT2WHYSO)
++pywrap: all selinuxswig_python_exception.i
++	CFLAGS="$(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) setup.py build_ext -I $(DESTDIR)$(INCLUDEDIR) -L $(DESTDIR)$(LIBDIR)
+ 
+ rubywrap: all $(SWIGRUBYSO)
+ 
+-$(SWIGLOBJ): $(SWIGCOUT)
+-	$(CC) $(CFLAGS) $(SWIG_CFLAGS) $(PYINC) -fPIC -DSHARED -c -o $@ $<
+-
+ $(SWIGRUBYLOBJ): $(SWIGRUBYCOUT)
+ 	$(CC) $(CFLAGS) $(SWIG_CFLAGS) $(RUBYINC) -fPIC -DSHARED -c -o $@ $<
+ 
+-$(SWIGSO): $(SWIGLOBJ)
+-	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $< -lselinux $(PYLIBS)
+-
+ $(SWIGRUBYSO): $(SWIGRUBYLOBJ)
+ 	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(RUBYLIBS)
+ 
+@@ -161,29 +154,15 @@ $(LIBPC): $(LIBPC).in ../VERSION
+ selinuxswig_python_exception.i: ../include/selinux/selinux.h
+ 	bash -e exception.sh > $@ || (rm -f $@ ; false)
+ 
+-$(AUDIT2WHYLOBJ): audit2why.c
+-	$(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<
+-
+-$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)
+-	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(LDLIBS_LIBSEPOLA) $(PYLIBS) -Wl,-soname,audit2why.so,--version-script=audit2why.map,-z,defs
+-
+ %.o:  %.c policy.h
+ 	$(CC) $(CFLAGS) $(TLSFLAGS) -c -o $@ $<
+ 
+ %.lo:  %.c policy.h
+ 	$(CC) $(CFLAGS) -fPIC -DSHARED -c -o $@ $<
+ 
+-$(SWIGCOUT): $(SWIGIF)
+-	$(SWIG) $<
+-
+-$(SWIGPYOUT): $(SWIGCOUT)
+-
+ $(SWIGRUBYCOUT): $(SWIGRUBYIF)
+ 	$(SWIGRUBY) $<
+ 
+-swigify: $(SWIGIF)
+-	$(SWIG) $<
+-
+ install: all 
+ 	test -d $(DESTDIR)$(LIBDIR) || install -m 755 -d $(DESTDIR)$(LIBDIR)
+ 	install -m 644 $(LIBA) $(DESTDIR)$(LIBDIR)
+@@ -194,10 +173,9 @@ install: all
+ 	ln -sf --relative $(DESTDIR)$(SHLIBDIR)/$(LIBSO) $(DESTDIR)$(LIBDIR)/$(TARGET)
+ 
+ install-pywrap: pywrap
+-	test -d $(DESTDIR)$(PYTHONLIBDIR)/selinux || install -m 755 -d $(DESTDIR)$(PYTHONLIBDIR)/selinux
+-	install -m 755 $(SWIGSO) $(DESTDIR)$(PYTHONLIBDIR)/_selinux$(PYCEXT)
+-	install -m 755 $(AUDIT2WHYSO) $(DESTDIR)$(PYTHONLIBDIR)/selinux/audit2why$(PYCEXT)
++	$(PYTHON) setup.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)`
+ 	install -m 644 $(SWIGPYOUT) $(DESTDIR)$(PYTHONLIBDIR)/selinux/__init__.py
++	ln -sf --relative $(DESTDIR)$(PYTHONLIBDIR)/selinux/_selinux$(PYCEXT) $(DESTDIR)$(PYTHONLIBDIR)/_selinux$(PYCEXT)
+ 
+ install-rubywrap: rubywrap
+ 	test -d $(DESTDIR)$(RUBYINSTALL) || install -m 755 -d $(DESTDIR)$(RUBYINSTALL) 
+@@ -208,6 +186,8 @@ relabel:
+ 
+ clean-pywrap:
+ 	-rm -f $(SWIGLOBJ) $(SWIGSO) $(AUDIT2WHYLOBJ) $(AUDIT2WHYSO)
++	$(PYTHON) setup.py clean
++	-rm -rf build *~ \#* *pyc .#*
+ 
+ clean-rubywrap:
+ 	-rm -f $(SWIGRUBYLOBJ) $(SWIGRUBYSO)
+diff --git libselinux/src/setup.py libselinux/src/setup.py
+new file mode 100644
+index 00000000..4dc03f55
+--- /dev/null
++++ libselinux/src/setup.py
+@@ -0,0 +1,24 @@
++#!/usr/bin/python3
++
++from distutils.core import Extension, setup
++
++setup(
++    name="selinux",
++    version="2.9",
++    description="SELinux python 3 bindings",
++    author="SELinux Project",
++    author_email="selinux@vger.kernel.org",
++    ext_modules=[
++        Extension('selinux._selinux',
++                  sources=['selinuxswig_python.i'],
++                  include_dirs=['../include'],
++                  library_dirs=['.'],
++                  libraries=['selinux']),
++        Extension('selinux.audit2why',
++                  sources=['audit2why.c'],
++                  include_dirs=['../include'],
++                  library_dirs=['.'],
++                  libraries=['selinux'],
++                  extra_link_args=['-l:libsepol.a', '-Wl,--version-script=audit2why.map'])
++    ],
++)
+-- 
+2.21.0
+
diff --git a/sys-libs/libselinux/libselinux-2.7.ebuild b/sys-libs/libselinux/libselinux-3.0.ebuild
similarity index 76%
rename from sys-libs/libselinux/libselinux-2.7.ebuild
rename to sys-libs/libselinux/libselinux-3.0.ebuild
index 52321c4..ced2a53 100644
--- a/sys-libs/libselinux/libselinux-2.7.ebuild
+++ b/sys-libs/libselinux/libselinux-3.0.ebuild
@@ -1,16 +1,16 @@
-# Copyright 1999-2017 Gentoo Foundation
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI="5"
-PYTHON_COMPAT=( python2_7 python3_4 python3_5 python3_6 )
-USE_RUBY="ruby22 ruby23"
+EAPI="6"
+PYTHON_COMPAT=( python3_{6..8} )
+USE_RUBY="ruby24 ruby25 ruby26"
 
 # No, I am not calling ruby-ng
-inherit multilib python-r1 toolchain-funcs eutils multilib-minimal
+inherit multilib python-r1 toolchain-funcs multilib-minimal
 
 MY_P="${P//_/-}"
 SEPOL_VER="${PV}"
-MY_RELEASEDATE="20170804"
+MY_RELEASEDATE="20191204"
 
 DESCRIPTION="SELinux userland library"
 HOMEPAGE="https://github.com/SELinuxProject/selinux/wiki"
@@ -20,14 +20,14 @@
 	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/${MY_RELEASEDATE}/${MY_P}.tar.gz"
+	SRC_URI="https://github.com/SELinuxProject/selinux/releases/download/${MY_RELEASEDATE}/${MY_P}.tar.gz"
 	KEYWORDS="*"
 	S="${WORKDIR}/${MY_P}"
 fi
 
 LICENSE="public-domain"
 SLOT="0"
-IUSE="pcre2 python ruby static-libs ruby_targets_ruby21 ruby_targets_ruby22 ruby_targets_ruby23"
+IUSE="pcre2 python ruby static-libs ruby_targets_ruby24 ruby_targets_ruby25 ruby_targets_ruby26"
 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
 
 RDEPEND=">=sys-libs/libsepol-${SEPOL_VER}:=[${MULTILIB_USEDEP}]
@@ -35,15 +35,18 @@
 	pcre2? ( dev-libs/libpcre2:=[static-libs?,${MULTILIB_USEDEP}] )
 	python? ( ${PYTHON_DEPS} )
 	ruby? (
-		ruby_targets_ruby22? ( dev-lang/ruby:2.2 )
-		ruby_targets_ruby23? ( dev-lang/ruby:2.3 )
-	)"
+		ruby_targets_ruby24? ( dev-lang/ruby:2.4 )
+		ruby_targets_ruby25? ( dev-lang/ruby:2.5 )
+		ruby_targets_ruby26? ( dev-lang/ruby:2.6 )
+	)
+	elibc_musl? ( sys-libs/fts-standalone )"
 DEPEND="${RDEPEND}
 	virtual/pkgconfig
-	python? ( >=dev-lang/swig-2.0.9 )"
+	python? ( >=dev-lang/swig-2.0.9 )
+	ruby? ( >=dev-lang/swig-2.0.9 )"
 
 src_prepare() {
-	epatch_user
+	eapply_user
 
 	multilib_copy_sources
 }
@@ -53,9 +56,10 @@
 
 	emake \
 		LIBDIR="\$(PREFIX)/$(get_libdir)" \
-		SHLIBDIR="\$(DESTDIR)/$(get_libdir)" \
+		SHLIBDIR="/$(get_libdir)" \
 		LDFLAGS="-fPIC ${LDFLAGS} -pthread" \
 		USE_PCRE2="$(usex pcre2 y n)" \
+		FTS_LDLIBS="$(usex elibc_musl '-lfts' '')" \
 		all
 
 	if multilib_is_native_abi && use python; then
@@ -63,8 +67,9 @@
 			emake \
 				LDFLAGS="-fPIC ${LDFLAGS} -lpthread" \
 				LIBDIR="\$(PREFIX)/$(get_libdir)" \
-				SHLIBDIR="\$(DESTDIR)/$(get_libdir)" \
+				SHLIBDIR="/$(get_libdir)" \
 				USE_PCRE2="$(usex pcre2 y n)" \
+				FTS_LDLIBS="$(usex elibc_musl '-lfts' '')" \
 				pywrap
 		}
 		python_foreach_impl building
@@ -79,8 +84,9 @@
 				RUBY=${1} \
 				LDFLAGS="-fPIC ${LDFLAGS} -lpthread" \
 				LIBDIR="\$(PREFIX)/$(get_libdir)" \
-				SHLIBDIR="\$(DESTDIR)/$(get_libdir)" \
+				SHLIBDIR="/$(get_libdir)" \
 				USE_PCRE2="$(usex pcre2 y n)" \
+				FTS_LDLIBS="$(usex elibc_musl '-lfts' '')" \
 				rubywrap
 		}
 		for RUBYTARGET in ${USE_RUBY}; do
@@ -94,8 +100,7 @@
 multilib_src_install() {
 	emake DESTDIR="${D}" \
 		LIBDIR="\$(PREFIX)/$(get_libdir)" \
-		SHLIBDIR="\$(DESTDIR)/$(get_libdir)" \
-		LIBSEPOLA="/usr/$(get_libdir)/libsepol.a" \
+		SHLIBDIR="/$(get_libdir)" \
 		USE_PCRE2="$(usex pcre2 y n)" \
 		install
 
@@ -103,7 +108,7 @@
 		installation() {
 			emake DESTDIR="${D}" \
 				LIBDIR="\$(PREFIX)/$(get_libdir)" \
-				LIBSEPOLA="/usr/$(get_libdir)/libsepol.a" \
+				SHLIBDIR="/$(get_libdir)" \
 				USE_PCRE2="$(usex pcre2 y n)" \
 				install-pywrap
 			python_optimize # bug 531638
@@ -118,7 +123,7 @@
 			rm src/selinuxswig_ruby_wrap.lo
 			emake DESTDIR="${D}" \
 				LIBDIR="\$(PREFIX)/$(get_libdir)" \
-				LIBSEPOLA="/usr/$(get_libdir)/libsepol.a" \
+				SHLIBDIR="/$(get_libdir)" \
 				RUBY=${1} \
 				USE_PCRE2="$(usex pcre2 y n)" \
 				install-rubywrap
diff --git a/sys-libs/libselinux/metadata.xml b/sys-libs/libselinux/metadata.xml
index d779663..92059a5 100644
--- a/sys-libs/libselinux/metadata.xml
+++ b/sys-libs/libselinux/metadata.xml
@@ -14,7 +14,7 @@
 		<flag name="pcre2">Use <pkg>dev-libs/libpcre2</pkg> for fcontext regexes</flag>
 	</use>
 	<upstream>
-		<remote-id type="github">SELinuxProject/selinux</remote-id>
 		<remote-id type="cpe">cpe:/a:selinuxproject:libselinux</remote-id>
+		<remote-id type="github">SELinuxProject/selinux</remote-id>
 	</upstream>
 </pkgmetadata>
diff --git a/sys-libs/libsepol/Manifest b/sys-libs/libsepol/Manifest
index 2bdf05b..f7a75b9 100644
--- a/sys-libs/libsepol/Manifest
+++ b/sys-libs/libsepol/Manifest
@@ -1 +1 @@
-DIST libsepol-2.7.tar.gz 471147 SHA256 d69d3bd8ec901a3bd5adf2be2fb47fb1a685ed73066ab482e7e505371a48f9e7 SHA512 1d308c17bfea2659f9dc4877ab685449a5a33dff7260e62b603cde9551bed2010360b71a896c6dfcdb8b9fe86ecebc9f6b3225e6c3573a80fca8578a9d561b47 WHIRLPOOL d89ac1e892a3b1a05221bcdaecab2e9bdb1dbe035133da052b04868152891ee994d266a64508ae4077a3859863a10efc49088f6ae12a5cf5beef571c1c932c80
+DIST libsepol-3.0.tar.gz 473864 BLAKE2B ff4da6e12c1635de88a2aaba26bd3630576a3806543d7176d8fbdb4deda5c9c5fbf8a5a4f68c8041cca0af97429e720d908cd31052d13ac72780bc85db1f56c8 SHA512 82a5bae0afd9ae53b55ddcfc9f6dd61724a55e45aef1d9cd0122d1814adf2abe63c816a7ac63b64b401f5c67acb910dd8e0574eec546bed04da7842ab6c3bb55
diff --git a/sys-libs/libsepol/files/libsepol-2.7-add-ability-to-redeclare-types-attributes.patch b/sys-libs/libsepol/files/libsepol-2.7-add-ability-to-redeclare-types-attributes.patch
deleted file mode 100644
index 1d00571..0000000
--- a/sys-libs/libsepol/files/libsepol-2.7-add-ability-to-redeclare-types-attributes.patch
+++ /dev/null
@@ -1,153 +0,0 @@
-From fafe4c212bf6c32c3021d7b69bcc0cf219e71608 Mon Sep 17 00:00:00 2001
-From: Dan Cashman <dcashman@android.com>
-Date: Tue, 29 Aug 2017 09:32:05 -0700
-Subject: [PATCH 03/12] libsepol: cil: Add ability to redeclare
- types[attributes]
-
-Modify cil_gen_node() to check to see if the cil_db supports multiple
-declarations, and if so, to check whether or not the
-repeated symbol is eligible to share the existing, already-stored datum. The
-only types considered so far are CIL_TYPE and CIL_TYPEATTRIBUTE, both of
-which intall empty datums during AST building, so they automatically return
-true.
-
-Test: Build policy with multilpe type and attribute declarations, and
-without. Policies are binary-identical.
-
-Signed-off-by: Dan Cashman <dcashman@android.com>
-Signed-off-by: James Carter <jwcart2@tycho.nsa.gov>
----
- libsepol/cil/include/cil/cil.h   |  1 +
- libsepol/cil/src/cil.c           |  5 ++++
- libsepol/cil/src/cil_build_ast.c | 48 +++++++++++++++++++++++++++-----
- libsepol/cil/src/cil_internal.h  |  1 +
- libsepol/src/libsepol.map.in     |  1 +
- 5 files changed, 49 insertions(+), 7 deletions(-)
-
-diff --git a/libsepol/cil/include/cil/cil.h b/libsepol/cil/include/cil/cil.h
-index 86117f24..f8cfc3be 100644
---- a/libsepol/cil/include/cil/cil.h
-+++ b/libsepol/cil/include/cil/cil.h
-@@ -50,6 +50,7 @@ extern int cil_userprefixes_to_string(cil_db_t *db, char **out, size_t *size);
- extern int cil_selinuxusers_to_string(cil_db_t *db, char **out, size_t *size);
- extern int cil_filecons_to_string(cil_db_t *db, char **out, size_t *size);
- extern void cil_set_disable_dontaudit(cil_db_t *db, int disable_dontaudit);
-+extern void cil_set_multiple_decls(cil_db_t *db, int multiple_decls);
- extern void cil_set_disable_neverallow(cil_db_t *db, int disable_neverallow);
- extern void cil_set_preserve_tunables(cil_db_t *db, int preserve_tunables);
- extern int cil_set_handle_unknown(cil_db_t *db, int handle_unknown);
-diff --git a/libsepol/cil/src/cil.c b/libsepol/cil/src/cil.c
-index c02a41a5..3fe68af8 100644
---- a/libsepol/cil/src/cil.c
-+++ b/libsepol/cil/src/cil.c
-@@ -1691,6 +1691,11 @@ void cil_set_mls(struct cil_db *db, int mls)
- 	db->mls = mls;
- }
- 
-+void cil_set_multiple_decls(struct cil_db *db, int multiple_decls)
-+{
-+	db->multiple_decls = multiple_decls;
-+}
-+
- void cil_set_target_platform(struct cil_db *db, int target_platform)
- {
- 	db->target_platform = target_platform;
-diff --git a/libsepol/cil/src/cil_build_ast.c b/libsepol/cil/src/cil_build_ast.c
-index 04492e52..9fc8ab87 100644
---- a/libsepol/cil/src/cil_build_ast.c
-+++ b/libsepol/cil/src/cil_build_ast.c
-@@ -82,10 +82,33 @@ exit:
- 	return rc;
- }
- 
-+/*
-+ * Determine whether or not multiple declarations of the same key can share a
-+ * datum, given the new datum and the one already present in a given symtab.
-+ */
-+int cil_is_datum_multiple_decl(__attribute__((unused)) struct cil_symtab_datum *cur,
-+                               __attribute__((unused)) struct cil_symtab_datum *old,
-+                               enum cil_flavor f)
-+{
-+	int rc = CIL_FALSE;
-+
-+	switch (f) {
-+	case CIL_TYPE:
-+	case CIL_TYPEATTRIBUTE:
-+		/* type and typeattribute statements insert empty datums, ret true */
-+		rc = CIL_TRUE;
-+		break;
-+	default:
-+		break;
-+	}
-+	return rc;
-+}
-+
- int cil_gen_node(__attribute__((unused)) struct cil_db *db, struct cil_tree_node *ast_node, struct cil_symtab_datum *datum, hashtab_key_t key, enum cil_sym_index sflavor, enum cil_flavor nflavor)
- {
- 	int rc = SEPOL_ERR;
- 	symtab_t *symtab = NULL;
-+	struct cil_symtab_datum *prev;
- 
- 	rc = __cil_verify_name((const char*)key);
- 	if (rc != SEPOL_OK) {
-@@ -103,15 +126,26 @@ int cil_gen_node(__attribute__((unused)) struct cil_db *db, struct cil_tree_node
- 	if (symtab != NULL) {
- 		rc = cil_symtab_insert(symtab, (hashtab_key_t)key, datum, ast_node);
- 		if (rc == SEPOL_EEXIST) {
--			cil_log(CIL_ERR, "Re-declaration of %s %s\n", 
--				cil_node_to_string(ast_node), key);
--			if (cil_symtab_get_datum(symtab, key, &datum) == SEPOL_OK) {
--				if (sflavor == CIL_SYM_BLOCKS) {
--					struct cil_tree_node *node = datum->nodes->head->data;
--					cil_tree_log(node, CIL_ERR, "Previous declaration");
-+			if (!db->multiple_decls ||
-+			    cil_symtab_get_datum(symtab, (hashtab_key_t)key, &prev) != SEPOL_OK ||
-+			    !cil_is_datum_multiple_decl(datum, prev, nflavor)) {
-+
-+				/* multiple_decls not ok, ret error */
-+				cil_log(CIL_ERR, "Re-declaration of %s %s\n",
-+					cil_node_to_string(ast_node), key);
-+				if (cil_symtab_get_datum(symtab, key, &datum) == SEPOL_OK) {
-+					if (sflavor == CIL_SYM_BLOCKS) {
-+						struct cil_tree_node *node = datum->nodes->head->data;
-+						cil_tree_log(node, CIL_ERR, "Previous declaration");
-+					}
- 				}
-+				goto exit;
- 			}
--			goto exit;
-+			/* multiple_decls is enabled and works for this datum type, add node */
-+			cil_list_append(prev->nodes, CIL_NODE, ast_node);
-+			ast_node->data = prev;
-+			cil_symtab_datum_destroy(datum);
-+			free(datum);
- 		}
- 	}
- 
-diff --git a/libsepol/cil/src/cil_internal.h b/libsepol/cil/src/cil_internal.h
-index 6d6a7d90..136a0049 100644
---- a/libsepol/cil/src/cil_internal.h
-+++ b/libsepol/cil/src/cil_internal.h
-@@ -316,6 +316,7 @@ struct cil_db {
- 	int preserve_tunables;
- 	int handle_unknown;
- 	int mls;
-+	int multiple_decls;
- 	int target_platform;
- 	int policy_version;
- };
-diff --git a/libsepol/src/libsepol.map.in b/libsepol/src/libsepol.map.in
-index dd1fec21..2a9996f7 100644
---- a/libsepol/src/libsepol.map.in
-+++ b/libsepol/src/libsepol.map.in
-@@ -49,6 +49,7 @@ LIBSEPOL_1.1 {
- 	cil_set_mls;
- 	cil_set_attrs_expand_generated;
- 	cil_set_attrs_expand_size;
-+	cil_set_multiple_decls;
- 	cil_write_policy_conf;
- 	sepol_ppfile_to_module_package;
- 	sepol_module_package_to_cil;
--- 
-2.16.1.291.g4437f3f132-goog
-
diff --git a/sys-libs/libsepol/files/libsepol-2.7-create-new-keep-field-for-type-attribute-sets.patch b/sys-libs/libsepol/files/libsepol-2.7-create-new-keep-field-for-type-attribute-sets.patch
deleted file mode 100644
index ffd12fc..0000000
--- a/sys-libs/libsepol/files/libsepol-2.7-create-new-keep-field-for-type-attribute-sets.patch
+++ /dev/null
@@ -1,138 +0,0 @@
-From 2d49a4b41c6ecbcf254e6045f2e01f677ad58ffe Mon Sep 17 00:00:00 2001
-From: James Carter <jwcart2@tycho.nsa.gov>
-Date: Fri, 17 Nov 2017 08:09:52 -0500
-Subject: [PATCH 11/12] libsepol/cil: Create new keep field for type attribute
- sets
-
-Daniel Cashman <dcashman@android.com> discovered the following:
-When using cil_db multiple_decls, the different cil_attribute nodes
-all point to the same underlying cil_attribute struct.  This leads
-to problems, though, when modifying the used value in the struct.
-__cil_post_db_attr() changes the value of the field to based on
-the output of cil_typeattribute_used(), for use later in
-cil_typeattribute_to_policydb and cil_typeattribute_to_bitmap, but
-due to the multiple declarations, cil_typeattribute_used() could be
-called again by a second node.  In this second call, the value used
-is the modifed value of CIL_TRUE or CIL_FALSE, not the flags actually
-needed. This could result in the field being reset again, to an
-incorrect CIL_FALSE value.
-
-Add the field "keep" to struct cil_typeattributeset, set its value
-using cil_typeattribute_used(), and use it when determining whether
-the attribute is to be kept or if it should be expanded.
-
-Signed-off-by: James Carter <jwcart2@tycho.nsa.gov>
----
- libsepol/cil/src/cil.c           | 1 +
- libsepol/cil/src/cil_binary.c    | 8 ++++----
- libsepol/cil/src/cil_internal.h  | 1 +
- libsepol/cil/src/cil_policy.c    | 2 +-
- libsepol/cil/src/cil_post.c      | 2 +-
- libsepol/cil/src/cil_reset_ast.c | 1 +
- 6 files changed, 9 insertions(+), 6 deletions(-)
-
-diff --git a/libsepol/cil/src/cil.c b/libsepol/cil/src/cil.c
-index 3fe68af8..5a64c2bc 100644
---- a/libsepol/cil/src/cil.c
-+++ b/libsepol/cil/src/cil.c
-@@ -2064,6 +2064,7 @@ void cil_typeattribute_init(struct cil_typeattribute **attr)
- 	(*attr)->expr_list = NULL;
- 	(*attr)->types = NULL;
- 	(*attr)->used = CIL_FALSE;
-+	(*attr)->keep = CIL_FALSE;
- }
- 
- void cil_typeattributeset_init(struct cil_typeattributeset **attrset)
-diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c
-index c0ca60f2..431cd9cd 100644
---- a/libsepol/cil/src/cil_binary.c
-+++ b/libsepol/cil/src/cil_binary.c
-@@ -567,7 +567,7 @@ int cil_typeattribute_to_policydb(policydb_t *pdb, struct cil_typeattribute *cil
- 	char *key = NULL;
- 	type_datum_t *sepol_attr = NULL;
- 
--	if (!cil_attr->used) {
-+	if (!cil_attr->keep) {
- 		return SEPOL_OK;		
- 	}
- 
-@@ -632,7 +632,7 @@ int cil_typeattribute_to_bitmap(policydb_t *pdb, const struct cil_db *db, struct
- 	ebitmap_node_t *tnode;
- 	unsigned int i;
- 
--	if (!cil_attr->used) {
-+	if (!cil_attr->keep) {
- 		return SEPOL_OK;
- 	}
- 
-@@ -1442,7 +1442,7 @@ static int __cil_should_expand_attribute( const struct cil_db *db, struct cil_sy
- 
- 	attr = (struct cil_typeattribute *)datum;
- 
--	return !attr->used || (ebitmap_cardinality(attr->types) < db->attrs_expand_size);
-+	return !attr->keep || (ebitmap_cardinality(attr->types) < db->attrs_expand_size);
- }
- 
- int __cil_avrule_to_avtab(policydb_t *pdb, const struct cil_db *db, struct cil_avrule *cil_avrule, cond_node_t *cond_node, enum cil_flavor cond_flavor)
-@@ -2525,7 +2525,7 @@ int __cil_constrain_expr_datum_to_sepol_expr(policydb_t *pdb, const struct cil_d
- 			if (rc != SEPOL_OK) {
- 				if (FLAVOR(item->data) == CIL_TYPEATTRIBUTE) {
- 					struct cil_typeattribute *attr = item->data;
--					if (!attr->used) {
-+					if (!attr->keep) {
- 						rc = 0;
- 					}
- 				}
-diff --git a/libsepol/cil/src/cil_internal.h b/libsepol/cil/src/cil_internal.h
-index 136a0049..8393e391 100644
---- a/libsepol/cil/src/cil_internal.h
-+++ b/libsepol/cil/src/cil_internal.h
-@@ -531,6 +531,7 @@ struct cil_typeattribute {
- 	struct cil_list *expr_list;
- 	ebitmap_t *types;
- 	int used;	// whether or not this attribute was used in a binary policy rule
-+	int keep;
- };
- 
- struct cil_typeattributeset {
-diff --git a/libsepol/cil/src/cil_policy.c b/libsepol/cil/src/cil_policy.c
-index 6d4987c4..99eb53c2 100644
---- a/libsepol/cil/src/cil_policy.c
-+++ b/libsepol/cil/src/cil_policy.c
-@@ -1085,7 +1085,7 @@ static void cil_typeattributes_to_policy(FILE *out, struct cil_list *types, stru
- 		type = i1->data;
- 		cil_list_for_each(i2, attributes) {
- 			attribute = i2->data;
--			if (!attribute->used)
-+			if (!attribute->keep)
- 				continue;
- 			if (ebitmap_get_bit(attribute->types, type->value)) {
- 				if (first) {
-diff --git a/libsepol/cil/src/cil_post.c b/libsepol/cil/src/cil_post.c
-index 3e013c97..a2122454 100644
---- a/libsepol/cil/src/cil_post.c
-+++ b/libsepol/cil/src/cil_post.c
-@@ -1369,7 +1369,7 @@ static int __cil_post_db_attr_helper(struct cil_tree_node *node, uint32_t *finis
- 			rc = __evaluate_type_expression(attr, db);
- 			if (rc != SEPOL_OK) goto exit;
- 		}
--		attr->used = cil_typeattribute_used(attr, db);
-+		attr->keep = cil_typeattribute_used(attr, db);
- 		break;
- 	}
- 	case CIL_ROLEATTRIBUTE: {
-diff --git a/libsepol/cil/src/cil_reset_ast.c b/libsepol/cil/src/cil_reset_ast.c
-index 8a13a1c1..43e6b88e 100644
---- a/libsepol/cil/src/cil_reset_ast.c
-+++ b/libsepol/cil/src/cil_reset_ast.c
-@@ -186,6 +186,7 @@ static void cil_reset_typeattr(struct cil_typeattribute *attr)
- 		attr->expr_list = NULL;
- 	}
- 	attr->used = CIL_FALSE;
-+	attr->keep = CIL_FALSE;
- }
- 
- static void cil_reset_typeattributeset(struct cil_typeattributeset *tas)
--- 
-2.16.1.291.g4437f3f132-goog
-
diff --git a/sys-libs/libsepol/files/libsepol-2.7-keep-attributes-used-by-generated-attributes-in-neverallow-rules.patch b/sys-libs/libsepol/files/libsepol-2.7-keep-attributes-used-by-generated-attributes-in-neverallow-rules.patch
deleted file mode 100644
index f3ba21f..0000000
--- a/sys-libs/libsepol/files/libsepol-2.7-keep-attributes-used-by-generated-attributes-in-neverallow-rules.patch
+++ /dev/null
@@ -1,119 +0,0 @@
-From 67b410e80f0917bf1b378997cac0dddf1e6406f7 Mon Sep 17 00:00:00 2001
-From: James Carter <jwcart2@tycho.nsa.gov>
-Date: Wed, 30 Aug 2017 14:22:28 -0400
-Subject: [PATCH 04/12] libsepol/cil: Keep attributes used by generated
- attributes in neverallow rules
-
-In order to reduce policy size, CIL removes attributes that are not used
-by a policy rule in the generated binary policy. However, CIL keeps
-attributes used by neverallow rules (which are checked at compile time
-and not in the binary policy) even if the attribute is not used anywhere
-else in the policy. This behavior is useful to Google who pulls neverallow
-rules out of the original policy.conf for compatibility testing, but
-converts the policy.conf to CIL and uses the CIL compiler to generate
-policy. Without this behavior, the generated binary policy might not have
-an attribute referred to by one of the neverallow rules used for testing.
-
-The one exception to this behavior is for attributes generated in
-module_to_cil (these have an "_typeattr_" in the middle of their name).
-Since these attributes are only created because CIL does not allow a
-type expression in an AV rule, they are removed if they only appear in
-a neverallow rule (which is the case for most of them) or if the
-option to expand generated attributes (-G or --expand-generated) is
-specified for secilc when compiling the policy.
-
-Removing generated attributes causes a problem, however, if the type
-expression that the generated attribute is replacing uses an attribute
-that is removed. In this case, the original neverallow rule will refer
-to an attribute that does not exist in the generated binary policy.
-
-Now any non-generated attribute used in a typeattributeset rule for a
-generated attribute which is used in a neverallow rule will be treated
-like it was used in a neverallow rule.
-
-This does not change the behavior of an expandtypeattribute rule for
-the attribute. That rule, if it exists, will take precedence.
-
-Signed-off-by: James Carter <jwcart2@tycho.nsa.gov>
----
- libsepol/cil/src/cil_post.c | 57 +++++++++++++++++++++++++++++++++++++
- 1 file changed, 57 insertions(+)
-
-diff --git a/libsepol/cil/src/cil_post.c b/libsepol/cil/src/cil_post.c
-index ad073e8e..ee693d47 100644
---- a/libsepol/cil/src/cil_post.c
-+++ b/libsepol/cil/src/cil_post.c
-@@ -1297,6 +1297,57 @@ static int cil_typeattribute_used(struct cil_typeattribute *attr, struct cil_db
- 	return CIL_TRUE;
- }
- 
-+static void __mark_neverallow_attrs(struct cil_list *expr_list)
-+{
-+	struct cil_list_item *curr;
-+
-+	cil_list_for_each(curr, expr_list) {
-+		if (curr->flavor == CIL_DATUM) {
-+			if (NODE(curr->data)->flavor == CIL_TYPEATTRIBUTE) {
-+				struct cil_typeattribute *attr = curr->data;
-+				if (strstr(DATUM(attr)->name, TYPEATTR_INFIX)) {
-+					__mark_neverallow_attrs(attr->expr_list);
-+				} else {
-+					attr->used |= CIL_ATTR_NEVERALLOW;
-+				}
-+			}
-+		} else if (curr->flavor == CIL_LIST) {
-+			 __mark_neverallow_attrs(curr->data);
-+		}
-+	}
-+}
-+
-+static int __cil_post_db_neverallow_attr_helper(struct cil_tree_node *node, uint32_t *finished, void *extra_args)
-+{
-+	struct cil_db *db = extra_args;
-+
-+	switch (node->flavor) {
-+	case CIL_BLOCK: {
-+		struct cil_block *blk = node->data;
-+		if (blk->is_abstract == CIL_TRUE) {
-+			*finished = CIL_TREE_SKIP_HEAD;
-+		}
-+		break;
-+	}
-+	case CIL_MACRO: {
-+		*finished = CIL_TREE_SKIP_HEAD;
-+		break;
-+	}
-+	case CIL_TYPEATTRIBUTE: {
-+		struct cil_typeattribute *attr = node->data;
-+		if ((attr->used & CIL_ATTR_NEVERALLOW) &&
-+		    strstr(DATUM(attr)->name, TYPEATTR_INFIX)) {
-+			__mark_neverallow_attrs(attr->expr_list);
-+		}
-+		break;
-+	}
-+	default:
-+		break;
-+	}
-+
-+	return SEPOL_OK;
-+}
-+
- static int __cil_post_db_attr_helper(struct cil_tree_node *node, uint32_t *finished, void *extra_args)
- {
- 	int rc = SEPOL_ERR;
-@@ -2031,6 +2082,12 @@ static int cil_post_db(struct cil_db *db)
- 		goto exit;
- 	}
- 
-+	rc = cil_tree_walk(db->ast->root, __cil_post_db_neverallow_attr_helper, NULL, NULL, db);
-+	if (rc != SEPOL_OK) {
-+		cil_log(CIL_INFO, "Failed to mark attributes used by generated attributes used in neverallow rules\n");
-+		goto exit;
-+	}
-+
- 	rc = cil_tree_walk(db->ast->root, __cil_post_db_attr_helper, NULL, NULL, db);
- 	if (rc != SEPOL_OK) {
- 		cil_log(CIL_INFO, "Failed to create attribute bitmaps\n");
--- 
-2.16.1.291.g4437f3f132-goog
-
diff --git a/sys-libs/libsepol/libsepol-2.7-r1.ebuild b/sys-libs/libsepol/libsepol-2.7-r1.ebuild
deleted file mode 120000
index 6fe2258..0000000
--- a/sys-libs/libsepol/libsepol-2.7-r1.ebuild
+++ /dev/null
@@ -1 +0,0 @@
-libsepol-2.7.ebuild
\ No newline at end of file
diff --git a/sys-libs/libsepol/libsepol-2.7.ebuild b/sys-libs/libsepol/libsepol-2.7.ebuild
deleted file mode 100644
index f84342b..0000000
--- a/sys-libs/libsepol/libsepol-2.7.ebuild
+++ /dev/null
@@ -1,51 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-inherit multilib toolchain-funcs eutils multilib-minimal
-
-MY_P="${P//_/-}"
-MY_RELEASEDATE="20170804"
-
-DESCRIPTION="SELinux binary policy representation 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/${MY_RELEASEDATE}/${MY_P}.tar.gz"
-	KEYWORDS="*"
-	S="${WORKDIR}/${MY_P}"
-fi
-
-LICENSE="GPL-2"
-SLOT="0"
-IUSE=""
-
-DEPEND=""
-RDEPEND=""
-
-# tests are not meant to be run outside of the full SELinux userland repo
-RESTRICT="test"
-
-src_prepare() {
-	epatch_user
-	epatch "${FILESDIR}/libsepol-2.7-add-ability-to-redeclare-types-attributes.patch"
-	epatch "${FILESDIR}/libsepol-2.7-keep-attributes-used-by-generated-attributes-in-neverallow-rules.patch"
-	epatch "${FILESDIR}/libsepol-2.7-create-new-keep-field-for-type-attribute-sets.patch"
-	multilib_copy_sources
-}
-
-multilib_src_compile() {
-	tc-export RANLIB;
-	LIBDIR="\$(PREFIX)/$(get_libdir)" SHLIBDIR="\$(DESTDIR)/$(get_libdir)" \
-		emake AR="$(tc-getAR)" CC="$(tc-getCC)"
-}
-
-multilib_src_install() {
-	LIBDIR="\$(PREFIX)/$(get_libdir)" SHLIBDIR="\$(DESTDIR)/$(get_libdir)" \
-		emake DESTDIR="${D}" install
-}
diff --git a/sys-libs/libsepol/libsepol-3.0.ebuild b/sys-libs/libsepol/libsepol-3.0.ebuild
new file mode 100644
index 0000000..d95e282
--- /dev/null
+++ b/sys-libs/libsepol/libsepol-3.0.ebuild
@@ -0,0 +1,55 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="6"
+
+inherit multilib toolchain-funcs multilib-minimal
+
+MY_P="${P//_/-}"
+MY_RELEASEDATE="20191204"
+
+DESCRIPTION="SELinux binary policy representation 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://github.com/SELinuxProject/selinux/releases/download/${MY_RELEASEDATE}/${MY_P}.tar.gz"
+	KEYWORDS="*"
+	S="${WORKDIR}/${MY_P}"
+fi
+
+LICENSE="GPL-2"
+SLOT="0"
+IUSE=""
+
+DEPEND=""
+RDEPEND=""
+
+# tests are not meant to be run outside of the full SELinux userland repo
+RESTRICT="test"
+
+src_prepare() {
+	eapply_user
+	multilib_copy_sources
+}
+
+multilib_src_compile() {
+	tc-export CC AR RANLIB
+
+	# https://bugs.gentoo.org/706730
+	local -x CFLAGS="${CFLAGS} -fcommon"
+
+	emake \
+		LIBDIR="\$(PREFIX)/$(get_libdir)" \
+		SHLIBDIR="/$(get_libdir)"
+}
+
+multilib_src_install() {
+	emake DESTDIR="${D}" \
+		LIBDIR="\$(PREFIX)/$(get_libdir)" \
+		SHLIBDIR="/$(get_libdir)" \
+		install
+}
diff --git a/sys-libs/libsepol/metadata.xml b/sys-libs/libsepol/metadata.xml
index 98f9437..1ff444a 100644
--- a/sys-libs/libsepol/metadata.xml
+++ b/sys-libs/libsepol/metadata.xml
@@ -7,7 +7,7 @@
 	</maintainer>
 	<longdescription>SELinux library for manipulating binary security policies</longdescription>
 	<upstream>
-		<remote-id type="github">SELinuxProject/selinux</remote-id>
 		<remote-id type="cpe">cpe:/a:selinuxproject:libsepol</remote-id>
+		<remote-id type="github">SELinuxProject/selinux</remote-id>
 	</upstream>
 </pkgmetadata>