1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
8 inherit autotools linux-info multilib multilib-minimal toolchain-funcs
10 if [[ ${PV} = 9999* ]]; then
11 EGIT_REPO_URI="https://github.com/gentoo/eudev.git"
14 SRC_URI="https://dev.gentoo.org/~blueness/${PN}/${P}.tar.gz"
15 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86"
18 DESCRIPTION="Linux dynamic and persistent device naming support (aka userspace devfs)"
19 HOMEPAGE="https://github.com/gentoo/eudev"
21 LICENSE="LGPL-2.1 MIT GPL-2"
23 IUSE="+hwdb +kmod introspection rule-generator selinux static-libs test"
24 RESTRICT="!test? ( test )"
26 COMMON_DEPEND=">=sys-apps/util-linux-2.20
27 introspection? ( >=dev-libs/gobject-introspection-1.38 )
28 kmod? ( >=sys-apps/kmod-16 )
29 selinux? ( >=sys-libs/libselinux-2.1.9 )
31 !sys-apps/gentoo-systemd-integration
33 DEPEND="${COMMON_DEPEND}
37 >=sys-devel/make-3.82-r4
38 >=sys-kernel/linux-headers-${KV_min}
39 >=dev-util/intltool-0.50
40 test? ( app-text/tree dev-lang/perl )"
42 RDEPEND="${COMMON_DEPEND}
46 !<sys-fs/lvm2-2.02.103
47 !<sec-policy/selinux-base-2.20120725-r10
51 PDEPEND=">=sys-fs/udev-init-scripts-26
52 hwdb? ( >=sys-apps/hwids-20140304[udev] )"
54 MULTILIB_WRAPPED_HEADERS=(
60 ewarn "As of 2013-01-29, ${P} provides the new interface renaming functionality,"
61 ewarn "as described in the URL below:"
62 ewarn "https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames"
64 ewarn "This functionality is enabled BY DEFAULT because eudev has no means of synchronizing"
65 ewarn "between the default or user-modified choice of sys-fs/udev. If you wish to disable"
66 ewarn "this new iface naming, please be sure that /etc/udev/rules.d/80-net-name-slot.rules"
67 ewarn "exists: touch /etc/udev/rules.d/80-net-name-slot.rules"
72 CONFIG_CHECK="~BLK_DEV_BSG ~DEVTMPFS ~!IDE ~INOTIFY_USER ~!SYSFS_DEPRECATED ~!SYSFS_DEPRECATED_V2 ~SIGNALFD ~EPOLL ~FHANDLE ~NET ~UNIX"
76 # These are required kernel options, but we don't error out on them
77 # because you can build under one kernel and run under another.
78 if kernel_is lt ${KV_min//./ }; then
80 ewarn "Your current running kernel version ${KV_FULL} is too old to run ${P}."
81 ewarn "Make sure to run udev under kernel version ${KV_min} or above."
87 # change rules back to group uucp instead of dialout for now
88 sed -e 's/GROUP="dialout"/GROUP="uucp"/' -i rules/*.rules \
89 || die "failed to change group dialout to uucp"
95 multilib_src_configure() {
97 export cc_cv_CFLAGS__flto=no #502950
99 # Keep sorted by ./configure --help and only pass --disable flags
100 # when *required* to avoid external deps or unnecessary compile
103 ac_cv_search_cap_init=
104 ac_cv_header_sys_capability_h=yes
108 --with-rootrundir=/run
109 --exec-prefix="${EPREFIX}"
110 --bindir="${EPREFIX}"/bin
111 --includedir="${EPREFIX}"/usr/include
112 --libdir="${EPREFIX}"/usr/$(get_libdir)
113 --with-rootlibexecdir="${EPREFIX}"/lib/udev
119 # Only build libudev for non-native_abi, and only install it to libdir,
120 # that means all options only apply to native_abi
121 if multilib_is_native_abi; then
123 --with-rootlibdir="${EPREFIX}"/$(get_libdir)
124 $(use_enable introspection)
126 $(use_enable static-libs static)
127 $(use_enable selinux)
128 $(use_enable rule-generator)
133 --disable-introspection
136 --disable-rule-generator
139 ECONF_SOURCE="${S}" econf "${econf_args[@]}"
142 multilib_src_compile() {
143 if multilib_is_native_abi; then
151 multilib_src_install() {
152 if multilib_is_native_abi; then
153 emake DESTDIR="${D}" install
155 emake -C src/libudev DESTDIR="${D}" install
159 multilib_src_test() {
160 # make sandbox get out of the way
161 # these are safe because there is a fake root filesystem put in place,
162 # but sandbox seems to evaluate the paths of the test i/o instead of the
163 # paths of the actual i/o that results.
164 # also only test for native abi
165 if multilib_is_native_abi; then
173 multilib_src_install_all() {
174 find "${D}" -name '*.la' -delete || die
176 insinto /lib/udev/rules.d
177 doins "${FILESDIR}"/40-gentoo.rules
179 use rule-generator && doinitd "${FILESDIR}"/udev-postmount
183 mkdir -p "${EROOT}"run
185 # "losetup -f" is confused if there is an empty /dev/loop/, Bug #338766
186 # So try to remove it here (will only work if empty).
187 rmdir "${EROOT}"dev/loop 2>/dev/null
188 if [[ -d ${EROOT}dev/loop ]]; then
189 ewarn "Please make sure your remove /dev/loop,"
190 ewarn "else losetup may be confused when looking for unused devices."
193 # REPLACING_VERSIONS should only ever have zero or 1 values but in case it doesn't,
194 # process it as a list. We only care about the zero case (new install) or the case where
195 # the same version is being re-emerged. If there is a second version, allow it to abort.
196 local rv rvres=doitnew
197 for rv in ${REPLACING_VERSIONS} ; do
198 if [[ ${rvres} == doit* ]]; then
199 if [[ ${rv%-r*} == ${PV} ]]; then
207 if use hwdb && has_version 'sys-apps/hwids[udev]'; then
208 udevadm hwdb --update --root="${ROOT%/}"
210 # https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
211 # reload database after it has be rebuilt, but only if we are not upgrading
212 # also pass if we are -9999 since who knows what hwdb related changes there might be
213 if [[ ${rvres} == doit* ]] && [[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
214 udevadm control --reload
217 if [[ ${rvres} != doitnew ]]; then
219 ewarn "You need to restart eudev as soon as possible to make the"
220 ewarn "upgrade go into effect:"
221 ewarn "\t/etc/init.d/udev --nodeps restart"
224 if use rule-generator && \
225 [[ -x $(type -P rc-update) ]] && rc-update show | grep udev-postmount | grep -qsv 'boot\|default\|sysinit'; then
227 ewarn "Please add the udev-postmount init script to your default runlevel"
228 ewarn "to ensure the legacy rule-generator functionality works as reliably"
230 ewarn "\trc-update add udev-postmount default"
234 elog "For more information on eudev on Gentoo, writing udev rules, and"
235 elog "fixing known issues visit: https://wiki.gentoo.org/wiki/Eudev"