summaryrefslogtreecommitdiff
blob: 2f7c974ef24d47052ac412fd096bb542227d8777 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="2"

inherit autotools linux-info pam

DESCRIPTION="Tools and libraries to control and monitor control groups"
HOMEPAGE="http://libcg.sourceforge.net/"
SRC_URI="mirror://sourceforge/libcg/${P}.tar.gz"

LICENSE="LGPL-2.1"
SLOT="0"
KEYWORDS="~x86"
IUSE="+daemon debug pam static-libs +tools"

RDEPEND="pam? ( virtual/pam )"
DEPEND="${RDEPEND}
	sys-devel/bison
	sys-devel/flex"

pkg_setup() {
	if use daemon && ! use tools; then
		eerror "The daemon USE flag requires tools USE flag."
		die "Please enable tools or disable daemon."
	fi

	local CONFIG_CHECK="~CGROUPS"
	if use daemon; then
		CONFIG_CHECK="${CONFIG_CHECK} ~CONNECTOR ~PROC_EVENTS"
	fi
	linux-info_pkg_setup
}

src_prepare() {
	# Change rules file location
	sed -e 's:/etc/cgrules.conf:/etc/cgroup/cgrules.conf:' \
		-i src/libcgroup-internal.h || die "sed failed"

	# Install PAM module into correct location
	sed \
		-e "/lib_LTLIBRARIES/ i pamlibdir=$(getpam_mod_dir)" \
		-e 's/lib_LTLIBRARIES/pamlib_LTLIBRARIES/' \
		-e '/pam_cgroup_la_LDFLAGS/ s/$/ -avoid-version -shared/' \
		-i src/pam/Makefile.am || die "sed failed"

	eautoreconf
}

src_configure() {
	econf \
		--enable-shared \
		$(use_enable daemon) \
		$(use_enable debug) \
		$(use_enable pam) \
		$(use_enable static-libs static) \
		$(use_enable tools)
}

src_install() {
	emake DESTDIR="${D}" install || die "Install failed"
	find "${D}" -name "*.la" -delete || die "la removal failed"

	insinto /etc/cgroup
	doins samples/cgrules.conf || die

	if use tools; then
		doins samples/cgconfig.conf || die

		newconfd "${FILESDIR}"/cgconfig.confd cgconfig || die
		newinitd "${FILESDIR}"/cgconfig.initd cgconfig || die
	fi

	if use daemon; then
		newconfd "${FILESDIR}"/cgred.confd cgred || die
		newinitd "${FILESDIR}"/cgred.initd cgred || die
	fi
}