sys-auth/elogind: amd64 stable wrt bug #716826
[gentoo.git] / sys-auth / elogind / elogind-243.7.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 if [[ ${PV} = *9999* ]]; then
7         EGIT_BRANCH="v241-stable"
8         EGIT_REPO_URI="https://github.com/elogind/elogind.git"
9         inherit git-r3
10 else
11         SRC_URI="https://github.com/${PN}/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
12         KEYWORDS="~alpha amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86"
13 fi
14
15 inherit linux-info meson pam udev xdg-utils
16
17 DESCRIPTION="The systemd project's logind, extracted to a standalone package"
18 HOMEPAGE="https://github.com/elogind/elogind"
19
20 LICENSE="CC0-1.0 LGPL-2.1+ public-domain"
21 SLOT="0"
22 IUSE="+acl debug doc +pam +policykit selinux"
23
24 BDEPEND="
25         app-text/docbook-xml-dtd:4.2
26         app-text/docbook-xml-dtd:4.5
27         app-text/docbook-xsl-stylesheets
28         dev-util/gperf
29         dev-util/intltool
30         virtual/pkgconfig
31 "
32 DEPEND="
33         sys-apps/util-linux
34         sys-libs/libcap
35         virtual/libudev:=
36         acl? ( sys-apps/acl )
37         pam? ( sys-libs/pam )
38         selinux? ( sys-libs/libselinux )
39 "
40 RDEPEND="${DEPEND}
41         !sys-apps/systemd
42 "
43 PDEPEND="
44         sys-apps/dbus
45         policykit? ( sys-auth/polkit )
46 "
47
48 DOCS=( README.md src/libelogind/sd-bus/GVARIANT-SERIALIZATION )
49
50 PATCHES=(
51         "${FILESDIR}/${P}-nodocs.patch"
52         "${FILESDIR}/${PN}-241.4-broken-test.patch" # bug 699116
53 )
54
55 pkg_setup() {
56         local CONFIG_CHECK="~CGROUPS ~EPOLL ~INOTIFY_USER ~SIGNALFD ~TIMERFD"
57
58         use kernel_linux && linux-info_pkg_setup
59 }
60
61 src_prepare() {
62         default
63         xdg_environment_reset
64 }
65
66 src_configure() {
67         local rccgroupmode="$(grep rc_cgroup_mode ${EPREFIX}/etc/rc.conf | cut -d '"' -f 2)"
68         local cgroupmode="legacy"
69
70         if [[ "xhybrid" = "x${rccgroupmode}" ]] ; then
71                 cgroupmode="hybrid"
72         elif [[ "xunified" = "x${rccgroupmode}" ]] ; then
73                 cgroupmode="unified"
74         fi
75
76         local emesonargs=(
77                 -Ddocdir="${EPREFIX}/usr/share/doc/${PF}"
78                 -Dhtmldir="${EPREFIX}/usr/share/doc/${PF}/html"
79                 -Dpamlibdir=$(getpam_mod_dir)
80                 -Dudevrulesdir="${EPREFIX}$(get_udevdir)"/rules.d
81                 --libdir="${EPREFIX}"/usr/$(get_libdir)
82                 -Drootlibdir="${EPREFIX}"/$(get_libdir)
83                 -Drootlibexecdir="${EPREFIX}"/$(get_libdir)/elogind
84                 -Drootprefix="${EPREFIX}/"
85                 -Dbashcompletiondir="${EPREFIX}/usr/share/bash-completion/completions"
86                 -Dman=auto
87                 -Dsmack=true
88                 -Dcgroup-controller=openrc
89                 -Ddefault-hierarchy=${cgroupmode}
90                 -Ddefault-kill-user-processes=false
91                 -Dacl=$(usex acl true false)
92                 --buildtype $(usex debug debug release)
93                 -Dhtml=$(usex doc auto false)
94                 -Dpam=$(usex pam true false)
95                 -Dselinux=$(usex selinux true false)
96                 -Dutmp=$(usex elibc_musl false true)
97         )
98
99         meson_src_configure
100 }
101
102 src_install() {
103         DOCS+=( src/libelogind/sd-bus/GVARIANT-SERIALIZATION )
104
105         meson_src_install
106
107         newinitd "${FILESDIR}"/${PN}.init ${PN}
108
109         sed -e "s/@libdir@/$(get_libdir)/" "${FILESDIR}"/${PN}.conf.in > ${PN}.conf || die
110         newconfd ${PN}.conf ${PN}
111 }
112
113 pkg_postinst() {
114         if [[ "$(rc-config list boot | grep elogind)" != "" ]]; then
115                 elog "elogind is currently started from boot runlevel."
116         elif [[ "$(rc-config list default | grep elogind)" != "" ]]; then
117                 ewarn "elogind is currently started from default runlevel."
118                 ewarn "Please remove elogind from the default runlevel and"
119                 ewarn "add it to the boot runlevel by:"
120                 ewarn "# rc-update del elogind default"
121                 ewarn "# rc-update add elogind boot"
122         else
123                 elog "elogind is currently not started from any runlevel."
124                 elog "You may add it to the boot runlevel by:"
125                 elog "# rc-update add elogind boot"
126                 elog
127                 elog "Alternatively, you can leave elogind out of any"
128                 elog "runlevel. It will then be started automatically"
129                 if use pam; then
130                         elog "when the first service calls it via dbus, or"
131                         elog "the first user logs into the system."
132                 else
133                         elog "when the first service calls it via dbus."
134                 fi
135         fi
136 }