1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit autotools bash-completion-r1 eutils linux-info multilib multilib-minimal toolchain-funcs udev user versionator
9 if [[ ${PV} = 9999* ]]; then
10 EGIT_REPO_URI="git://anongit.freedesktop.org/systemd/systemd"
15 SRC_URI="http://www.freedesktop.org/software/systemd/systemd-${PV}.tar.xz"
16 if [[ -n "${patchset}" ]]; then
18 https://dev.gentoo.org/~ssuominen/${P}-patches-${patchset}.tar.xz
19 https://dev.gentoo.org/~williamh/dist/${P}-patches-${patchset}.tar.xz"
21 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
24 DESCRIPTION="Linux dynamic and persistent device naming support (aka userspace devfs)"
25 HOMEPAGE="http://www.freedesktop.org/wiki/Software/systemd"
27 LICENSE="LGPL-2.1 MIT GPL-2"
29 IUSE="acl doc gudev introspection +kmod selinux static-libs"
33 COMMON_DEPEND=">=sys-apps/util-linux-2.20
35 gudev? ( >=dev-libs/glib-2.34.3[${MULTILIB_USEDEP}] )
36 introspection? ( >=dev-libs/gobject-introspection-1.38 )
37 kmod? ( >=sys-apps/kmod-16 )
38 selinux? ( >=sys-libs/libselinux-2.1.9 )
40 !sys-apps/gentoo-systemd-integration
43 !<=app-emulation/emul-linux-x86-baselibs-20130224-r7
44 !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
46 # Force new make >= -r4 to skip some parallel build issues
47 DEPEND="${COMMON_DEPEND}
49 >=sys-apps/coreutils-8.16
53 >=sys-devel/make-3.82-r4
54 >=sys-kernel/linux-headers-3.9
55 doc? ( >=dev-util/gtk-doc-1.18 )"
56 # Try with `emerge -C docbook-xml-dtd` to see the build failure without DTDs
57 if [[ ${PV} = 9999* ]]; then
59 app-text/docbook-xml-dtd:4.2
60 app-text/docbook-xml-dtd:4.5
61 app-text/docbook-xsl-stylesheets
64 RDEPEND="${COMMON_DEPEND}
65 !<sys-fs/lvm2-2.02.103
66 !<sec-policy/selinux-base-2.20120725-r10
67 gudev? ( !dev-libs/libgudev )"
68 PDEPEND=">=sys-apps/hwids-20140304[udev]
69 >=sys-fs/udev-init-scripts-26"
71 S=${WORKDIR}/systemd-${PV}
73 # The multilib-build.eclass doesn't handle situation where the installed headers
74 # are different in ABIs. In this case, we install libgudev headers in native
75 # ABI but not for non-native ABI.
76 multilib_check_headers() { :; }
78 check_default_rules() {
79 # Make sure there are no sudden changes to upstream rules file
80 # (more for my own needs than anything else ...)
81 local udev_rules_md5=b8ad860dccae0ca51656b33c405ea2ca
82 MD5=$(md5sum < "${S}"/rules/50-udev-default.rules)
84 if [[ ${MD5} != ${udev_rules_md5} ]]; then
85 eerror "50-udev-default.rules has been updated, please validate!"
86 eerror "md5sum: ${MD5}"
87 die "50-udev-default.rules has been updated, please validate!"
92 if [[ ${MERGE_TYPE} != buildonly ]]; then
93 CONFIG_CHECK="~BLK_DEV_BSG ~DEVTMPFS ~!IDE ~INOTIFY_USER ~!SYSFS_DEPRECATED ~!SYSFS_DEPRECATED_V2 ~SIGNALFD ~EPOLL ~FHANDLE ~NET ~!FW_LOADER_USER_HELPER"
96 # CONFIG_FHANDLE was introduced by 2.6.39
99 if kernel_is -lt ${MINKV//./ }; then
100 eerror "Your running kernel is too old to run this version of ${P}"
101 eerror "You need to upgrade kernel at least to ${MINKV}"
104 if kernel_is -lt 3 7; then
105 ewarn "Your running kernel is too old to have firmware loader and"
106 ewarn "this version of ${P} doesn't have userspace firmware loader"
107 ewarn "If you need firmware support, you need to upgrade kernel at least to 3.7"
113 if ! [[ ${PV} = 9999* ]]; then
114 # secure_getenv() disable for non-glibc systems wrt bug #443030
115 if ! [[ $(grep -r secure_getenv * | wc -l) -eq 28 ]]; then
116 eerror "The line count for secure_getenv() failed, see bug #443030"
121 # backport some patches
122 if [[ -n "${patchset}" ]]; then
123 EPATCH_SUFFIX=patch EPATCH_FORCE=yes epatch
126 cat <<-EOF > "${T}"/40-gentoo.rules
127 # Gentoo specific floppy and usb groups
128 SUBSYSTEM=="block", KERNEL=="fd[0-9]", GROUP="floppy"
129 SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", GROUP="usb"
132 # change rules back to group uucp instead of dialout for now wrt #454556
133 sed -i -e 's/GROUP="dialout"/GROUP="uucp"/' rules/*.rules || die
138 if [[ ! -e configure ]]; then
140 gtkdocize --docdir docs || die "gtkdocize failed"
142 echo 'EXTRA_DIST =' > docs/gtk-doc.make
150 # Restore possibility of running --enable-static wrt #472608
152 -e '/--enable-static is not supported by systemd/s:as_fn_error:echo:' \
155 if ! use elibc_glibc; then #443030
156 echo '#define secure_getenv(x) NULL' >> config.h.in
157 sed -i -e '/error.*secure_getenv/s:.*:#define secure_getenv(x) NULL:' src/shared/missing.h || die
159 rm src/journal/audit_type-to-name.h src/udev/keyboard-keys-from-name.gperf \
163 multilib_src_configure() {
165 export cc_cv_CFLAGS__flto=no #502950
167 # Keep sorted by ./configure --help and only pass --disable flags
168 # when *required* to avoid external deps or unnecessary compile
171 ac_cv_search_cap_init=
172 --libdir=/usr/$(get_libdir)
173 --docdir=/usr/share/doc/${PF}
174 $(multilib_native_use_enable static-libs static)
176 $(multilib_native_use_enable doc gtk-doc)
177 $(multilib_native_use_enable introspection)
178 --disable-python-devel
180 $(multilib_native_use_enable kmod)
183 $(multilib_native_use_enable selinux)
187 $(multilib_native_use_enable acl)
190 --disable-libcryptsetup
202 $(multilib_is_native_abi || echo "--disable-manpages")
204 --with-html-dir=/usr/share/doc/${PF}/html
206 --with-bashcompletiondir="$(get_bashcompdir)"
208 $(multilib_is_native_abi && echo "--with-rootlibdir=/$(get_libdir)")
211 if ! multilib_is_native_abi; then
213 MOUNT_{CFLAGS,LIBS}=' '
217 # Use pregenerated copies when possible wrt #480924
218 [[ ${PV} = 9999* ]] || econf_args+=( --disable-manpages )
220 ECONF_SOURCE=${S} econf "${econf_args[@]}"
223 multilib_src_compile() {
224 echo 'BUILT_SOURCES: $(BUILT_SOURCES)' > "${T}"/Makefile.extra
225 emake -f Makefile -f "${T}"/Makefile.extra BUILT_SOURCES
227 # Most of the parallel build problems were solved by >=sys-devel/make-3.82-r4,
228 # but not everything -- separate building of the binaries as a workaround,
229 # which will force internal libraries required for the helpers to be built
230 # early enough, like eg. libsystemd-shared.la
231 if multilib_is_native_abi; then
232 local lib_targets=( libudev.la )
233 use gudev && lib_targets+=( libgudev-1.0.la )
234 emake "${lib_targets[@]}"
240 emake "${exec_targets[@]}"
242 local helper_targets=(
251 emake "${helper_targets[@]}"
253 if [[ ${PV} = 9999* ]]; then
258 man/systemd-udevd.service.8
261 emake "${man_targets[@]}"
265 emake -C docs/libudev
266 use gudev && emake -C docs/gudev
269 local lib_targets=( libudev.la )
270 use gudev && lib_targets+=( libgudev-1.0.la )
271 emake "${lib_targets[@]}"
275 multilib_src_install() {
276 if multilib_is_native_abi; then
277 local lib_LTLIBRARIES="libudev.la" \
278 pkgconfiglib_DATA="src/libudev/libudev.pc"
281 install-libLTLIBRARIES
282 install-includeHEADERS
283 install-libgudev_includeHEADERS
284 install-rootbinPROGRAMS
285 install-rootlibexecPROGRAMS
286 install-udevlibexecPROGRAMS
287 install-dist_udevconfDATA
288 install-dist_udevrulesDATA
290 install-pkgconfiglibDATA
291 install-pkgconfigdataDATA
295 install-directories-hook
296 install-dist_bashcompletionDATA
297 install-dist_networkDATA
301 lib_LTLIBRARIES+=" libgudev-1.0.la"
302 pkgconfiglib_DATA+=" src/gudev/gudev-1.0.pc"
305 # add final values of variables:
307 rootlibexec_PROGRAMS=systemd-udevd
308 rootbin_PROGRAMS=udevadm
309 lib_LTLIBRARIES="${lib_LTLIBRARIES}"
310 pkgconfiglib_DATA="${pkgconfiglib_DATA}"
311 pkgconfigdata_DATA="src/udev/udev.pc"
312 INSTALL_DIRS='$(sysconfdir)/udev/rules.d \
313 $(sysconfdir)/udev/hwdb.d \
314 $(sysconfdir)/systemd/network'
315 dist_bashcompletion_DATA="shell-completion/bash/udevadm"
316 dist_network_DATA="network/99-default.link"
318 emake -j1 DESTDIR="${D}" "${targets[@]}"
321 emake -C docs/libudev DESTDIR="${D}" install
322 use gudev && emake -C docs/gudev DESTDIR="${D}" install
325 if [[ ${PV} = 9999* ]]; then
326 doman man/{udev.conf.5,systemd.link.5,udev.7,systemd-udevd.service.8,udevadm.8}
328 doman "${S}"/man/{udev.conf.5,systemd.link.5,udev.7,systemd-udevd.service.8,udevadm.8}
331 local lib_LTLIBRARIES="libudev.la" \
332 pkgconfiglib_DATA="src/libudev/libudev.pc" \
333 include_HEADERS="src/libudev/libudev.h"
336 install-libLTLIBRARIES
337 install-includeHEADERS
338 install-pkgconfiglibDATA
342 lib_LTLIBRARIES+=" libgudev-1.0.la"
343 pkgconfiglib_DATA+=" src/gudev/gudev-1.0.pc"
347 lib_LTLIBRARIES="${lib_LTLIBRARIES}"
348 pkgconfiglib_DATA="${pkgconfiglib_DATA}"
349 include_HEADERS="${include_HEADERS}"
351 emake -j1 DESTDIR="${D}" "${targets[@]}"
355 multilib_src_install_all() {
358 prune_libtool_files --all
360 "${D}"/lib/udev/rules.d/99-systemd.rules \
361 "${D}"/usr/share/doc/${PF}/{LICENSE.*,GVARIANT-SERIALIZATION,DIFFERENCES,PORTING-DBUS1,sd-shutdown.h}
363 # see src_prepare() for content of 40-gentoo.rules
364 insinto /lib/udev/rules.d
365 doins "${T}"/40-gentoo.rules
367 # maintainer note: by not letting the upstream build-sys create the .so
368 # link, you also avoid a parallel make problem
369 mv "${D}"/usr/share/man/man8/systemd-udevd{.service,}.8
371 if ! [[ ${PV} = 9999* ]]; then
372 insinto /usr/share/doc/${PF}/html/gudev
373 doins "${S}"/docs/gudev/html/*
375 insinto /usr/share/doc/${PF}/html/libudev
376 doins "${S}"/docs/libudev/html/*
382 for htmldir in gudev libudev; do
383 if [[ -d ${ROOT%/}/usr/share/gtk-doc/html/${htmldir} ]]; then
384 rm -rf "${ROOT%/}"/usr/share/gtk-doc/html/${htmldir}
386 if [[ -d ${D}/usr/share/doc/${PF}/html/${htmldir} ]]; then
387 dosym ../../doc/${PF}/html/${htmldir} \
388 /usr/share/gtk-doc/html/${htmldir}
394 mkdir -p "${ROOT%/}"/run
396 # "losetup -f" is confused if there is an empty /dev/loop/, Bug #338766
397 # So try to remove it here (will only work if empty).
398 rmdir "${ROOT%/}"/dev/loop 2>/dev/null
399 if [[ -d ${ROOT%/}/dev/loop ]]; then
400 ewarn "Please make sure your remove /dev/loop,"
401 ewarn "else losetup may be confused when looking for unused devices."
404 local fstab="${ROOT%/}"/etc/fstab dev path fstype rest
405 while read -r dev path fstype rest; do
406 if [[ ${path} == /dev && ${fstype} != devtmpfs ]]; then
407 ewarn "You need to edit your /dev line in ${fstab} to have devtmpfs"
408 ewarn "filesystem. Otherwise udev won't be able to boot."
409 ewarn "See, http://bugs.gentoo.org/453186"
413 if [[ -d ${ROOT%/}/usr/lib/udev ]]; then
415 ewarn "Please re-emerge all packages on your system which install"
416 ewarn "rules and helpers in /usr/lib/udev. They should now be in"
419 ewarn "One way to do this is to run the following command:"
420 ewarn "emerge -av1 \$(qfile -q -S -C /usr/lib/udev)"
421 ewarn "Note that qfile can be found in app-portage/portage-utils"
424 local old_cd_rules="${ROOT%/}"/etc/udev/rules.d/70-persistent-cd.rules
425 local old_net_rules="${ROOT%/}"/etc/udev/rules.d/70-persistent-net.rules
426 for old_rules in "${old_cd_rules}" "${old_net_rules}"; do
427 if [[ -f ${old_rules} ]]; then
429 ewarn "File ${old_rules} is from old udev installation but if you still use it,"
430 ewarn "rename it to something else starting with 70- to silence this deprecation"
436 elog "Starting from version >= 197 the new predictable network interface names are"
437 elog "used by default, see:"
438 elog "http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames"
439 elog "http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c"
441 elog "Example command to get the information for the new interface name before booting"
442 elog "(replace <ifname> with, for example, eth0):"
443 elog "# udevadm test-builtin net_id /sys/class/net/<ifname> 2> /dev/null"
445 elog "You can use either kernel parameter \"net.ifnames=0\", create empty"
446 elog "file /etc/systemd/network/99-default.link, or symlink it to /dev/null"
447 elog "to disable the feature."
449 if has_version 'sys-apps/biosdevname'; then
451 ewarn "You can replace the functionality of sys-apps/biosdevname which has been"
452 ewarn "detected to be installed with the new predictable network interface names."
456 ewarn "You need to restart udev as soon as possible to make the upgrade go"
458 ewarn "The method you use to do this depends on your init system."
459 if has_version 'sys-apps/openrc'; then
460 ewarn "For sys-apps/openrc users it is:"
461 ewarn "# /etc/init.d/udev --nodeps restart"
465 elog "For more information on udev on Gentoo, upgrading, writing udev rules, and"
466 elog "fixing known issues visit:"
467 elog "http://wiki.gentoo.org/wiki/Udev"
468 elog "http://wiki.gentoo.org/wiki/Udev/upgrade"
470 # If user has disabled 80-net-name-slot.rules using a empty file or a symlink to /dev/null,
471 # do the same for 80-net-setup-link.rules to keep the old behavior
473 local net_name_slot_sym=no
474 local net_rules_path="${ROOT%/}"/etc/udev/rules.d
475 local net_name_slot="${net_rules_path}"/80-net-name-slot.rules
476 local net_setup_link="${net_rules_path}"/80-net-setup-link.rules
477 if [[ ! -e ${net_setup_link} ]]; then
478 [[ -f ${net_name_slot} && $(sed -e "/^#/d" -e "/^\W*$/d" ${net_name_slot} | wc -l) == 0 ]] && net_move=yes
479 if [[ -L ${net_name_slot} && $(readlink ${net_name_slot}) == /dev/null ]]; then
481 net_name_slot_sym=yes
484 if [[ ${net_move} == yes ]]; then
485 ebegin "Copying ${net_name_slot} to ${net_setup_link}"
487 if [[ ${net_name_slot_sym} == yes ]]; then
488 ln -nfs /dev/null "${net_setup_link}"
490 cp "${net_name_slot}" "${net_setup_link}"
495 # http://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
496 # http://bugs.gentoo.org/246847
497 # http://bugs.gentoo.org/514174
500 # Update hwdb database in case the format is changed by udev version.
501 if has_version 'sys-apps/hwids[udev]'; then
502 udevadm hwdb --update --root="${ROOT%/}"
503 # Only reload when we are not upgrading to avoid potential race w/ incompatible hwdb.bin and the running udevd
504 # http://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
505 [[ -z ${REPLACING_VERSIONS} ]] && udev_reload