1 # Copyright 2003-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit bash-completion-r1 linux-info meson ninja-utils multilib-minimal toolchain-funcs udev usr-ldscript
8 if [[ ${PV} = 9999* ]]; then
9 EGIT_REPO_URI="https://github.com/systemd/systemd.git"
15 SRC_URI="https://github.com/systemd/systemd/archive/v${MY_PV}/${MY_P}.tar.gz"
16 KEYWORDS="~alpha amd64 arm arm64 hppa ia64 ~m68k ~mips ppc ppc64 s390 sparc x86"
19 DESCRIPTION="Linux dynamic and persistent device naming support (aka userspace devfs)"
20 HOMEPAGE="https://www.freedesktop.org/wiki/Software/systemd"
22 LICENSE="LGPL-2.1 MIT GPL-2"
24 IUSE="acl +kmod selinux static-libs"
28 COMMON_DEPEND=">=sys-apps/util-linux-2.30[${MULTILIB_USEDEP}]
29 sys-libs/libcap[${MULTILIB_USEDEP}]
31 kmod? ( >=sys-apps/kmod-16 )
32 selinux? ( >=sys-libs/libselinux-2.1.9 )
34 !sys-apps/gentoo-systemd-integration
36 DEPEND="${COMMON_DEPEND}
38 >=dev-util/intltool-0.50
39 >=dev-util/meson-0.40.0
41 >=sys-apps/coreutils-8.16
44 >=sys-kernel/linux-headers-3.9
45 app-text/docbook-xml-dtd:4.2
46 app-text/docbook-xml-dtd:4.5
47 app-text/docbook-xsl-stylesheets
49 RDEPEND="${COMMON_DEPEND}
62 !<sys-fs/lvm2-2.02.103
63 !<sec-policy/selinux-base-2.20120725-r10"
64 PDEPEND=">=sys-apps/hwids-20140304[udev]
65 >=sys-fs/udev-init-scripts-26"
68 if [[ ${MERGE_TYPE} != buildonly ]]; then
69 CONFIG_CHECK="~BLK_DEV_BSG ~DEVTMPFS ~!IDE ~INOTIFY_USER ~!SYSFS_DEPRECATED ~!SYSFS_DEPRECATED_V2 ~SIGNALFD ~EPOLL ~FHANDLE ~NET ~!FW_LOADER_USER_HELPER ~UNIX"
72 # CONFIG_FHANDLE was introduced by 2.6.39
75 if kernel_is -lt ${MINKV//./ }; then
76 eerror "Your running kernel is too old to run this version of ${P}"
77 eerror "You need to upgrade kernel at least to ${MINKV}"
80 if kernel_is -lt 3 7; then
81 ewarn "Your running kernel is too old to have firmware loader and"
82 ewarn "this version of ${P} doesn't have userspace firmware loader"
83 ewarn "If you need firmware support, you need to upgrade kernel at least to 3.7"
89 cat <<-EOF > "${T}"/40-gentoo.rules
90 # Gentoo specific floppy and usb groups
91 ACTION=="add", SUBSYSTEM=="block", KERNEL=="fd[0-9]", GROUP="floppy"
92 ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", GROUP="usb"
95 if [[ -d "${WORKDIR}/patches" ]]; then
96 eapply "${WORKDIR}/patches"
102 meson_multilib_native_use() {
103 if multilib_is_native_abi && use "$1"; then
110 multilib_src_configure() {
112 -Dacl=$(meson_multilib_native_use acl)
114 -Dkmod=$(meson_multilib_native_use kmod)
115 -Dselinux=$(meson_multilib_native_use selinux)
116 -Dlink-udev-shared=false
118 -Drootlibdir="${EPREFIX}/usr/$(get_libdir)"
119 -Dstatic-libudev=$(usex static-libs true false)
121 # Prevent automagic deps
123 -Dlibcryptsetup=false
135 # Prevent conflicts with i686 cross toolchain, bug 559726
136 tc-export AR CC NM OBJCOPY RANLIB
137 multilib-minimal_src_configure
140 multilib_src_compile() {
141 # meson creates this link
142 local libudev=$(readlink src/udev/libudev.so.1)
147 if use static-libs; then
148 targets+=( src/udev/libudev.a )
150 if multilib_is_native_abi; then
163 man/systemd-udevd.service.8
167 eninja "${targets[@]}"
170 multilib_src_install() {
171 local libudev=$(readlink src/udev/libudev.so.1)
173 dolib.so src/udev/{${libudev},libudev.so.1,libudev.so}
174 gen_usr_ldscript -a udev
175 use static-libs && dolib.a src/udev/libudev.a
177 insinto "/usr/$(get_libdir)/pkgconfig"
178 doins src/libudev/libudev.pc
180 if multilib_is_native_abi; then
188 doexe src/udev/{ata_id,cdrom_id,mtd_probe,scsi_id,v4l_id}
190 rm rules/99-systemd.rules || die
191 insinto /lib/udev/rules.d
194 insinto /usr/share/pkgconfig
195 doins src/udev/udev.pc
197 mv man/systemd-udevd.service.8 man/systemd-udevd.8 || die
198 rm man/systemd-udevd-{control,kernel}.socket.8 || die
203 multilib_src_install_all() {
204 doheader src/libudev/libudev.h
207 doins src/udev/udev.conf
208 keepdir /etc/udev/{hwdb.d,rules.d}
210 insinto /lib/systemd/network
211 doins network/99-default.link
213 # see src_prepare() for content of 40-gentoo.rules
214 insinto /lib/udev/rules.d
215 doins "${T}"/40-gentoo.rules
216 doins "${S}"/rules/*.rules
218 dobashcomp shell-completion/bash/udevadm
220 insinto /usr/share/zsh/site-functions
221 doins shell-completion/zsh/_udevadm
227 mkdir -p "${ROOT%/}"/run
229 # "losetup -f" is confused if there is an empty /dev/loop/, Bug #338766
230 # So try to remove it here (will only work if empty).
231 rmdir "${ROOT%/}"/dev/loop 2>/dev/null
232 if [[ -d ${ROOT%/}/dev/loop ]]; then
233 ewarn "Please make sure your remove /dev/loop,"
234 ewarn "else losetup may be confused when looking for unused devices."
237 local fstab="${ROOT%/}"/etc/fstab dev path fstype rest
238 while read -r dev path fstype rest; do
239 if [[ ${path} == /dev && ${fstype} != devtmpfs ]]; then
240 ewarn "You need to edit your /dev line in ${fstab} to have devtmpfs"
241 ewarn "filesystem. Otherwise udev won't be able to boot."
242 ewarn "See, https://bugs.gentoo.org/453186"
246 if [[ -d ${ROOT%/}/usr/lib/udev ]]; then
248 ewarn "Please re-emerge all packages on your system which install"
249 ewarn "rules and helpers in /usr/lib/udev. They should now be in"
252 ewarn "One way to do this is to run the following command:"
253 ewarn "emerge -av1 \$(qfile -q -S -C /usr/lib/udev)"
254 ewarn "Note that qfile can be found in app-portage/portage-utils"
257 local old_cd_rules="${ROOT%/}"/etc/udev/rules.d/70-persistent-cd.rules
258 local old_net_rules="${ROOT%/}"/etc/udev/rules.d/70-persistent-net.rules
259 for old_rules in "${old_cd_rules}" "${old_net_rules}"; do
260 if [[ -f ${old_rules} ]]; then
262 ewarn "File ${old_rules} is from old udev installation but if you still use it,"
263 ewarn "rename it to something else starting with 70- to silence this deprecation"
269 elog "Starting from version >= 197 the new predictable network interface names are"
270 elog "used by default, see:"
271 elog "https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames"
272 elog "https://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c"
274 elog "Example command to get the information for the new interface name before booting"
275 elog "(replace <ifname> with, for example, eth0):"
276 elog "# udevadm test-builtin net_id /sys/class/net/<ifname> 2> /dev/null"
278 elog "You can use either kernel parameter \"net.ifnames=0\", create empty"
279 elog "file /etc/systemd/network/99-default.link, or symlink it to /dev/null"
280 elog "to disable the feature."
282 if has_version 'sys-apps/biosdevname'; then
284 ewarn "You can replace the functionality of sys-apps/biosdevname which has been"
285 ewarn "detected to be installed with the new predictable network interface names."
289 ewarn "You need to restart udev as soon as possible to make the upgrade go"
291 ewarn "The method you use to do this depends on your init system."
292 if has_version 'sys-apps/openrc'; then
293 ewarn "For sys-apps/openrc users it is:"
294 ewarn "# /etc/init.d/udev --nodeps restart"
298 elog "For more information on udev on Gentoo, upgrading, writing udev rules, and"
299 elog "fixing known issues visit:"
300 elog "https://wiki.gentoo.org/wiki/Udev"
301 elog "https://wiki.gentoo.org/wiki/Udev/upgrade"
303 # If user has disabled 80-net-name-slot.rules using a empty file or a symlink to /dev/null,
304 # do the same for 80-net-setup-link.rules to keep the old behavior
306 local net_name_slot_sym=no
307 local net_rules_path="${ROOT%/}"/etc/udev/rules.d
308 local net_name_slot="${net_rules_path}"/80-net-name-slot.rules
309 local net_setup_link="${net_rules_path}"/80-net-setup-link.rules
310 if [[ ! -e ${net_setup_link} ]]; then
311 [[ -f ${net_name_slot} && $(sed -e "/^#/d" -e "/^\W*$/d" ${net_name_slot} | wc -l) == 0 ]] && net_move=yes
312 if [[ -L ${net_name_slot} && $(readlink ${net_name_slot}) == /dev/null ]]; then
314 net_name_slot_sym=yes
317 if [[ ${net_move} == yes ]]; then
318 ebegin "Copying ${net_name_slot} to ${net_setup_link}"
320 if [[ ${net_name_slot_sym} == yes ]]; then
321 ln -nfs /dev/null "${net_setup_link}"
323 cp "${net_name_slot}" "${net_setup_link}"
328 # Update hwdb database in case the format is changed by udev version.
329 if has_version 'sys-apps/hwids[udev]'; then
330 udevadm hwdb --update --root="${ROOT%/}"
331 # Only reload when we are not upgrading to avoid potential race w/ incompatible hwdb.bin and the running udevd
332 # https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
333 [[ -z ${REPLACING_VERSIONS} ]] && udev_reload