1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
8 inherit autotools linux-info multilib multilib-minimal
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 s390 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 --libdir="${EPREFIX}"/usr/$(get_libdir)
110 --with-rootlibexecdir="${EPREFIX}"/lib/udev
114 --exec-prefix="${EPREFIX}"
117 # Only build libudev for non-native_abi, and only install it to libdir,
118 # that means all options only apply to native_abi
119 if multilib_is_native_abi; then
121 --with-rootlibdir="${EPREFIX}"/$(get_libdir)
122 $(use_enable introspection)
124 $(use_enable static-libs static)
125 $(use_enable selinux)
126 $(use_enable rule-generator)
131 --disable-introspection
134 --disable-rule-generator
137 ECONF_SOURCE="${S}" econf "${econf_args[@]}"
140 multilib_src_compile() {
141 if multilib_is_native_abi; then
149 multilib_src_install() {
150 if multilib_is_native_abi; then
151 emake DESTDIR="${D}" install
153 emake -C src/libudev DESTDIR="${D}" install
157 multilib_src_test() {
158 # make sandbox get out of the way
159 # these are safe because there is a fake root filesystem put in place,
160 # but sandbox seems to evaluate the paths of the test i/o instead of the
161 # paths of the actual i/o that results.
162 # also only test for native abi
163 if multilib_is_native_abi; then
171 multilib_src_install_all() {
172 find "${D}" -name '*.la' -delete || die
174 insinto /lib/udev/rules.d
175 doins "${FILESDIR}"/40-gentoo.rules
177 use rule-generator && doinitd "${FILESDIR}"/udev-postmount
181 mkdir -p "${EROOT}"run
183 # "losetup -f" is confused if there is an empty /dev/loop/, Bug #338766
184 # So try to remove it here (will only work if empty).
185 rmdir "${EROOT}"dev/loop 2>/dev/null
186 if [[ -d ${EROOT}dev/loop ]]; then
187 ewarn "Please make sure your remove /dev/loop,"
188 ewarn "else losetup may be confused when looking for unused devices."
191 # process it as a list. We only care about the zero case (new install) or the case where
192 # the same version is being re-emerged. If there is a second version, allow it to abort.
193 local rv rvres=doitnew
194 for rv in ${REPLACING_VERSIONS} ; do
195 if [[ ${rvres} == doit* ]]; then
196 if [[ ${rv%-r*} == ${PV} ]]; then
204 if use hwdb && has_version 'sys-apps/hwids[udev]'; then
205 udevadm hwdb --update --root="${ROOT%/}"
207 # https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
208 # reload database after it has be rebuilt, but only if we are not upgrading
209 # also pass if we are -9999 since who knows what hwdb related changes there might be
210 if [[ ${rvres} == doit* ]] && [[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
211 udevadm control --reload
214 if [[ ${rvres} != doitnew ]]; then
216 ewarn "You need to restart eudev as soon as possible to make the"
217 ewarn "upgrade go into effect:"
218 ewarn "\t/etc/init.d/udev --nodeps restart"
221 if use rule-generator && \
222 [[ -x $(type -P rc-update) ]] && rc-update show | grep udev-postmount | grep -qsv 'boot\|default\|sysinit'; then
224 ewarn "Please add the udev-postmount init script to your default runlevel"
225 ewarn "to ensure the legacy rule-generator functionality works as reliably"
227 ewarn "\trc-update add udev-postmount default"
231 elog "For more information on eudev on Gentoo, writing udev rules, and"
232 elog "fixing known issues visit: https://wiki.gentoo.org/wiki/Eudev"