sys-process/glances: revbump 3.1.4.1, add missing doc dep
[gentoo.git] / sys-libs / libsemanage / libsemanage-3.0.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="6"
5 PYTHON_COMPAT=( python{3_6,3_7,3_8} )
6
7 inherit multilib python-r1 toolchain-funcs multilib-minimal
8
9 MY_P="${P//_/-}"
10 MY_RELEASEDATE="20191204"
11
12 SEPOL_VER="${PV}"
13 SELNX_VER="${PV}"
14
15 DESCRIPTION="SELinux kernel and policy management library"
16 HOMEPAGE="https://github.com/SELinuxProject/selinux/wiki"
17
18 if [[ ${PV} == 9999 ]]; then
19         inherit git-r3
20         EGIT_REPO_URI="https://github.com/SELinuxProject/selinux.git"
21         S="${WORKDIR}/${MY_P}/${PN}"
22 else
23         SRC_URI="https://github.com/SELinuxProject/selinux/releases/download/${MY_RELEASEDATE}/${MY_P}.tar.gz"
24         KEYWORDS="amd64 ~arm ~arm64 ~mips x86"
25         S="${WORKDIR}/${MY_P}"
26 fi
27
28 LICENSE="GPL-2"
29 SLOT="0"
30 IUSE="python"
31 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
32
33 RDEPEND=">=sys-libs/libsepol-${SEPOL_VER}[${MULTILIB_USEDEP}]
34         >=sys-libs/libselinux-${SELNX_VER}[${MULTILIB_USEDEP}]
35         >=sys-process/audit-2.2.2[${MULTILIB_USEDEP}]
36         >=dev-libs/ustr-1.0.4-r2[${MULTILIB_USEDEP}]
37         python? ( ${PYTHON_DEPS} )"
38 DEPEND="${RDEPEND}
39         sys-devel/bison
40         sys-devel/flex
41         python? (
42                 >=dev-lang/swig-2.0.4-r1
43                 virtual/pkgconfig
44         )"
45
46 # tests are not meant to be run outside of the
47 # full SELinux userland repo
48 RESTRICT="test"
49
50 src_prepare() {
51         eapply_user
52
53         echo >> "${S}/src/semanage.conf"
54         echo "# Set this to true to save the linked policy." >> "${S}/src/semanage.conf"
55         echo "# This is normally only useful for analysis" >> "${S}/src/semanage.conf"
56         echo "# or debugging of policy." >> "${S}/src/semanage.conf"
57         echo "save-linked=false" >> "${S}/src/semanage.conf"
58         echo >> "${S}/src/semanage.conf"
59         echo "# Set this to 0 to disable assertion checking." >> "${S}/src/semanage.conf"
60         echo "# This should speed up building the kernel policy" >> "${S}/src/semanage.conf"
61         echo "# from policy modules, but may leave you open to" >> "${S}/src/semanage.conf"
62         echo "# dangerous rules which assertion checking" >> "${S}/src/semanage.conf"
63         echo "# would catch." >> "${S}/src/semanage.conf"
64         echo "expand-check=1" >> "${S}/src/semanage.conf"
65         echo >> "${S}/src/semanage.conf"
66         echo "# Modules in the module store can be compressed" >> "${S}/src/semanage.conf"
67         echo "# with bzip2.  Set this to the bzip2 blocksize" >> "${S}/src/semanage.conf"
68         echo "# 1-9 when compressing.  The higher the number," >> "${S}/src/semanage.conf"
69         echo "# the more memory is traded off for disk space." >> "${S}/src/semanage.conf"
70         echo "# Set to 0 to disable bzip2 compression." >> "${S}/src/semanage.conf"
71         echo "bzip-blocksize=0" >> "${S}/src/semanage.conf"
72         echo >> "${S}/src/semanage.conf"
73         echo "# Reduce memory usage for bzip2 compression and" >> "${S}/src/semanage.conf"
74         echo "# decompression of modules in the module store." >> "${S}/src/semanage.conf"
75         echo "bzip-small=true" >> "${S}/src/semanage.conf"
76
77         multilib_copy_sources
78 }
79
80 multilib_src_compile() {
81         emake \
82                 AR="$(tc-getAR)" \
83                 CC="$(tc-getCC)" \
84                 LIBDIR="${EPREFIX}/usr/$(get_libdir)" \
85                 all
86
87         if multilib_is_native_abi && use python; then
88                 building_py() {
89                         emake \
90                                 AR="$(tc-getAR)" \
91                                 CC="$(tc-getCC)" \
92                                 LIBDIR="${EPREFIX}/usr/$(get_libdir)" \
93                                 "$@"
94                 }
95                 python_foreach_impl building_py swigify
96                 python_foreach_impl building_py pywrap
97         fi
98 }
99
100 multilib_src_install() {
101         emake \
102                 LIBDIR="${EPREFIX}/usr/$(get_libdir)" \
103                 DESTDIR="${ED}" install
104
105         if multilib_is_native_abi && use python; then
106                 installation_py() {
107                         emake DESTDIR="${ED}" \
108                                 LIBDIR="${EPREFIX}/usr/$(get_libdir)" \
109                                 install-pywrap
110                         python_optimize # bug 531638
111                 }
112                 python_foreach_impl installation_py
113         fi
114 }
115
116 pkg_postinst() {
117         # Migrate the SELinux semanage configuration store if not done already
118         local selinuxtype=$(awk -F'=' '/SELINUXTYPE=/ {print $2}' "${EROOT}"/etc/selinux/config 2>/dev/null)
119         if [ -n "${selinuxtype}" ] && [ ! -d "${EROOT}"/var/lib/selinux/${selinuxtype}/active ] ; then
120                 ewarn "Since the 2.4 SELinux userspace, the policy module store is moved"
121                 ewarn "from /etc/selinux to /var/lib/selinux. The migration will be run now."
122                 ewarn "If there are any issues, it can be done manually by running:"
123                 ewarn "/usr/libexec/selinux/semanage_migrate_store"
124                 ewarn "For more information, please see"
125                 ewarn "- https://github.com/SELinuxProject/selinux/wiki/Policy-Store-Migration"
126         fi
127
128         # Run the store migration without rebuilds
129         for POLICY_TYPE in ${POLICY_TYPES} ; do
130                 if [ ! -d "${EROOT}/var/lib/selinux/${POLICY_TYPE}/active" ] ; then
131                         einfo "Migrating store ${POLICY_TYPE} (without policy rebuild)."
132                         "${EROOT}/usr/libexec/selinux/semanage_migrate_store" -n -s "${POLICY_TYPE}" || die "Failed to migrate store ${POLICY_TYPE}"
133                 fi
134         done
135 }