1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
10 inherit autotools eutils linux-info multilib multilib-minimal user
12 if [[ ${PV} = 9999* ]]; then
13 EGIT_REPO_URI="git://github.com/gentoo/eudev.git"
16 SRC_URI="https://dev.gentoo.org/~blueness/${PN}/${P}.tar.gz"
17 KEYWORDS="~amd64 ~arm ~hppa ~mips ~ppc ~ppc64 sparc ~x86"
20 DESCRIPTION="Linux dynamic and persistent device naming support (aka userspace devfs)"
21 HOMEPAGE="https://github.com/gentoo/eudev"
23 LICENSE="LGPL-2.1 MIT GPL-2"
25 IUSE="doc gudev +hwdb +kmod introspection +keymap +modutils +rule-generator selinux static-libs test"
27 COMMON_DEPEND=">=sys-apps/util-linux-2.20
28 gudev? ( >=dev-libs/glib-2.34.3:2[${MULTILIB_USEDEP}] )
29 introspection? ( >=dev-libs/gobject-introspection-1.38 )
30 kmod? ( >=sys-apps/kmod-16 )
31 selinux? ( >=sys-libs/libselinux-2.1.9 )
33 !sys-apps/gentoo-systemd-integration
36 !<=app-emulation/emul-linux-x86-baselibs-20130224-r7
37 !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
39 DEPEND="${COMMON_DEPEND}
40 keymap? ( dev-util/gperf )
43 >=sys-devel/make-3.82-r4
44 >=sys-kernel/linux-headers-${KV_min}
45 doc? ( >=dev-util/gtk-doc-1.18 )
46 app-text/docbook-xml-dtd:4.2
47 app-text/docbook-xml-dtd:4.5
48 app-text/docbook-xsl-stylesheets
50 >=dev-util/intltool-0.50
51 test? ( app-text/tree dev-lang/perl )"
53 RDEPEND="${COMMON_DEPEND}
54 !<sys-fs/lvm2-2.02.103
55 !<sec-policy/selinux-base-2.20120725-r10
58 gudev? ( !dev-libs/libgudev )"
60 PDEPEND=">=sys-fs/udev-init-scripts-26
61 hwdb? ( >=sys-apps/hwids-20140304[udev] )
62 keymap? ( >=sys-apps/hwids-20140304[udev] )"
64 REQUIRED_USE="keymap? ( hwdb )"
66 # The multilib-build.eclass doesn't handle situation where the installed headers
67 # are different in ABIs. In this case, we install libgudev headers in native
68 # ABI but not for non-native ABI.
69 multilib_check_headers() { :; }
72 if ! use rule-generator; then
74 ewarn "As of 2013-01-29, ${P} provides the new interface renaming functionality,"
75 ewarn "as described in the URL below:"
76 ewarn "http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames"
78 ewarn "This functionality is enabled BY DEFAULT because eudev has no means of synchronizing"
79 ewarn "between the default or user-modified choice of sys-fs/udev. If you wish to disable"
80 ewarn "this new iface naming, please be sure that /etc/udev/rules.d/80-net-name-slot.rules"
82 ewarn "\ttouch /etc/udev/rules.d/80-net-name-slot.rules"
84 ewarn "We are working on a better solution for the next beta release."
90 CONFIG_CHECK="~BLK_DEV_BSG ~DEVTMPFS ~!IDE ~INOTIFY_USER ~!SYSFS_DEPRECATED ~!SYSFS_DEPRECATED_V2 ~SIGNALFD ~EPOLL ~FHANDLE ~NET"
94 # These are required kernel options, but we don't error out on them
95 # because you can build under one kernel and run under another.
96 if kernel_is lt ${KV_min//./ }; then
98 ewarn "Your current running kernel version ${KV_FULL} is too old to run ${P}."
99 ewarn "Make sure to run udev under kernel version ${KV_min} or above."
105 # change rules back to group uucp instead of dialout for now
106 sed -e 's/GROUP="dialout"/GROUP="uucp"/' -i rules/*.rules \
107 || die "failed to change group dialout to uucp"
112 gtkdocize --docdir docs || die "gtkdocize failed"
114 echo 'EXTRA_DIST =' > docs/gtk-doc.make
119 multilib_src_configure() {
121 export cc_cv_CFLAGS__flto=no #502950
123 # Keep sorted by ./configure --help and only pass --disable flags
124 # when *required* to avoid external deps or unnecessary compile
127 ac_cv_search_cap_init=
128 ac_cv_header_sys_capability_h=yes
132 --docdir=/usr/share/doc/${PF}
133 --libdir=/usr/$(get_libdir)
134 --with-rootlibexecdir=/lib/udev
135 --with-html-dir="/usr/share/doc/${PF}/html"
142 # Only build libudev for non-native_abi, and only install it to libdir,
143 # that means all options only apply to native_abi
144 if multilib_is_native_abi; then
146 --with-rootlibdir=/$(get_libdir)
147 $(use_enable doc gtk-doc)
148 $(use_enable introspection)
150 $(use_enable kmod libkmod)
151 $(usex kmod --enable-modules $(use_enable modutils modules))
152 $(use_enable static-libs static)
153 $(use_enable selinux)
154 $(use_enable rule-generator)
160 --disable-introspection
165 --disable-rule-generator
168 ECONF_SOURCE="${S}" econf "${econf_args[@]}"
171 multilib_src_compile() {
172 if multilib_is_native_abi; then
177 use gudev && emake -C src/gudev
181 multilib_src_install() {
182 if multilib_is_native_abi; then
183 emake DESTDIR="${D}" install
185 emake -C src/libudev DESTDIR="${D}" install
186 use gudev && emake -C src/gudev DESTDIR="${D}" install
190 multilib_src_test() {
191 # make sandbox get out of the way
192 # these are safe because there is a fake root filesystem put in place,
193 # but sandbox seems to evaluate the paths of the test i/o instead of the
194 # paths of the actual i/o that results.
195 # also only test for native abi
196 if multilib_is_native_abi; then
204 multilib_src_install_all() {
205 prune_libtool_files --all
206 rm -rf "${ED}"/usr/share/doc/${PF}/LICENSE.*
208 use rule-generator && doinitd "${FILESDIR}"/udev-postmount
210 # drop distributed hwdb files, they override sys-apps/hwids
211 rm -f "${ED}"/etc/udev/hwdb.d/*.hwdb
213 insinto /lib/udev/rules.d
214 doins "${FILESDIR}"/40-gentoo.rules
216 insinto /usr/share/doc/${PF}/html/gudev
217 doins "${S}"/docs/gudev/html/*
219 insinto /usr/share/doc/${PF}/html/libudev
220 doins "${S}"/docs/libudev/html/*
225 for htmldir in gudev libudev; do
226 if [[ -d ${EROOT}usr/share/gtk-doc/html/${htmldir} ]]; then
227 rm -rf "${EROOT}"usr/share/gtk-doc/html/${htmldir}
229 if [[ -d ${ED}/usr/share/doc/${PF}/html/${htmldir} ]]; then
230 dosym ../../doc/${PF}/html/${htmldir} \
231 /usr/share/gtk-doc/html/${htmldir}
237 mkdir -p "${EROOT}"run
239 # "losetup -f" is confused if there is an empty /dev/loop/, Bug #338766
240 # So try to remove it here (will only work if empty).
241 rmdir "${EROOT}"dev/loop 2>/dev/null
242 if [[ -d ${EROOT}dev/loop ]]; then
243 ewarn "Please make sure your remove /dev/loop,"
244 ewarn "else losetup may be confused when looking for unused devices."
247 if use hwdb && has_version 'sys-apps/hwids[udev]'; then
248 udevadm hwdb --update --root="${ROOT%/}"
250 # http://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
251 # reload database after it has be rebuilt, but only if we are not upgrading
252 # also pass if we are -9999 since who knows what hwdb related changes there might be
253 if [[ ${REPLACING_VERSIONS%-r*} == ${PV} || -z ${REPLACING_VERSIONS} ]] && \
254 [[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
255 udevadm control --reload
260 ewarn "You need to restart eudev as soon as possible to make the"
261 ewarn "upgrade go into effect:"
262 ewarn "\t/etc/init.d/udev --nodeps restart"
264 if use rule-generator && \
265 [[ -x $(type -P rc-update) ]] && rc-update show | grep udev-postmount | grep -qsv 'boot\|default\|sysinit'; then
267 ewarn "Please add the udev-postmount init script to your default runlevel"
268 ewarn "to ensure the legacy rule-generator functionality works as reliably"
270 ewarn "\trc-update add udev-postmount default"
274 elog "For more information on eudev on Gentoo, writing udev rules, and"
275 elog "fixing known issues visit:"
276 elog " https://www.gentoo.org/doc/en/udev-guide.xml"
279 # http://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
280 # http://bugs.gentoo.org/246847
281 # http://bugs.gentoo.org/514174
284 # Update hwdb database in case the format is changed by udev version.
285 if has_version 'sys-apps/hwids[udev]'; then
286 udevadm hwdb --update --root="${ROOT%/}"
287 # Only reload when we are not upgrading to avoid potential race w/ incompatible hwdb.bin and the running udevd
288 if [[ -z ${REPLACING_VERSIONS} ]]; then
289 # http://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
290 if [[ ${ROOT} != "" ]] && [[ ${ROOT} != "/" ]]; then
293 udevadm control --reload