1 # Copyright 2011-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 if [[ ${PV} == 9999 ]]; then
7 EGIT_REPO_URI="https://github.com/systemd/systemd.git"
10 SRC_URI="https://github.com/systemd/systemd/archive/v${PV}/${P}.tar.gz
11 https://dev.gentoo.org/~floppym/dist/${P}-patches-2.tar.gz"
12 KEYWORDS="alpha amd64 arm arm64 ~hppa ia64 ~mips ppc ppc64 sparc x86"
15 PYTHON_COMPAT=( python{3_5,3_6,3_7} )
17 inherit bash-completion-r1 linux-info meson multilib-minimal ninja-utils pam python-any-r1 systemd toolchain-funcs udev user
19 DESCRIPTION="System and service manager for Linux"
20 HOMEPAGE="https://www.freedesktop.org/wiki/Software/systemd"
22 LICENSE="GPL-2 LGPL-2.1 MIT public-domain"
24 IUSE="acl apparmor audit build cryptsetup curl elfutils +gcrypt gnuefi http idn importd +kmod libidn2 +lz4 lzma nat pam pcre policykit qrcode +resolvconf +seccomp selinux +split-usr ssl +sysv-utils test vanilla xkb"
26 REQUIRED_USE="importd? ( curl gcrypt lzma )"
27 RESTRICT="!test? ( test )"
31 COMMON_DEPEND=">=sys-apps/util-linux-2.30:0=[${MULTILIB_USEDEP}]
32 sys-libs/libcap:0=[${MULTILIB_USEDEP}]
34 acl? ( sys-apps/acl:0= )
35 apparmor? ( sys-libs/libapparmor:0= )
36 audit? ( >=sys-process/audit-2:0= )
37 cryptsetup? ( >=sys-fs/cryptsetup-1.6:0= )
38 curl? ( net-misc/curl:0= )
39 elfutils? ( >=dev-libs/elfutils-0.158:0= )
40 gcrypt? ( >=dev-libs/libgcrypt-1.4.5:0=[${MULTILIB_USEDEP}] )
42 >=net-libs/libmicrohttpd-0.9.33:0=
43 ssl? ( >=net-libs/gnutls-3.1.4:0= )
46 libidn2? ( net-dns/libidn2:= )
47 !libidn2? ( net-dns/libidn:= )
53 kmod? ( >=sys-apps/kmod-15:0= )
54 lz4? ( >=app-arch/lz4-0_p131:0=[${MULTILIB_USEDEP}] )
55 lzma? ( >=app-arch/xz-utils-5.0.5-r1:0=[${MULTILIB_USEDEP}] )
56 nat? ( net-firewall/iptables:0= )
57 pam? ( virtual/pam:=[${MULTILIB_USEDEP}] )
58 pcre? ( dev-libs/libpcre2 )
59 qrcode? ( media-gfx/qrencode:0= )
60 seccomp? ( >=sys-libs/libseccomp-2.3.3:0= )
61 selinux? ( sys-libs/libselinux:0= )
62 xkb? ( >=x11-libs/libxkbcommon-0.4.1:0= )"
64 # baselayout-2.2 has /run
65 RDEPEND="${COMMON_DEPEND}
66 >=sys-apps/baselayout-2.2
67 selinux? ( sec-policy/selinux-base-policy[systemd] )
68 sysv-utils? ( !sys-apps/sysvinit )
69 !sysv-utils? ( sys-apps/sysvinit )
70 resolvconf? ( !net-dns/openresolv )
72 sys-apps/util-linux[kill(-)]
73 sys-process/procps[kill(+)]
74 sys-apps/coreutils[kill(-)]
76 !sys-auth/nss-myhostname
77 !<sys-kernel/dracut-044
81 # sys-apps/dbus: the daemon only (+ build-time lib dep for tests)
82 PDEPEND=">=sys-apps/dbus-1.9.8[systemd]
83 >=sys-apps/hwids-20150417[udev]
84 >=sys-fs/udev-init-scripts-25
85 policykit? ( sys-auth/polkit )
86 !vanilla? ( sys-apps/gentoo-systemd-integration )"
88 # Newer linux-headers needed by ia64, bug #480218
89 DEPEND="${COMMON_DEPEND}
92 >=dev-util/intltool-0.50
93 >=sys-apps/coreutils-8.16
94 >=sys-kernel/linux-headers-${MINKV}
95 virtual/pkgconfig[${MULTILIB_USEDEP}]
96 gnuefi? ( >=sys-boot/gnu-efi-3.0.2 )
97 test? ( sys-apps/dbus )
98 app-text/docbook-xml-dtd:4.2
99 app-text/docbook-xml-dtd:4.5
100 app-text/docbook-xsl-stylesheets
102 $(python_gen_any_dep 'dev-python/lxml[${PYTHON_USEDEP}]')
106 if [[ ${MERGE_TYPE} != buildonly ]]; then
107 local CONFIG_CHECK="~AUTOFS4_FS ~BLK_DEV_BSG ~CGROUPS
108 ~CHECKPOINT_RESTORE ~DEVTMPFS ~EPOLL ~FANOTIFY ~FHANDLE
109 ~INOTIFY_USER ~IPV6 ~NET ~NET_NS ~PROC_FS ~SIGNALFD ~SYSFS
110 ~TIMERFD ~TMPFS_XATTR ~UNIX
111 ~CRYPTO_HMAC ~CRYPTO_SHA256 ~CRYPTO_USER_API_HASH
112 ~!FW_LOADER_USER_HELPER_FALLBACK ~!GRKERNSEC_PROC ~!IDE ~!SYSFS_DEPRECATED
113 ~!SYSFS_DEPRECATED_V2"
115 use acl && CONFIG_CHECK+=" ~TMPFS_POSIX_ACL"
116 use seccomp && CONFIG_CHECK+=" ~SECCOMP ~SECCOMP_FILTER"
117 kernel_is -lt 3 7 && CONFIG_CHECK+=" ~HOTPLUG"
118 kernel_is -lt 4 7 && CONFIG_CHECK+=" ~DEVPTS_MULTIPLE_INSTANCES"
119 kernel_is -ge 4 10 && CONFIG_CHECK+=" ~CGROUP_BPF"
121 if linux_config_exists; then
122 local uevent_helper_path=$(linux_chkconfig_string UEVENT_HELPER_PATH)
123 if [[ -n ${uevent_helper_path} ]] && [[ ${uevent_helper_path} != '""' ]]; then
124 ewarn "It's recommended to set an empty value to the following kernel config option:"
125 ewarn "CONFIG_UEVENT_HELPER_PATH=${uevent_helper_path}"
127 if linux_chkconfig_present X86; then
128 CONFIG_CHECK+=" ~DMIID"
132 if kernel_is -lt ${MINKV//./ }; then
133 ewarn "Kernel version at least ${MINKV} required"
146 [[ ${PV} != 9999 ]] || git-r3_src_unpack
150 # Do NOT add patches here
153 [[ -d "${WORKDIR}"/patches ]] && PATCHES+=( "${WORKDIR}"/patches )
155 # Add local patches here
157 "${FILESDIR}"/239-debug-extra.patch
158 "${FILESDIR}"/CVE-2019-6454.patch
161 if ! use vanilla; then
163 "${FILESDIR}/gentoo-Dont-enable-audit-by-default.patch"
164 "${FILESDIR}/gentoo-systemd-user-pam.patch"
165 "${FILESDIR}/gentoo-uucp-group-r1.patch"
166 "${FILESDIR}/gentoo-generator-path.patch"
174 # Prevent conflicts with i686 cross toolchain, bug 559726
175 tc-export AR CC NM OBJCOPY RANLIB
179 multilib-minimal_src_configure
187 if multilib_is_native_abi; then
194 meson_multilib_native_use() {
195 if multilib_is_native_abi && use "$1"; then
202 multilib_src_configure() {
204 --localstatedir="${EPREFIX}/var"
205 -Dpamlibdir="$(getpam_mod_dir)"
206 # avoid bash-completion dep
207 -Dbashcompletiondir="$(get_bashcompdir)"
208 # make sure we get /bin:/sbin in PATH
209 -Dsplit-usr=$(usex split-usr true false)
210 -Drootprefix="$(usex split-usr "${EPREFIX:-/}" "${EPREFIX}/usr")"
213 # Avoid infinite exec recursion, bug 642724
214 -Dtelinit-path="${EPREFIX}/lib/sysvinit/telinit"
216 -Defi=$(meson_multilib)
218 # Optional components/dependencies
219 -Dacl=$(meson_multilib_native_use acl)
220 -Dapparmor=$(meson_multilib_native_use apparmor)
221 -Daudit=$(meson_multilib_native_use audit)
222 -Dlibcryptsetup=$(meson_multilib_native_use cryptsetup)
223 -Dlibcurl=$(meson_multilib_native_use curl)
224 -Delfutils=$(meson_multilib_native_use elfutils)
225 -Dgcrypt=$(meson_use gcrypt)
226 -Dgnu-efi=$(meson_multilib_native_use gnuefi)
227 -Defi-libdir="${EPREFIX}/usr/$(get_libdir)"
228 -Dmicrohttpd=$(meson_multilib_native_use http)
229 $(usex http -Dgnutls=$(meson_multilib_native_use ssl) -Dgnutls=false)
230 -Dimportd=$(meson_multilib_native_use importd)
231 -Dbzip2=$(meson_multilib_native_use importd)
232 -Dzlib=$(meson_multilib_native_use importd)
233 -Dkmod=$(meson_multilib_native_use kmod)
234 -Dlz4=$(meson_use lz4)
235 -Dxz=$(meson_use lzma)
236 -Dlibiptc=$(meson_multilib_native_use nat)
237 -Dpam=$(meson_use pam)
238 -Dpcre2=$(meson_multilib_native_use pcre)
239 -Dpolkit=$(meson_multilib_native_use policykit)
240 -Dqrencode=$(meson_multilib_native_use qrcode)
241 -Dseccomp=$(meson_multilib_native_use seccomp)
242 -Dselinux=$(meson_multilib_native_use selinux)
243 #-Dtests=$(meson_multilib_native_use test)
244 -Ddbus=$(meson_multilib_native_use test)
245 -Dxkbcommon=$(meson_multilib_native_use xkb)
246 # hardcode a few paths to spare some deps
247 -Dkill-path=/bin/kill
248 -Dntp-servers="0.gentoo.pool.ntp.org 1.gentoo.pool.ntp.org 2.gentoo.pool.ntp.org 3.gentoo.pool.ntp.org"
249 # Breaks screen, tmux, etc.
250 -Ddefault-kill-user-processes=false
253 -Dbacklight=$(meson_multilib)
254 -Dbinfmt=$(meson_multilib)
255 -Dcoredump=$(meson_multilib)
256 -Denvironment-d=$(meson_multilib)
257 -Dfirstboot=$(meson_multilib)
258 -Dhibernate=$(meson_multilib)
259 -Dhostnamed=$(meson_multilib)
260 -Dhwdb=$(meson_multilib)
261 -Dldconfig=$(meson_multilib)
262 -Dlocaled=$(meson_multilib)
263 -Dman=$(meson_multilib)
264 -Dnetworkd=$(meson_multilib)
265 -Dquotacheck=$(meson_multilib)
266 -Drandomseed=$(meson_multilib)
267 -Drfkill=$(meson_multilib)
268 -Dsysusers=$(meson_multilib)
269 -Dtimedated=$(meson_multilib)
270 -Dtimesyncd=$(meson_multilib)
271 -Dtmpfiles=$(meson_multilib)
272 -Dvconsole=$(meson_multilib)
275 if multilib_is_native_abi && use idn; then
277 -Dlibidn2=$(usex libidn2 true false)
278 -Dlibidn=$(usex libidn2 false true)
287 meson_src_configure "${myconf[@]}"
290 multilib_src_compile() {
294 multilib_src_test() {
295 unset DBUS_SESSION_BUS_ADDRESS XDG_RUNTIME_DIR
299 multilib_src_install() {
300 DESTDIR="${D}" eninja install
303 multilib_src_install_all() {
304 local rootprefix=$(usex split-usr '' /usr)
306 # meson doesn't know about docdir
307 mv "${ED%/}"/usr/share/doc/{systemd,${PF}} || die
310 dodoc "${FILESDIR}"/nsswitch.conf
312 if ! use resolvconf; then
313 rm -f "${ED%/}${rootprefix}"/sbin/resolvconf || die
316 if ! use sysv-utils; then
317 rm "${ED%/}${rootprefix}"/sbin/{halt,init,poweroff,reboot,runlevel,shutdown,telinit} || die
318 rm "${ED%/}"/usr/share/man/man1/init.1 || die
319 rm "${ED%/}"/usr/share/man/man8/{halt,poweroff,reboot,runlevel,shutdown,telinit}.8 || die
322 if ! use resolvconf && ! use sysv-utils; then
323 rmdir "${ED%/}${rootprefix}"/sbin || die
326 # Preserve empty dirs in /etc & /var, bug #437008
327 keepdir /etc/{binfmt.d,modules-load.d,tmpfiles.d}
328 keepdir /etc/systemd/{ntp-units.d,user} /var/lib/systemd
329 keepdir /etc/udev/{hwdb.d,rules.d}
330 keepdir /var/log/journal/remote
332 # Symlink /etc/sysctl.conf for easy migration.
333 dosym ../sysctl.conf /etc/sysctl.d/99-sysctl.conf
335 # If we install these symlinks, there is no way for the sysadmin to remove them
337 rm -f "${ED%/}"/etc/systemd/system/multi-user.target.wants/systemd-networkd.service || die
338 rm -f "${ED%/}"/etc/systemd/system/dbus-org.freedesktop.network1.service || die
339 rm -f "${ED%/}"/etc/systemd/system/multi-user.target.wants/systemd-resolved.service || die
340 rm -f "${ED%/}"/etc/systemd/system/dbus-org.freedesktop.resolve1.service || die
341 rm -fr "${ED%/}"/etc/systemd/system/network-online.target.wants || die
342 rm -fr "${ED%/}"/etc/systemd/system/sockets.target.wants || die
343 rm -fr "${ED%/}"/etc/systemd/system/sysinit.target.wants || die
345 local udevdir=/lib/udev
346 use split-usr || udevdir=/usr/lib/udev
348 rm -r "${ED%/}${udevdir}/hwdb.d" || die
350 if use split-usr; then
351 # Avoid breaking boot/reboot
352 dosym ../../../lib/systemd/systemd /usr/lib/systemd/systemd
353 dosym ../../../lib/systemd/systemd-shutdown /usr/lib/systemd/systemd-shutdown
358 local envd_locale_def="${EROOT%/}/etc/env.d/02locale"
359 local envd_locale=( "${EROOT%/}"/etc/env.d/??locale )
360 local locale_conf="${EROOT%/}/etc/locale.conf"
362 if [[ ! -L ${locale_conf} && ! -e ${locale_conf} ]]; then
363 # If locale.conf does not exist...
364 if [[ -e ${envd_locale} ]]; then
365 # ...either copy env.d/??locale if there's one
366 ebegin "Moving ${envd_locale} to ${locale_conf}"
367 mv "${envd_locale}" "${locale_conf}"
370 # ...or create a dummy default
371 ebegin "Creating ${locale_conf}"
372 cat > "${locale_conf}" <<-EOF
373 # This file has been created by the sys-apps/systemd ebuild.
374 # See locale.conf(5) and localectl(1).
382 if [[ ! -L ${envd_locale} ]]; then
383 # now, if env.d/??locale is not a symlink (to locale.conf)...
384 if [[ -e ${envd_locale} ]]; then
385 # ...warn the user that he has duplicate locale settings
387 ewarn "To ensure consistent behavior, you should replace ${envd_locale}"
388 ewarn "with a symlink to ${locale_conf}. Please migrate your settings"
389 ewarn "and create the symlink with the following command:"
390 ewarn "ln -s -n -f ../locale.conf ${envd_locale}"
393 # ...or just create the symlink if there's nothing here
394 ebegin "Creating ${envd_locale_def} -> ../locale.conf symlink"
395 ln -n -s ../locale.conf "${envd_locale_def}"
404 enewuser "$1" -1 -1 -1 "$1"
410 enewgroup systemd-journal
411 newusergroup systemd-bus-proxy
412 newusergroup systemd-coredump
413 newusergroup systemd-journal-gateway
414 newusergroup systemd-journal-remote
415 newusergroup systemd-journal-upload
416 newusergroup systemd-network
417 newusergroup systemd-resolve
418 newusergroup systemd-timesync
420 systemd_update_catalog
422 # Keep this here in case the database format changes so it gets updated
423 # when required. Despite that this file is owned by sys-apps/hwids.
424 if has_version "sys-apps/hwids[udev]"; then
425 udevadm hwdb --update --root="${EROOT%/}"
428 udev_reload || FAIL=1
430 # Bug 465468, make sure locales are respect, and ensure consistency
431 # between OpenRC & systemd
434 systemd_reenable systemd-networkd.service systemd-resolved.service
436 if [[ ${FAIL} ]]; then
437 eerror "One of the postinst commands failed. Please check the postinst output"
438 eerror "for errors. You may need to clean up your system and/or try installing"
439 eerror "systemd again."
445 # If removing systemd completely, remove the catalog database.
446 if [[ ! ${REPLACED_BY_VERSION} ]]; then
447 rm -f -v "${EROOT}"/var/lib/systemd/catalog/database