1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 AUTOTOOLS_PRUNE_LIBTOOL_FILES=all
8 PYTHON_COMPAT=( python{2_7,3_3,3_4} )
9 inherit autotools-utils bash-completion-r1 linux-info multilib \
10 multilib-minimal pam python-single-r1 systemd toolchain-funcs udev \
13 DESCRIPTION="System and service manager for Linux"
14 HOMEPAGE="http://www.freedesktop.org/wiki/Software/systemd"
15 SRC_URI="https://dev.gentoo.org/~floppym/dist/${P}.tar.xz
16 http://cgit.freedesktop.org/systemd/systemd/plain/tmpfiles.d/systemd.conf.m4?id=v219 -> systemd.conf.m4-v219"
18 LICENSE="GPL-2 LGPL-2.1 MIT public-domain"
20 KEYWORDS="~alpha ~amd64 ~arm ~ia64 ~ppc ~ppc64 ~sparc ~x86"
21 IUSE="acl apparmor audit cryptsetup curl doc elfutils gcrypt gudev http
22 idn importd introspection kdbus +kmod +lz4 lzma nat pam policykit python
23 qrcode +seccomp selinux ssl sysv-utils terminal test vanilla xkb"
24 REQUIRED_USE="importd? ( curl gcrypt lzma )"
28 COMMON_DEPEND=">=sys-apps/util-linux-2.25:0=
31 acl? ( sys-apps/acl:0= )
32 apparmor? ( sys-libs/libapparmor:0= )
33 audit? ( >=sys-process/audit-2:0= )
34 cryptsetup? ( >=sys-fs/cryptsetup-1.6:0= )
35 curl? ( net-misc/curl:0= )
36 elfutils? ( >=dev-libs/elfutils-0.158:0= )
37 gcrypt? ( >=dev-libs/libgcrypt-1.4.5:0=[${MULTILIB_USEDEP}] )
38 gudev? ( >=dev-libs/glib-2.34.3:2=[${MULTILIB_USEDEP}] )
40 >=net-libs/libmicrohttpd-0.9.33:0=
41 ssl? ( >=net-libs/gnutls-3.1.4:0= )
43 idn? ( net-dns/libidn:0= )
48 introspection? ( >=dev-libs/gobject-introspection-1.31.1:0= )
49 kmod? ( >=sys-apps/kmod-15:0= )
50 lz4? ( >=app-arch/lz4-0_p119:0=[${MULTILIB_USEDEP}] )
51 lzma? ( >=app-arch/xz-utils-5.0.5-r1:0=[${MULTILIB_USEDEP}] )
52 nat? ( net-firewall/iptables:0= )
53 pam? ( virtual/pam:= )
54 python? ( ${PYTHON_DEPS} )
55 qrcode? ( media-gfx/qrencode:0= )
56 seccomp? ( sys-libs/libseccomp:0= )
57 selinux? ( sys-libs/libselinux:0= )
59 !sys-apps/systemd-sysv-utils
61 terminal? ( >=dev-libs/libevdev-1.2:0=
62 >=x11-libs/libxkbcommon-0.5:0=
63 >=x11-libs/libdrm-2.4:0= )
64 xkb? ( >=x11-libs/libxkbcommon-0.4.1:0= )
65 abi_x86_32? ( !<=app-emulation/emul-linux-x86-baselibs-20130224-r9
66 !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)] )"
68 # baselayout-2.2 has /run
69 RDEPEND="${COMMON_DEPEND}
70 >=sys-apps/baselayout-2.2
71 !sys-auth/nss-myhostname
74 gudev? ( !dev-libs/libgudev )"
76 # sys-apps/dbus: the daemon only (+ build-time lib dep for tests)
77 PDEPEND=">=sys-apps/dbus-1.6.8-r1:0[systemd]
78 >=sys-apps/hwids-20130717-r1[udev]
79 >=sys-fs/udev-init-scripts-25
80 policykit? ( sys-auth/polkit )
81 !vanilla? ( sys-apps/gentoo-systemd-integration )"
83 # Newer linux-headers needed by ia64, bug #480218
84 DEPEND="${COMMON_DEPEND}
87 >=dev-util/intltool-0.50
88 >=sys-apps/coreutils-8.16
89 >=sys-devel/binutils-2.23.1
91 >=sys-kernel/linux-headers-${MINKV}
92 ia64? ( >=sys-kernel/linux-headers-3.9 )
94 doc? ( >=dev-util/gtk-doc-1.18 )
95 python? ( dev-python/lxml[${PYTHON_USEDEP}] )
96 terminal? ( media-fonts/unifont[utils(+)] )
97 test? ( >=sys-apps/dbus-1.6.8-r1:0 )"
99 PATCHES=( "${FILESDIR}/218-Dont-enable-audit-by-default.patch" )
100 S=${WORKDIR}/systemd-219
103 local CONFIG_CHECK="~AUTOFS4_FS ~BLK_DEV_BSG ~CGROUPS
104 ~DEVPTS_MULTIPLE_INSTANCES ~DEVTMPFS ~DMIID ~EPOLL ~FANOTIFY ~FHANDLE
105 ~INOTIFY_USER ~IPV6 ~NET ~NET_NS ~PROC_FS ~SECCOMP ~SIGNALFD ~SYSFS
106 ~TIMERFD ~TMPFS_XATTR
107 ~!FW_LOADER_USER_HELPER ~!GRKERNSEC_PROC ~!IDE ~!SYSFS_DEPRECATED
108 ~!SYSFS_DEPRECATED_V2"
110 use acl && CONFIG_CHECK+=" ~TMPFS_POSIX_ACL"
111 kernel_is -lt 3 7 && CONFIG_CHECK+=" ~HOTPLUG"
113 if linux_config_exists; then
114 local uevent_helper_path=$(linux_chkconfig_string UEVENT_HELPER_PATH)
115 if [ -n "${uevent_helper_path}" ] && [ "${uevent_helper_path}" != '""' ]; then
116 ewarn "It's recommended to set an empty value to the following kernel config option:"
117 ewarn "CONFIG_UEVENT_HELPER_PATH=${uevent_helper_path}"
121 if [[ ${MERGE_TYPE} != binary ]]; then
122 if [[ $(gcc-major-version) -lt 4
123 || ( $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt 6 ) ]]
125 eerror "systemd requires at least gcc 4.6 to build. Please switch the active"
126 eerror "gcc version using gcc-config."
127 die "systemd requires at least gcc 4.6"
131 if [[ ${MERGE_TYPE} != buildonly ]]; then
132 if kernel_is -lt ${MINKV//./ }; then
133 ewarn "Kernel version at least ${MINKV} required"
141 use python && python-single-r1_pkg_setup
146 cp "${DISTDIR}/systemd.conf.m4-v219" "${S}/tmpfiles.d/systemd.conf.m4" || die
151 sed -i -e 's/GROUP="dialout"/GROUP="uucp"/' rules/*.rules || die
153 autotools-utils_src_prepare
157 # Keep using the one where the rules were installed.
158 MY_UDEVDIR=$(get_udevdir)
159 # Fix systems broken by bug #509454.
160 [[ ${MY_UDEVDIR} ]] || MY_UDEVDIR=/lib/udev
162 multilib-minimal_src_configure
165 multilib_src_configure() {
167 # disable -flto since it is an optimization flag
168 # and makes distcc less effective
169 cc_cv_CFLAGS__flto=no
171 # Workaround for bug 516346
172 --enable-dependency-tracking
174 --disable-maintainer-mode
176 --with-pamlibdir=$(getpam_mod_dir)
177 # avoid bash-completion dep
178 --with-bashcompletiondir="$(get_bashcompdir)"
179 # make sure we get /bin:/sbin in $PATH
182 --with-rootprefix="${ROOTPREFIX-/usr}"
183 --with-rootlibdir="${ROOTPREFIX-/usr}/$(get_libdir)"
184 # disable sysv compatibility
185 --with-sysvinit-path=
186 --with-sysvrcnd-path=
191 # Optional components/dependencies
192 $(multilib_native_use_enable acl)
193 $(multilib_native_use_enable apparmor)
194 $(multilib_native_use_enable audit)
195 $(multilib_native_use_enable cryptsetup libcryptsetup)
196 $(multilib_native_use_enable curl libcurl)
197 $(multilib_native_use_enable doc gtk-doc)
198 $(multilib_native_use_enable elfutils)
201 $(multilib_native_use_enable http microhttpd)
202 $(usex http $(multilib_native_use_enable ssl gnutls) --disable-gnutls)
203 $(multilib_native_use_enable idn libidn)
204 $(multilib_native_use_enable importd)
205 $(multilib_native_use_enable importd bzip2)
206 $(multilib_native_use_enable importd zlib)
207 $(multilib_native_use_enable introspection)
209 $(multilib_native_use_enable kmod)
211 $(use_enable lzma xz)
212 $(multilib_native_use_enable nat libiptc)
213 $(multilib_native_use_enable pam)
214 $(multilib_native_use_enable policykit polkit)
215 $(multilib_native_use_with python)
216 $(multilib_native_use_enable python python-devel)
217 $(multilib_native_use_enable qrcode qrencode)
218 $(multilib_native_use_enable seccomp)
219 $(multilib_native_use_enable selinux)
220 $(multilib_native_use_enable terminal)
221 $(multilib_native_use_enable test tests)
222 $(multilib_native_use_enable test dbus)
223 $(multilib_native_use_enable xkb xkbcommon)
225 # not supported (avoid automagic deps in the future)
228 # hardcode a few paths to spare some deps
229 QUOTAON=/usr/sbin/quotaon
230 QUOTACHECK=/usr/sbin/quotacheck
233 --with-dbuspolicydir="${EPREFIX}/etc/dbus-1/system.d"
234 --with-dbussessionservicedir="${EPREFIX}/usr/share/dbus-1/services"
235 --with-dbussystemservicedir="${EPREFIX}/usr/share/dbus-1/system-services"
237 --with-ntp-servers="0.gentoo.pool.ntp.org 1.gentoo.pool.ntp.org 2.gentoo.pool.ntp.org 3.gentoo.pool.ntp.org"
240 if ! multilib_is_native_abi; then
242 MOUNT_{CFLAGS,LIBS}=' '
244 ac_cv_search_cap_init=
245 ac_cv_header_sys_capability_h=yes
249 # Work around bug 463846.
252 autotools-utils_src_configure
255 multilib_src_compile() {
257 udevlibexecdir="${MY_UDEVDIR}"
260 if multilib_is_native_abi; then
261 emake "${mymakeopts[@]}"
263 # prerequisites for gudev
264 use gudev && emake src/gudev/gudev{enumtypes,marshal}.{c,h}
266 echo 'gentoo: $(BUILT_SOURCES)' | \
267 emake "${mymakeopts[@]}" -f Makefile -f - gentoo
268 echo 'gentoo: $(lib_LTLIBRARIES) $(pkgconfiglib_DATA)' | \
269 emake "${mymakeopts[@]}" -f Makefile -f - gentoo
273 multilib_src_test() {
274 multilib_is_native_abi || continue
279 multilib_src_install() {
281 # automake fails with parallel libtool relinking
282 # https://bugs.gentoo.org/show_bug.cgi?id=491398
285 udevlibexecdir="${MY_UDEVDIR}"
290 if multilib_is_native_abi; then
291 emake "${mymakeopts[@]}" install
294 install-libLTLIBRARIES
295 install-pkgconfiglibDATA
296 install-includeHEADERS
297 # safe to call unconditionally, 'installs' empty list
298 install-libgudev_includeHEADERS
299 install-pkgincludeHEADERS
302 emake "${mymakeopts[@]}"
305 # install compat pkg-config files
306 # Change dbus to >=sys-apps/dbus-1.8.8 if/when this is dropped.
307 local pcfiles=( src/compat-libs/libsystemd-{daemon,id128,journal,login}.pc )
308 emake "${mymakeopts[@]}" install-pkgconfiglibDATA \
309 pkgconfiglib_DATA="${pcfiles[*]}"
312 multilib_src_install_all() {
313 prune_libtool_files --modules
316 if use sysv-utils; then
317 for app in halt poweroff reboot runlevel shutdown telinit; do
318 dosym "..${ROOTPREFIX-/usr}/bin/systemctl" /sbin/${app}
320 dosym "..${ROOTPREFIX-/usr}/lib/systemd/systemd" /sbin/init
322 # we just keep sysvinit tools, so no need for the mans
323 rm "${D}"/usr/share/man/man8/{halt,poweroff,reboot,runlevel,shutdown,telinit}.8 \
325 rm "${D}"/usr/share/man/man1/init.1 || die
328 # Disable storing coredumps in journald, bug #433457
329 mv "${D}"/usr/lib/sysctl.d/50-coredump.conf{,.disabled} || die
331 # Preserve empty dirs in /etc & /var, bug #437008
332 keepdir /etc/binfmt.d /etc/modules-load.d /etc/tmpfiles.d \
333 /etc/systemd/ntp-units.d /etc/systemd/user /var/lib/systemd \
334 /var/log/journal/remote
336 # Symlink /etc/sysctl.conf for easy migration.
337 dosym ../sysctl.conf /etc/sysctl.d/99-sysctl.conf
339 # If we install these symlinks, there is no way for the sysadmin to remove them
341 rm "${D}"/etc/systemd/system/multi-user.target.wants/systemd-networkd.service || die
342 rm "${D}"/etc/systemd/system/multi-user.target.wants/systemd-resolved.service || die
343 rm -r "${D}"/etc/systemd/system/network-online.target.wants || die
344 rm -r "${D}"/etc/systemd/system/sysinit.target.wants || die
348 local envd_locale_def="${EROOT%/}/etc/env.d/02locale"
349 local envd_locale=( "${EROOT%/}"/etc/env.d/??locale )
350 local locale_conf="${EROOT%/}/etc/locale.conf"
352 if [[ ! -L ${locale_conf} && ! -e ${locale_conf} ]]; then
353 # If locale.conf does not exist...
354 if [[ -e ${envd_locale} ]]; then
355 # ...either copy env.d/??locale if there's one
356 ebegin "Moving ${envd_locale} to ${locale_conf}"
357 mv "${envd_locale}" "${locale_conf}"
360 # ...or create a dummy default
361 ebegin "Creating ${locale_conf}"
362 cat > "${locale_conf}" <<-EOF
363 # This file has been created by the sys-apps/systemd ebuild.
364 # See locale.conf(5) and localectl(1).
372 if [[ ! -L ${envd_locale} ]]; then
373 # now, if env.d/??locale is not a symlink (to locale.conf)...
374 if [[ -e ${envd_locale} ]]; then
375 # ...warn the user that he has duplicate locale settings
377 ewarn "To ensure consistent behavior, you should replace ${envd_locale}"
378 ewarn "with a symlink to ${locale_conf}. Please migrate your settings"
379 ewarn "and create the symlink with the following command:"
380 ewarn "ln -s -n -f ../locale.conf ${envd_locale}"
383 # ...or just create the symlink if there's nothing here
384 ebegin "Creating ${envd_locale_def} -> ../locale.conf symlink"
385 ln -n -s ../locale.conf "${envd_locale_def}"
391 migrate_net_name_slot() {
392 # If user has disabled 80-net-name-slot.rules using a empty file or a symlink to /dev/null,
393 # do the same for 80-net-setup-link.rules to keep the old behavior
395 local net_name_slot_sym=no
396 local net_rules_path="${EROOT%/}"/etc/udev/rules.d
397 local net_name_slot="${net_rules_path}"/80-net-name-slot.rules
398 local net_setup_link="${net_rules_path}"/80-net-setup-link.rules
399 if [[ -e ${net_setup_link} ]]; then
401 elif [[ -f ${net_name_slot} && $(sed -e "/^#/d" -e "/^\W*$/d" ${net_name_slot} | wc -l) == 0 ]]; then
403 elif [[ -L ${net_name_slot} && $(readlink ${net_name_slot}) == /dev/null ]]; then
405 net_name_slot_sym=yes
407 if [[ ${net_move} == yes ]]; then
408 ebegin "Copying ${net_name_slot} to ${net_setup_link}"
410 if [[ ${net_name_slot_sym} == yes ]]; then
411 ln -nfs /dev/null "${net_setup_link}"
413 cp "${net_name_slot}" "${net_setup_link}"
422 enewuser "$1" -1 -1 -1 "$1"
426 enewgroup systemd-journal
427 newusergroup systemd-bus-proxy
428 newusergroup systemd-journal-gateway
429 newusergroup systemd-journal-remote
430 newusergroup systemd-journal-upload
431 newusergroup systemd-network
432 newusergroup systemd-resolve
433 newusergroup systemd-timesync
434 use http && newusergroup systemd-journal-gateway
436 systemd_update_catalog
438 # Keep this here in case the database format changes so it gets updated
439 # when required. Despite that this file is owned by sys-apps/hwids.
440 if has_version "sys-apps/hwids[udev]"; then
441 udevadm hwdb --update --root="${ROOT%/}"
444 udev_reload || FAIL=1
446 # Bug 465468, make sure locales are respect, and ensure consistency
447 # between OpenRC & systemd
450 # Migrate 80-net-name-slot.rules -> 80-net-setup-link.rules
451 migrate_net_name_slot
453 if [[ ${FAIL} ]]; then
454 eerror "One of the postinst commands failed. Please check the postinst output"
455 eerror "for errors. You may need to clean up your system and/or try installing"
456 eerror "systemd again."
460 if [[ $(readlink "${ROOT}"/etc/resolv.conf) == */run/systemd/network/resolv.conf ]]; then
461 ewarn "resolv.conf is now generated by systemd-resolved. To use it, enable"
462 ewarn "systemd-resolved.service, and create a symlink from /etc/resolv.conf"
463 ewarn "to /run/systemd/resolve/resolv.conf"
469 # If removing systemd completely, remove the catalog database.
470 if [[ ! ${REPLACED_BY_VERSION} ]]; then
471 rm -f -v "${EROOT}"/var/lib/systemd/catalog/database