*/*: [QA] Fix trivial cases of MissingTestRestrict
[gentoo.git] / dev-libs / libcgroup / libcgroup-0.41-r6.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit autotools flag-o-matic linux-info pam systemd
7
8 DESCRIPTION="Tools and libraries to configure and manage kernel control groups"
9 HOMEPAGE="http://libcg.sourceforge.net/"
10 SRC_URI="mirror://sourceforge/project/libcg/${PN}/v${PV}/${P}.tar.bz2"
11
12 LICENSE="LGPL-2.1"
13 SLOT="0"
14 KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~x86"
15 IUSE="+daemon elibc_musl pam static-libs test +tools"
16 REQUIRED_USE="daemon? ( tools )"
17
18 # Use mount cgroup to build directory
19 # sandbox restricted to trivial build,
20 RESTRICT="test"
21
22 BDEPEND="
23         sys-devel/bison
24         sys-devel/flex
25         elibc_musl? ( sys-libs/fts-standalone )
26 "
27 DEPEND="pam? ( sys-libs/pam )"
28 RDEPEND="${DEPEND}"
29
30 PATCHES=(
31         "${FILESDIR}"/${P}-replace-DECLS.patch
32         "${FILESDIR}"/${P}-replace-INLCUDES.patch
33         "${FILESDIR}"/${P}-reorder-headers.patch
34         "${FILESDIR}"/${P}-remove-umask.patch
35 )
36
37 pkg_setup() {
38         local CONFIG_CHECK="~CGROUPS"
39         if use daemon; then
40                 CONFIG_CHECK="${CONFIG_CHECK} ~CONNECTOR ~PROC_EVENTS"
41         fi
42         linux-info_pkg_setup
43 }
44
45 PATCHES=(
46         "${FILESDIR}"/${P}-replace_DECLS.patch
47         "${FILESDIR}"/${P}-replace_INLCUDES.patch
48         "${FILESDIR}"/${P}-reorder-headers.patch
49         "${FILESDIR}"/${P}-remove-umask.patch
50 )
51
52 src_prepare() {
53         default
54         # Change rules file location
55         sed -e 's:/etc/cgrules.conf:/etc/cgroup/cgrules.conf:' \
56                 -i src/libcgroup-internal.h || die "sed failed"
57         sed -e 's:/etc/cgconfig.conf:/etc/cgroup/cgconfig.conf:' \
58                 -i src/libcgroup-internal.h || die "sed failed"
59         sed -e 's:\(pam_cgroup_la_LDFLAGS.*\):\1\ -avoid-version:' \
60                 -i src/pam/Makefile.am || die "sed failed"
61         sed -e 's#/var/run#/run#g' -i configure.in || die "sed failed"
62
63         # If we're not running tests, don't bother building them.
64         if ! use test; then
65                 sed -i '/^SUBDIRS/s:tests::' Makefile.am || die
66         fi
67
68         # Workaround configure.in
69         mv configure.in configure.ac || die
70
71         eautoreconf
72 }
73
74 src_configure() {
75         local my_conf
76
77         if use pam; then
78                 my_conf=" --enable-pam-module-dir=$(getpam_mod_dir) "
79         fi
80
81         use elibc_musl && append-ldflags "-lfts"
82         econf \
83                 $(use_enable static-libs static) \
84                 $(use_enable daemon) \
85                 $(use_enable pam) \
86                 $(use_enable tools) \
87                 ${my_conf}
88 }
89
90 src_install() {
91         default
92         find "${D}" -name '*.la' -delete || die
93
94         insinto /etc/cgroup
95         doins samples/*.conf
96
97         if use tools; then
98                 newconfd "${FILESDIR}"/cgconfig.confd-r1 cgconfig
99                 newinitd "${FILESDIR}"/cgconfig.initd-r1 cgconfig
100                 systemd_dounit "${FILESDIR}"/cgconfig.service
101                 systemd_dounit "${FILESDIR}"/cgrules.service
102         fi
103
104         if use daemon; then
105                 newconfd "${FILESDIR}"/cgred.confd-r2 cgred
106                 newinitd "${FILESDIR}"/cgred.initd-r1 cgred
107         fi
108 }