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"
14 SRC_URI="https://github.com/systemd/systemd/archive/v${PV}.tar.gz -> ${P}.tar.gz"
15 if [[ -n "${patchset}" ]]; then
17 https://dev.gentoo.org/~ssuominen/${P}-patches-${patchset}.tar.xz
18 https://dev.gentoo.org/~williamh/dist/${P}-patches-${patchset}.tar.xz"
20 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
23 DESCRIPTION="Linux dynamic and persistent device naming support (aka userspace devfs)"
24 HOMEPAGE="http://www.freedesktop.org/wiki/Software/systemd"
26 LICENSE="LGPL-2.1 MIT GPL-2"
28 IUSE="acl +kmod selinux static-libs"
32 COMMON_DEPEND=">=sys-apps/util-linux-2.24
33 sys-libs/libcap[${MULTILIB_USEDEP}]
35 kmod? ( >=sys-apps/kmod-16 )
36 selinux? ( >=sys-libs/libselinux-2.1.9 )
38 !sys-apps/gentoo-systemd-integration
41 !<=app-emulation/emul-linux-x86-baselibs-20130224-r7
42 !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
44 # Force new make >= -r4 to skip some parallel build issues
45 DEPEND="${COMMON_DEPEND}
47 >=dev-util/intltool-0.50
48 >=sys-apps/coreutils-8.16
51 >=sys-devel/make-3.82-r4
52 >=sys-kernel/linux-headers-3.9
53 app-text/docbook-xml-dtd:4.2
54 app-text/docbook-xml-dtd:4.5
55 app-text/docbook-xsl-stylesheets
57 RDEPEND="${COMMON_DEPEND}
58 !<sys-fs/lvm2-2.02.103
59 !<sec-policy/selinux-base-2.20120725-r10"
60 PDEPEND=">=sys-apps/hwids-20140304[udev]
61 >=sys-fs/udev-init-scripts-26"
63 S=${WORKDIR}/systemd-${PV}
65 # The multilib-build.eclass doesn't handle situation where the installed headers
66 # are different in ABIs. In this case, we install libgudev headers in native
67 # ABI but not for non-native ABI.
68 multilib_check_headers() { :; }
70 check_default_rules() {
71 # Make sure there are no sudden changes to upstream rules file
72 # (more for my own needs than anything else ...)
73 local udev_rules_md5=b8ad860dccae0ca51656b33c405ea2ca
74 MD5=$(md5sum < "${S}"/rules/50-udev-default.rules)
76 if [[ ${MD5} != ${udev_rules_md5} ]]; then
77 eerror "50-udev-default.rules has been updated, please validate!"
78 eerror "md5sum: ${MD5}"
79 die "50-udev-default.rules has been updated, please validate!"
84 if [[ ${MERGE_TYPE} != buildonly ]]; then
85 CONFIG_CHECK="~BLK_DEV_BSG ~DEVTMPFS ~!IDE ~INOTIFY_USER ~!SYSFS_DEPRECATED ~!SYSFS_DEPRECATED_V2 ~SIGNALFD ~EPOLL ~FHANDLE ~NET ~!FW_LOADER_USER_HELPER"
88 # CONFIG_FHANDLE was introduced by 2.6.39
91 if kernel_is -lt ${MINKV//./ }; then
92 eerror "Your running kernel is too old to run this version of ${P}"
93 eerror "You need to upgrade kernel at least to ${MINKV}"
96 if kernel_is -lt 3 7; then
97 ewarn "Your running kernel is too old to have firmware loader and"
98 ewarn "this version of ${P} doesn't have userspace firmware loader"
99 ewarn "If you need firmware support, you need to upgrade kernel at least to 3.7"
105 if ! [[ ${PV} = 9999* ]]; then
106 # secure_getenv() disable for non-glibc systems wrt bug #443030
107 if ! [[ $(grep -r secure_getenv * | wc -l) -eq 25 ]]; then
108 eerror "The line count for secure_getenv() failed, see bug #443030"
113 # backport some patches
114 if [[ -n "${patchset}" ]]; then
115 EPATCH_SUFFIX=patch EPATCH_FORCE=yes epatch
118 cat <<-EOF > "${T}"/40-gentoo.rules
119 # Gentoo specific floppy and usb groups
120 SUBSYSTEM=="block", KERNEL=="fd[0-9]", GROUP="floppy"
121 SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", GROUP="usb"
124 # change rules back to group uucp instead of dialout for now wrt #454556
125 sed -i -e 's/GROUP="dialout"/GROUP="uucp"/' rules/*.rules || die
127 # stub out the am_path_libcrypt function
128 echo 'AC_DEFUN([AM_PATH_LIBGCRYPT],[:])' > m4/gcrypt.m4
135 if ! [[ ${PV} = 9999* ]]; then
139 # Restore possibility of running --enable-static wrt #472608
141 -e '/--enable-static is not supported by systemd/s:as_fn_error:echo:' \
144 if ! use elibc_glibc; then #443030
145 echo '#define secure_getenv(x) NULL' >> config.h.in
146 sed -i -e '/error.*secure_getenv/s:.*:#define secure_getenv(x) NULL:' src/shared/missing.h || die
150 multilib_src_configure() {
152 export cc_cv_CFLAGS__flto=no #502950
153 export cc_cv_CFLAGS__Werror_shadow=no #554454
155 # Keep sorted by ./configure --help and only pass --disable flags
156 # when *required* to avoid external deps or unnecessary compile
159 --libdir=/usr/$(get_libdir)
160 --docdir=/usr/share/doc/${PF}
161 $(multilib_native_use_enable static-libs static)
164 $(multilib_native_use_enable kmod)
167 $(multilib_native_use_enable selinux)
171 $(multilib_native_use_enable acl)
174 --disable-libcryptsetup
185 $(multilib_is_native_abi || echo "--disable-manpages")
188 --with-bashcompletiondir="$(get_bashcompdir)"
190 $(multilib_is_native_abi && echo "--with-rootlibdir=/$(get_libdir)")
194 if ! multilib_is_native_abi; then
196 MOUNT_{CFLAGS,LIBS}=' '
200 ECONF_SOURCE=${S} econf "${econf_args[@]}"
203 multilib_src_compile() {
204 echo 'BUILT_SOURCES: $(BUILT_SOURCES)' > "${T}"/Makefile.extra
205 emake -f Makefile -f "${T}"/Makefile.extra BUILT_SOURCES
207 # Most of the parallel build problems were solved by >=sys-devel/make-3.82-r4,
208 # but not everything -- separate building of the binaries as a workaround,
209 # which will force internal libraries required for the helpers to be built
210 # early enough, like eg. libsystemd-shared.la
211 if multilib_is_native_abi; then
212 local lib_targets=( libudev.la )
213 emake "${lib_targets[@]}"
219 emake "${exec_targets[@]}"
221 local helper_targets=(
229 emake "${helper_targets[@]}"
235 man/systemd-udevd.service.8
238 emake "${man_targets[@]}"
240 local lib_targets=( libudev.la )
241 emake "${lib_targets[@]}"
245 multilib_src_install() {
246 if multilib_is_native_abi; then
247 local lib_LTLIBRARIES="libudev.la" \
248 pkgconfiglib_DATA="src/libudev/libudev.pc"
251 install-libLTLIBRARIES
252 install-includeHEADERS
253 install-rootbinPROGRAMS
254 install-rootlibexecPROGRAMS
255 install-udevlibexecPROGRAMS
256 install-dist_udevconfDATA
257 install-dist_udevrulesDATA
258 install-pkgconfiglibDATA
259 install-pkgconfigdataDATA
262 install-directories-hook
263 install-dist_bashcompletionDATA
264 install-dist_networkDATA
267 # add final values of variables:
269 rootlibexec_PROGRAMS=systemd-udevd
270 rootbin_PROGRAMS=udevadm
271 lib_LTLIBRARIES="${lib_LTLIBRARIES}"
272 pkgconfiglib_DATA="${pkgconfiglib_DATA}"
273 pkgconfigdata_DATA="src/udev/udev.pc"
274 INSTALL_DIRS='$(sysconfdir)/udev/rules.d \
275 $(sysconfdir)/udev/hwdb.d \
276 $(sysconfdir)/systemd/network'
277 dist_bashcompletion_DATA="shell-completion/bash/udevadm"
278 dist_network_DATA="network/99-default.link"
280 emake -j1 DESTDIR="${D}" "${targets[@]}"
281 doman man/{udev.conf.5,systemd.link.5,udev.7,systemd-udevd.service.8,udevadm.8}
283 local lib_LTLIBRARIES="libudev.la" \
284 pkgconfiglib_DATA="src/libudev/libudev.pc" \
285 include_HEADERS="src/libudev/libudev.h"
288 install-libLTLIBRARIES
289 install-includeHEADERS
290 install-pkgconfiglibDATA
294 lib_LTLIBRARIES="${lib_LTLIBRARIES}"
295 pkgconfiglib_DATA="${pkgconfiglib_DATA}"
296 include_HEADERS="${include_HEADERS}"
298 emake -j1 DESTDIR="${D}" "${targets[@]}"
302 multilib_src_install_all() {
305 prune_libtool_files --all
307 "${D}"/lib/udev/rules.d/99-systemd.rules \
308 "${D}"/usr/share/doc/${PF}/{LICENSE.*,GVARIANT-SERIALIZATION,DIFFERENCES,PORTING-DBUS1,sd-shutdown.h}
310 # see src_prepare() for content of 40-gentoo.rules
311 insinto /lib/udev/rules.d
312 doins "${T}"/40-gentoo.rules
314 # maintainer note: by not letting the upstream build-sys create the .so
315 # link, you also avoid a parallel make problem
316 mv "${D}"/usr/share/man/man8/systemd-udevd{.service,}.8
320 mkdir -p "${ROOT%/}"/run
322 # "losetup -f" is confused if there is an empty /dev/loop/, Bug #338766
323 # So try to remove it here (will only work if empty).
324 rmdir "${ROOT%/}"/dev/loop 2>/dev/null
325 if [[ -d ${ROOT%/}/dev/loop ]]; then
326 ewarn "Please make sure your remove /dev/loop,"
327 ewarn "else losetup may be confused when looking for unused devices."
330 local fstab="${ROOT%/}"/etc/fstab dev path fstype rest
331 while read -r dev path fstype rest; do
332 if [[ ${path} == /dev && ${fstype} != devtmpfs ]]; then
333 ewarn "You need to edit your /dev line in ${fstab} to have devtmpfs"
334 ewarn "filesystem. Otherwise udev won't be able to boot."
335 ewarn "See, http://bugs.gentoo.org/453186"
339 if [[ -d ${ROOT%/}/usr/lib/udev ]]; then
341 ewarn "Please re-emerge all packages on your system which install"
342 ewarn "rules and helpers in /usr/lib/udev. They should now be in"
345 ewarn "One way to do this is to run the following command:"
346 ewarn "emerge -av1 \$(qfile -q -S -C /usr/lib/udev)"
347 ewarn "Note that qfile can be found in app-portage/portage-utils"
350 local old_cd_rules="${ROOT%/}"/etc/udev/rules.d/70-persistent-cd.rules
351 local old_net_rules="${ROOT%/}"/etc/udev/rules.d/70-persistent-net.rules
352 for old_rules in "${old_cd_rules}" "${old_net_rules}"; do
353 if [[ -f ${old_rules} ]]; then
355 ewarn "File ${old_rules} is from old udev installation but if you still use it,"
356 ewarn "rename it to something else starting with 70- to silence this deprecation"
362 elog "Starting from version >= 197 the new predictable network interface names are"
363 elog "used by default, see:"
364 elog "http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames"
365 elog "http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c"
367 elog "Example command to get the information for the new interface name before booting"
368 elog "(replace <ifname> with, for example, eth0):"
369 elog "# udevadm test-builtin net_id /sys/class/net/<ifname> 2> /dev/null"
371 elog "You can use either kernel parameter \"net.ifnames=0\", create empty"
372 elog "file /etc/systemd/network/99-default.link, or symlink it to /dev/null"
373 elog "to disable the feature."
375 if has_version 'sys-apps/biosdevname'; then
377 ewarn "You can replace the functionality of sys-apps/biosdevname which has been"
378 ewarn "detected to be installed with the new predictable network interface names."
382 ewarn "You need to restart udev as soon as possible to make the upgrade go"
384 ewarn "The method you use to do this depends on your init system."
385 if has_version 'sys-apps/openrc'; then
386 ewarn "For sys-apps/openrc users it is:"
387 ewarn "# /etc/init.d/udev --nodeps restart"
391 elog "For more information on udev on Gentoo, upgrading, writing udev rules, and"
392 elog "fixing known issues visit:"
393 elog "http://wiki.gentoo.org/wiki/Udev"
394 elog "http://wiki.gentoo.org/wiki/Udev/upgrade"
396 # If user has disabled 80-net-name-slot.rules using a empty file or a symlink to /dev/null,
397 # do the same for 80-net-setup-link.rules to keep the old behavior
399 local net_name_slot_sym=no
400 local net_rules_path="${ROOT%/}"/etc/udev/rules.d
401 local net_name_slot="${net_rules_path}"/80-net-name-slot.rules
402 local net_setup_link="${net_rules_path}"/80-net-setup-link.rules
403 if [[ ! -e ${net_setup_link} ]]; then
404 [[ -f ${net_name_slot} && $(sed -e "/^#/d" -e "/^\W*$/d" ${net_name_slot} | wc -l) == 0 ]] && net_move=yes
405 if [[ -L ${net_name_slot} && $(readlink ${net_name_slot}) == /dev/null ]]; then
407 net_name_slot_sym=yes
410 if [[ ${net_move} == yes ]]; then
411 ebegin "Copying ${net_name_slot} to ${net_setup_link}"
413 if [[ ${net_name_slot_sym} == yes ]]; then
414 ln -nfs /dev/null "${net_setup_link}"
416 cp "${net_name_slot}" "${net_setup_link}"
421 # http://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
422 # http://bugs.gentoo.org/246847
423 # http://bugs.gentoo.org/514174
426 # Update hwdb database in case the format is changed by udev version.
427 if has_version 'sys-apps/hwids[udev]'; then
428 udevadm hwdb --update --root="${ROOT%/}"
429 # Only reload when we are not upgrading to avoid potential race w/ incompatible hwdb.bin and the running udevd
430 # http://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
431 [[ -z ${REPLACING_VERSIONS} ]] && udev_reload