summaryrefslogtreecommitdiff
blob: fabf75d2229e062af3b64a74db47b3bdf519f068 (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=6

inherit autotools eutils linux-info pam udev

DESCRIPTION="The systemd project's logind, extracted to a standalone package"
HOMEPAGE="https://github.com/wingo/elogind"
SRC_URI="https://github.com/wingo/elogind/archive/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="CC0-1.0 LGPL-2.1+ public-domain"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-linux ~ia64-linux ~x86-linux"
IUSE="acl apparmor pam policykit selinux +seccomp"

COMMON_DEPEND="
	sys-libs/libcap
	sys-apps/util-linux
	virtual/libudev:=
	acl? ( sys-apps/acl )
	apparmor? ( sys-libs/libapparmor )
	pam? ( virtual/pam )
	seccomp? ( sys-libs/libseccomp )
	selinux? ( sys-libs/libselinux )
"
RDEPEND="${COMMON_DEPEND}
	sys-apps/dbus
	policykit? ( sys-auth/polkit )
	!sys-auth/systemd
"
DEPEND="${COMMON_DEPEND}
	dev-util/gperf
	dev-util/intltool
	sys-devel/libtool
	virtual/pkgconfig
"

PATCHES=(
	"${FILESDIR}/${PN}-docs.patch"
	"${FILESDIR}/${PN}-lrt.patch"
	"${FILESDIR}/${P}-session.patch"
	"${FILESDIR}/${PN}-add_missing_login1_permissions.patch"
)

pkg_setup() {
	if use kernel_linux; then
		linux-info_pkg_setup
		if ! linux_config_exists; then
			ewarn "Can't check the linux kernel configuration."
		else
			local missing_count=0
			if ! linux_chkconfig_present CGROUPS; then
				eerror "CGROUPS is not enabled but needed by elogind."
				eerror " (it is OK to disable all controllers)"
				missing_count=$((missing_count+1))
			fi
			if ! linux_chkconfig_present INOTIFY_USER; then
				eerror "INOTIFY_USER is not enabled but needed by elogind."
				missing_count=$((missing_count+1))
			fi
			if ! linux_chkconfig_present SIGNALFD; then
				eerror "SIGNALFD is not enabled but needed by elogind."
				missing_count=$((missing_count+1))
			fi
			if ! linux_chkconfig_present TIMERFD; then
				eerror "TIMERFD is not enabled but needed by elogind."
				missing_count=$((missing_count+1))
			fi
			if ! linux_chkconfig_present EPOLL; then
				eerror "EPOLL is not enabled but needed by elogind."
				missing_count=$((missing_count+1))
			fi
			if ! linux_chkconfig_present SECCOMP; then
				einfo "SECCOMP is not enabled but useful to elogind."
			fi
			[ 0 -lt $missing_count ] && die "$missing_count required kernel features are missing."
		fi
	fi
}

src_prepare() {
	default

	# Makefile.am is patched by
	# - "${FILESDIR}/${PN}-docs.patch"
	# - "${FILESDIR}/${PN}-lrt.patch"
	eautoreconf
}

src_configure() {
	local use_smack="--disable-smack"
	if linux_config_exists && linux_chkconfig_present SECURITY_SMACK; then
		use_smack="--enable-smack"
	fi

	econf \
		--with-pamlibdir=$(getpam_mod_dir) \
		--with-udevrulesdir="$(get_udevdir)"/rules.d \
		--libdir=/$(get_libdir) \
		$(use_enable acl) \
		$(use_enable apparmor) \
		$(use_enable pam) \
		$(use_enable seccomp) \
		$(use_enable selinux) \
		$use_smack
}

src_install() {
	default

	# Installation would fail with
	# "static archives (*.a) and libtool library files
	#  (*.la) belong in /usr/lib*, not /lib*"
	# if we didn't prune them.
	prune_libtool_files --modules

	# Unfortunately the build system puts the pkgconfig file(s)
	# into $(libdir)/pkgconfig - Move it to /usr/$(libdir)/pkgconfig
	mkdir -p "${ED}"usr/$(get_libdir) || die
	mv "${ED}"$(get_libdir)/pkgconfig "${ED}"usr/$(get_libdir)/ || die

	newinitd "${FILESDIR}"/${PN}.init ${PN}
	newconfd "${FILESDIR}"/${PN}.conf ${PN}
}

pkg_postinst() {
	if [ "$(rc-config list default | grep elogind)" = "" ]; then
		ewarn "To enable the elogind daemon, elogind must be"
		ewarn "added to the default runlevel:"
		ewarn "# rc-update add elogind default"
	fi
}