1 # Copyright 2003-2019 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
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 ~sh ~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"
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
119 # Prevent automagic deps
121 -Dlibcryptsetup=false
133 # Prevent conflicts with i686 cross toolchain, bug 559726
134 tc-export AR CC NM OBJCOPY RANLIB
135 multilib-minimal_src_configure
138 multilib_src_compile() {
139 # meson creates this link
140 local libudev=$(readlink src/udev/libudev.so.1)
145 if multilib_is_native_abi; then
158 man/systemd-udevd.service.8
162 eninja "${targets[@]}"
165 multilib_src_install() {
166 local libudev=$(readlink src/udev/libudev.so.1)
169 dolib.so src/udev/{${libudev},libudev.so.1,libudev.so}
171 insinto "/usr/$(get_libdir)/pkgconfig"
172 doins src/libudev/libudev.pc
174 if multilib_is_native_abi; then
182 doexe src/udev/{ata_id,cdrom_id,mtd_probe,scsi_id,v4l_id}
184 rm rules/99-systemd.rules || die
185 insinto /lib/udev/rules.d
188 insinto /usr/share/pkgconfig
189 doins src/udev/udev.pc
191 mv man/systemd-udevd.service.8 man/systemd-udevd.8 || die
192 rm man/systemd-udevd-{control,kernel}.socket.8 || die
197 multilib_src_install_all() {
198 doheader src/libudev/libudev.h
201 doins src/udev/udev.conf
202 keepdir /etc/udev/{hwdb.d,rules.d}
204 insinto /lib/systemd/network
205 doins network/99-default.link
207 # see src_prepare() for content of 40-gentoo.rules
208 insinto /lib/udev/rules.d
209 doins "${T}"/40-gentoo.rules
210 doins "${S}"/rules/*.rules
212 dobashcomp shell-completion/bash/udevadm
214 insinto /usr/share/zsh/site-functions
215 doins shell-completion/zsh/_udevadm
221 mkdir -p "${ROOT%/}"/run
223 # "losetup -f" is confused if there is an empty /dev/loop/, Bug #338766
224 # So try to remove it here (will only work if empty).
225 rmdir "${ROOT%/}"/dev/loop 2>/dev/null
226 if [[ -d ${ROOT%/}/dev/loop ]]; then
227 ewarn "Please make sure your remove /dev/loop,"
228 ewarn "else losetup may be confused when looking for unused devices."
231 local fstab="${ROOT%/}"/etc/fstab dev path fstype rest
232 while read -r dev path fstype rest; do
233 if [[ ${path} == /dev && ${fstype} != devtmpfs ]]; then
234 ewarn "You need to edit your /dev line in ${fstab} to have devtmpfs"
235 ewarn "filesystem. Otherwise udev won't be able to boot."
236 ewarn "See, https://bugs.gentoo.org/453186"
240 if [[ -d ${ROOT%/}/usr/lib/udev ]]; then
242 ewarn "Please re-emerge all packages on your system which install"
243 ewarn "rules and helpers in /usr/lib/udev. They should now be in"
246 ewarn "One way to do this is to run the following command:"
247 ewarn "emerge -av1 \$(qfile -q -S -C /usr/lib/udev)"
248 ewarn "Note that qfile can be found in app-portage/portage-utils"
251 local old_cd_rules="${ROOT%/}"/etc/udev/rules.d/70-persistent-cd.rules
252 local old_net_rules="${ROOT%/}"/etc/udev/rules.d/70-persistent-net.rules
253 for old_rules in "${old_cd_rules}" "${old_net_rules}"; do
254 if [[ -f ${old_rules} ]]; then
256 ewarn "File ${old_rules} is from old udev installation but if you still use it,"
257 ewarn "rename it to something else starting with 70- to silence this deprecation"
263 elog "Starting from version >= 197 the new predictable network interface names are"
264 elog "used by default, see:"
265 elog "https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames"
266 elog "https://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c"
268 elog "Example command to get the information for the new interface name before booting"
269 elog "(replace <ifname> with, for example, eth0):"
270 elog "# udevadm test-builtin net_id /sys/class/net/<ifname> 2> /dev/null"
272 elog "You can use either kernel parameter \"net.ifnames=0\", create empty"
273 elog "file /etc/systemd/network/99-default.link, or symlink it to /dev/null"
274 elog "to disable the feature."
276 if has_version 'sys-apps/biosdevname'; then
278 ewarn "You can replace the functionality of sys-apps/biosdevname which has been"
279 ewarn "detected to be installed with the new predictable network interface names."
283 ewarn "You need to restart udev as soon as possible to make the upgrade go"
285 ewarn "The method you use to do this depends on your init system."
286 if has_version 'sys-apps/openrc'; then
287 ewarn "For sys-apps/openrc users it is:"
288 ewarn "# /etc/init.d/udev --nodeps restart"
292 elog "For more information on udev on Gentoo, upgrading, writing udev rules, and"
293 elog "fixing known issues visit:"
294 elog "https://wiki.gentoo.org/wiki/Udev"
295 elog "https://wiki.gentoo.org/wiki/Udev/upgrade"
297 # If user has disabled 80-net-name-slot.rules using a empty file or a symlink to /dev/null,
298 # do the same for 80-net-setup-link.rules to keep the old behavior
300 local net_name_slot_sym=no
301 local net_rules_path="${ROOT%/}"/etc/udev/rules.d
302 local net_name_slot="${net_rules_path}"/80-net-name-slot.rules
303 local net_setup_link="${net_rules_path}"/80-net-setup-link.rules
304 if [[ ! -e ${net_setup_link} ]]; then
305 [[ -f ${net_name_slot} && $(sed -e "/^#/d" -e "/^\W*$/d" ${net_name_slot} | wc -l) == 0 ]] && net_move=yes
306 if [[ -L ${net_name_slot} && $(readlink ${net_name_slot}) == /dev/null ]]; then
308 net_name_slot_sym=yes
311 if [[ ${net_move} == yes ]]; then
312 ebegin "Copying ${net_name_slot} to ${net_setup_link}"
314 if [[ ${net_name_slot_sym} == yes ]]; then
315 ln -nfs /dev/null "${net_setup_link}"
317 cp "${net_name_slot}" "${net_setup_link}"
322 # Update hwdb database in case the format is changed by udev version.
323 if has_version 'sys-apps/hwids[udev]'; then
324 udevadm hwdb --update --root="${ROOT%/}"
325 # Only reload when we are not upgrading to avoid potential race w/ incompatible hwdb.bin and the running udevd
326 # https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
327 [[ -z ${REPLACING_VERSIONS} ]] && udev_reload