/[gentoo-x86]/sys-fs/udev/udev-149.ebuild
Gentoo

Contents of /sys-fs/udev/udev-149.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.15 - (show annotations) (download)
Mon Aug 23 20:22:14 2010 UTC (8 years, 1 month ago) by vapier
Branch: MAIN
Changes since 1.14: +3 -2 lines
Convert kernel headers into a blocker #296546 by Alan Hourihane.
(Portage version: 2.2_rc67/cvs/Linux x86_64)

1 # Copyright 1999-2010 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/sys-fs/udev/udev-149.ebuild,v 1.14 2010/08/08 16:19:04 armin76 Exp $
4
5 EAPI="1"
6
7 inherit eutils flag-o-matic multilib toolchain-funcs linux-info
8
9 PATCHSET=${P}-gentoo-patchset-v1
10
11 if [[ ${PV} == "9999" ]]; then
12 EGIT_REPO_URI="git://git.kernel.org/pub/scm/linux/hotplug/udev.git"
13 EGIT_BRANCH="master"
14 inherit git autotools
15 else
16 # please update testsys-tarball whenever udev-xxx/test/sys/ is changed
17 SRC_URI="mirror://kernel/linux/utils/kernel/hotplug/${P}.tar.bz2
18 test? ( mirror://gentoo/${PN}-149-testsys.tar.bz2 )
19 mirror://gentoo/${PATCHSET}.tar.bz2"
20 fi
21 DESCRIPTION="Linux dynamic and persistent device naming support (aka userspace devfs)"
22 HOMEPAGE="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html"
23
24 LICENSE="GPL-2"
25 SLOT="0"
26 KEYWORDS="~alpha amd64 arm ~hppa ~ia64 ~m68k ~mips ppc ppc64 ~s390 sh ~sparc x86"
27 IUSE="selinux +devfs-compat -extras test"
28
29 COMMON_DEPEND="selinux? ( sys-libs/libselinux )
30 extras? (
31 sys-apps/acl
32 >=sys-apps/usbutils-0.82
33 virtual/libusb:0
34 sys-apps/pciutils
35 dev-libs/glib:2
36 dev-util/pkgconfig
37 )
38 >=sys-apps/util-linux-2.16
39 >=sys-libs/glibc-2.9"
40
41 DEPEND="${COMMON_DEPEND}
42 extras? ( dev-util/gperf )
43 virtual/os-headers
44 !<sys-kernel/linux-headers-2.6.29
45 test? ( app-text/tree )"
46
47 RDEPEND="${COMMON_DEPEND}
48 !sys-apps/coldplug
49 !<sys-fs/lvm2-2.02.45
50 !sys-fs/device-mapper
51 >=sys-apps/baselayout-1.12.5"
52
53 if [[ ${PV} == "9999" ]]; then
54 # for documentation processing with xsltproc
55 DEPEND="${DEPEND}
56 app-text/docbook-xsl-stylesheets
57 app-text/docbook-xml-dtd
58 dev-util/gtk-doc"
59 fi
60
61 # required kernel options
62 CONFIG_CHECK="~INOTIFY_USER ~SIGNALFD ~!SYSFS_DEPRECATED ~!SYSFS_DEPRECATED_V2"
63
64 # We need the lib/rcscripts/addon support
65 PROVIDE="virtual/dev-manager"
66
67 udev_check_KV() {
68 local ok=0
69 if [[ ${KV_MAJOR} == 2 && ${KV_MINOR} == 6 ]]
70 then
71 if kernel_is -ge 2 6 ${KV_PATCH_reliable} ; then
72 ok=2
73 elif kernel_is -ge 2 6 ${KV_PATCH_min} ; then
74 ok=1
75 fi
76 fi
77 return $ok
78 }
79
80 pkg_setup() {
81 linux-info_pkg_setup
82
83 udev_libexec_dir="/$(get_libdir)/udev"
84
85 # udev requires signalfd introduced in kernel 2.6.25,
86 # but a glibc compiled against >=linux-headers-2.6.27 uses the
87 # new signalfd syscall introduced in kernel 2.6.27 without falling back
88 # to the old one. So we just depend on 2.6.27 here, see Bug #281312.
89 KV_PATCH_min=25
90 KV_PATCH_reliable=27
91 KV_min=2.6.${KV_PATCH_min}
92 KV_reliable=2.6.${KV_PATCH_reliable}
93
94 # always print kernel version requirements
95 ewarn
96 ewarn "${P} does not support Linux kernel before version ${KV_min}!"
97 if [[ ${KV_PATCH_min} != ${KV_PATCH_reliable} ]]; then
98 ewarn "For a reliable udev, use at least kernel ${KV_reliable}"
99 fi
100
101 echo
102 # We don't care about the secondary revision of the kernel.
103 # 2.6.30.4 -> 2.6.30 is all we check
104 udev_check_KV
105 case "$?" in
106 2) einfo "Your kernel version (${KV_FULL}) is new enough to run ${P} reliably." ;;
107 1) ewarn "Your kernel version (${KV_FULL}) is new enough to run ${P},"
108 ewarn "but it may be unreliable in some cases."
109 ebeep ;;
110 0) eerror "Your kernel version (${KV_FULL}) is too old to run ${P}"
111 ebeep ;;
112 esac
113 echo
114
115 KV_FULL_SRC=${KV_FULL}
116 get_running_version
117 udev_check_KV
118 if [[ "$?" = "0" ]]; then
119 eerror
120 eerror "udev cannot be restarted after emerging,"
121 eerror "as your running kernel version (${KV_FULL}) is too old."
122 eerror "You really need to use a newer kernel after a reboot!"
123 NO_RESTART=1
124 ebeep
125 fi
126 }
127
128 sed_libexec_dir() {
129 sed -e "s#/lib/udev#${udev_libexec_dir}#" -i "$@"
130 }
131
132 src_unpack() {
133 if [[ ${PV} == "9999" ]] ; then
134 git_src_unpack
135 else
136 unpack ${A}
137
138 if use test; then
139 mv "${WORKDIR}"/test/sys "${S}"/test/
140 fi
141 fi
142
143 cd "${S}"
144
145 # patches go here...
146
147 # backport some patches
148 EPATCH_SOURCE="${WORKDIR}/${PATCHSET}" EPATCH_SUFFIX="patch" \
149 EPATCH_FORCE="yes" epatch
150
151 if ! use devfs-compat; then
152 # see Bug #269359
153 epatch "${FILESDIR}"/udev-141-remove-devfs-names.diff
154 fi
155
156 # change rules back to group uucp instead of dialout for now
157 sed -e 's/GROUP="dialout"/GROUP="uucp"/' \
158 -i rules/{rules.d,packages,gentoo}/*.rules \
159 || die "failed to change group dialout to uucp"
160
161 if [[ ${PV} != 9999 ]]; then
162 # Make sure there is no sudden changes to upstream rules file
163 # (more for my own needs than anything else ...)
164 MD5=$(md5sum < "${S}/rules/rules.d/50-udev-default.rules")
165 MD5=${MD5/ -/}
166 if [[ ${MD5} != f38d3e1344588b6e44746097e1dfd149 ]]
167 then
168 echo
169 eerror "50-udev-default.rules has been updated, please validate!"
170 eerror "md5sum=${MD5}"
171 die "50-udev-default.rules has been updated, please validate!"
172 fi
173 fi
174
175 sed_libexec_dir \
176 rules/rules.d/50-udev-default.rules \
177 rules/rules.d/78-sound-card.rules \
178 extras/rule_generator/write_*_rules \
179 || die "sed failed"
180
181 if [[ ${PV} == 9999 ]]; then
182 gtkdocize --copy
183 eautoreconf
184 fi
185 }
186
187 src_compile() {
188 filter-flags -fprefetch-loop-arrays
189
190 econf \
191 --prefix=/usr \
192 --sysconfdir=/etc \
193 --sbindir=/sbin \
194 --libdir=/usr/$(get_libdir) \
195 --with-rootlibdir=/$(get_libdir) \
196 --libexecdir="${udev_libexec_dir}" \
197 --enable-logging \
198 $(use_with selinux) \
199 $(use_enable extras) \
200 --disable-introspection
201 # we don't have gobject-introspection in portage tree
202
203 emake || die "compiling udev failed"
204 }
205
206 src_install() {
207 local scriptdir="${FILESDIR}/147"
208
209 into /
210 emake DESTDIR="${D}" install || die "make install failed"
211 # without this code, multilib-strict is angry
212 if [[ "$(get_libdir)" != "lib" ]]; then
213 # check if this code is needed, bug #281338
214 if [[ -d "${D}/lib" ]]; then
215 # we can not just rename /lib to /lib64, because
216 # make install creates /lib64 and /lib
217 einfo "Moving lib to $(get_libdir)"
218 mkdir -p "${D}/$(get_libdir)"
219 mv "${D}"/lib/* "${D}/$(get_libdir)/"
220 rmdir "${D}"/lib
221 else
222 einfo "There is no ${D}/lib, move code can be deleted."
223 fi
224 fi
225
226 exeinto "${udev_libexec_dir}"
227 newexe "${FILESDIR}"/net-130-r1.sh net.sh || die "net.sh not installed properly"
228 newexe "${FILESDIR}"/move_tmp_persistent_rules-112-r1.sh move_tmp_persistent_rules.sh \
229 || die "move_tmp_persistent_rules.sh not installed properly"
230 newexe "${FILESDIR}"/write_root_link_rule-125 write_root_link_rule \
231 || die "write_root_link_rule not installed properly"
232
233 doexe "${scriptdir}"/shell-compat-KV.sh \
234 || die "shell-compat.sh not installed properly"
235 doexe "${scriptdir}"/shell-compat-addon.sh \
236 || die "shell-compat.sh not installed properly"
237
238 keepdir "${udev_libexec_dir}"/state
239 keepdir "${udev_libexec_dir}"/devices
240
241 # create symlinks for these utilities to /sbin
242 # where multipath-tools expect them to be (Bug #168588)
243 dosym "..${udev_libexec_dir}/scsi_id" /sbin/scsi_id
244
245 # Add gentoo stuff to udev.conf
246 echo "# If you need to change mount-options, do it in /etc/fstab" \
247 >> "${D}"/etc/udev/udev.conf
248
249 # let the dir exist at least
250 keepdir /etc/udev/rules.d
251
252 # Now installing rules
253 cd "${S}"/rules
254 insinto "${udev_libexec_dir}"/rules.d/
255
256 # Our rules files
257 doins gentoo/??-*.rules
258 doins packages/40-isdn.rules
259
260 # Adding arch specific rules
261 if [[ -f packages/40-${ARCH}.rules ]]
262 then
263 doins "packages/40-${ARCH}.rules"
264 fi
265 cd "${S}"
266
267 # our udev hooks into the rc system
268 insinto /$(get_libdir)/rcscripts/addons
269 doins "${scriptdir}"/udev-start.sh \
270 || die "udev-start.sh not installed properly"
271 doins "${scriptdir}"/udev-stop.sh \
272 || die "udev-stop.sh not installed properly"
273
274 local init
275 # udev-postmount and init-scripts for >=openrc-0.3.1, Bug #240984
276 for init in udev udev-mount udev-dev-tarball udev-postmount; do
277 newinitd "${scriptdir}/${init}.initd" "${init}" \
278 || die "initscript ${init} not installed properly"
279 done
280
281 # insert minimum kernel versions
282 sed -e "s/%KV_MIN%/${KV_min}/" \
283 -e "s/%KV_MIN_RELIABLE%/${KV_reliable}/" \
284 -i "${D}"/etc/init.d/udev-mount
285
286 # config file for init-script and start-addon
287 newconfd "${scriptdir}/udev.confd" udev \
288 || die "config file not installed properly"
289
290 insinto /etc/modprobe.d
291 newins "${FILESDIR}"/blacklist-146 blacklist.conf
292 newins "${FILESDIR}"/pnp-aliases pnp-aliases.conf
293
294 # convert /lib/udev to real used dir
295 sed_libexec_dir \
296 "${D}/$(get_libdir)"/rcscripts/addons/*.sh \
297 "${D}/${udev_libexec_dir}"/write_root_link_rule \
298 "${D}"/etc/conf.d/udev \
299 "${D}"/etc/init.d/udev* \
300 "${D}"/etc/modprobe.d/*
301
302 # documentation
303 dodoc ChangeLog README TODO || die "failed installing docs"
304
305 # keep doc in just one directory, Bug #281137
306 rm -rf "${D}/usr/share/doc/${PN}"
307 if use extras; then
308 dodoc extras/keymap/README.keymap.txt || die "failed installing docs"
309 fi
310
311 cd docs/writing_udev_rules
312 mv index.html writing_udev_rules.html
313 dohtml *.html
314 }
315
316 pkg_preinst() {
317 # moving old files to support newer modprobe, 12 May 2009
318 local f dir=${ROOT}/etc/modprobe.d/
319 for f in pnp-aliases blacklist; do
320 if [[ -f $dir/$f && ! -f $dir/$f.conf ]]
321 then
322 elog "Moving $dir/$f to $f.conf"
323 mv -f "$dir/$f" "$dir/$f.conf"
324 fi
325 done
326
327 if [[ -d ${ROOT}/lib/udev-state ]]
328 then
329 mv -f "${ROOT}"/lib/udev-state/* "${D}"/lib/udev/state/
330 rm -r "${ROOT}"/lib/udev-state
331 fi
332
333 if [[ -f ${ROOT}/etc/udev/udev.config &&
334 ! -f ${ROOT}/etc/udev/udev.rules ]]
335 then
336 mv -f "${ROOT}"/etc/udev/udev.config "${ROOT}"/etc/udev/udev.rules
337 fi
338
339 # delete the old udev.hotplug symlink if it is present
340 if [[ -h ${ROOT}/etc/hotplug.d/default/udev.hotplug ]]
341 then
342 rm -f "${ROOT}"/etc/hotplug.d/default/udev.hotplug
343 fi
344
345 # delete the old wait_for_sysfs.hotplug symlink if it is present
346 if [[ -h ${ROOT}/etc/hotplug.d/default/05-wait_for_sysfs.hotplug ]]
347 then
348 rm -f "${ROOT}"/etc/hotplug.d/default/05-wait_for_sysfs.hotplug
349 fi
350
351 # delete the old wait_for_sysfs.hotplug symlink if it is present
352 if [[ -h ${ROOT}/etc/hotplug.d/default/10-udev.hotplug ]]
353 then
354 rm -f "${ROOT}"/etc/hotplug.d/default/10-udev.hotplug
355 fi
356
357 has_version "=${CATEGORY}/${PN}-103-r3"
358 previous_equal_to_103_r3=$?
359
360 has_version "<${CATEGORY}/${PN}-104-r5"
361 previous_less_than_104_r5=$?
362
363 has_version "<${CATEGORY}/${PN}-106-r5"
364 previous_less_than_106_r5=$?
365
366 has_version "<${CATEGORY}/${PN}-113"
367 previous_less_than_113=$?
368 }
369
370 # 19 Nov 2008
371 fix_old_persistent_net_rules() {
372 local rules=${ROOT}/etc/udev/rules.d/70-persistent-net.rules
373 [[ -f ${rules} ]] || return
374
375 elog
376 elog "Updating persistent-net rules file"
377
378 # Change ATTRS to ATTR matches, Bug #246927
379 sed -i -e 's/ATTRS{/ATTR{/g' "${rules}"
380
381 # Add KERNEL matches if missing, Bug #246849
382 sed -ri \
383 -e '/KERNEL/ ! { s/NAME="(eth|wlan|ath)([0-9]+)"/KERNEL=="\1*", NAME="\1\2"/}' \
384 "${rules}"
385 }
386
387 # See Bug #129204 for a discussion about restarting udevd
388 restart_udevd() {
389 if [[ ${NO_RESTART} = "1" ]]; then
390 ewarn "Not restarting udevd, as your kernel is too old!"
391 return
392 fi
393
394 # need to merge to our system
395 [[ ${ROOT} = / ]] || return
396
397 # check if root of init-process is identical to ours (not in chroot)
398 [[ -r /proc/1/root && /proc/1/root/ -ef /proc/self/root/ ]] || return
399
400 # abort if there is no udevd running
401 [[ -n $(pidof udevd) ]] || return
402
403 # abort if no /dev/.udev exists
404 [[ -e /dev/.udev ]] || return
405
406 elog
407 elog "restarting udevd now."
408
409 killall -15 udevd &>/dev/null
410 sleep 1
411 killall -9 udevd &>/dev/null
412
413 /sbin/udevd --daemon
414 sleep 3
415 if [[ ! -n $(pidof udevd) ]]; then
416 eerror "FATAL: udev died, please check your kernel is"
417 eerror "new enough and configured correctly for ${P}."
418 eerror
419 eerror "Please have a look at this before rebooting."
420 eerror "If in doubt, please downgrade udev back to your old version"
421 ebeep
422 fi
423 }
424
425 postinst_init_scripts() {
426 # FIXME: we may need some code that detects if this is a system bootstrap
427 # and auto-enables udev then
428 #
429 # FIXME: inconsistent handling of init-scripts here
430 # * udev is added to sysinit in openrc-ebuild
431 # * we add udev-postmount to default in here
432 #
433
434 # migration to >=openrc-0.4
435 if [[ -e "${ROOT}"/etc/runlevels/sysinit && ! -e "${ROOT}"/etc/runlevels/sysinit/udev ]]
436 then
437 ewarn
438 ewarn "You need to add the udev init script to the runlevel sysinit,"
439 ewarn "else your system will not be able to boot"
440 ewarn "after updating to >=openrc-0.4.0"
441 ewarn "Run this to enable udev for >=openrc-0.4.0:"
442 ewarn "\trc-update add udev sysinit"
443 ewarn
444 fi
445
446 # add udev-postmount to default runlevel instead of that ugly injecting
447 # like a hotplug event, 2009/10/15
448
449 # already enabled?
450 [[ -e "${ROOT}"/etc/runlevels/default/udev-postmount ]] && return
451
452 local enable_postmount=0
453 [[ -e "${ROOT}"/etc/runlevels/sysinit/udev ]] && enable_postmount=1
454 [[ "${ROOT}" = "/" && -d /dev/.udev/ ]] && enable_postmount=1
455
456 if [[ ${enable_postmount} = 1 ]]
457 then
458 local initd=udev-postmount
459
460 if [[ -e ${ROOT}/etc/init.d/${initd} ]] && \
461 [[ ! -e ${ROOT}/etc/runlevels/default/${initd} ]]
462 then
463 ln -snf /etc/init.d/${initd} "${ROOT}"/etc/runlevels/default/${initd}
464 elog "Auto-adding '${initd}' service to your default runlevel"
465 fi
466 else
467 elog "You should add the udev-postmount service to default runlevel."
468 elog "Run this to add it:"
469 elog "\trc-update add udev-postmount default"
470 fi
471 }
472
473 pkg_postinst() {
474 fix_old_persistent_net_rules
475
476 restart_udevd
477
478 postinst_init_scripts
479
480 # people want reminders, I'll give them reminders. Odds are they will
481 # just ignore them anyway...
482
483 # delete 40-scsi-hotplug.rules, it is integrated in 50-udev.rules, 19 Jan 2007
484 if [[ $previous_equal_to_103_r3 = 0 ]] &&
485 [[ -e ${ROOT}/etc/udev/rules.d/40-scsi-hotplug.rules ]]
486 then
487 ewarn "Deleting stray 40-scsi-hotplug.rules"
488 ewarn "installed by sys-fs/udev-103-r3"
489 rm -f "${ROOT}"/etc/udev/rules.d/40-scsi-hotplug.rules
490 fi
491
492 # Removing some device-nodes we thought we need some time ago, 25 Jan 2007
493 if [[ -d ${ROOT}/lib/udev/devices ]]
494 then
495 rm -f "${ROOT}"/lib/udev/devices/{null,zero,console,urandom}
496 fi
497
498 # Removing some old file, 29 Jan 2007
499 if [[ $previous_less_than_104_r5 = 0 ]]
500 then
501 rm -f "${ROOT}"/etc/dev.d/net/hotplug.dev
502 rmdir --ignore-fail-on-non-empty "${ROOT}"/etc/dev.d/net 2>/dev/null
503 fi
504
505 # 19 Mar 2007
506 if [[ $previous_less_than_106_r5 = 0 ]] &&
507 [[ -e ${ROOT}/etc/udev/rules.d/95-net.rules ]]
508 then
509 rm -f "${ROOT}"/etc/udev/rules.d/95-net.rules
510 fi
511
512 # Try to remove /etc/dev.d as that is obsolete, 23 Apr 2007
513 if [[ -d ${ROOT}/etc/dev.d ]]
514 then
515 rmdir --ignore-fail-on-non-empty "${ROOT}"/etc/dev.d/default "${ROOT}"/etc/dev.d 2>/dev/null
516 if [[ -d ${ROOT}/etc/dev.d ]]
517 then
518 ewarn "You still have the directory /etc/dev.d on your system."
519 ewarn "This is no longer used by udev and can be removed."
520 fi
521 fi
522
523 # 64-device-mapper.rules now gets installed by sys-fs/device-mapper
524 # remove it if user don't has sys-fs/device-mapper installed, 27 Jun 2007
525 if [[ $previous_less_than_113 = 0 ]] &&
526 [[ -f ${ROOT}/etc/udev/rules.d/64-device-mapper.rules ]] &&
527 ! has_version sys-fs/device-mapper
528 then
529 rm -f "${ROOT}"/etc/udev/rules.d/64-device-mapper.rules
530 einfo "Removed unneeded file 64-device-mapper.rules"
531 fi
532
533 # requested in bug #275974, added 2009/09/05
534 ewarn
535 ewarn "If after the udev update removable devices or CD/DVD drives"
536 ewarn "stop working, try re-emerging HAL before filling a bug report"
537
538 # requested in Bug #225033:
539 elog
540 elog "persistent-net does assigning fixed names to network devices."
541 elog "If you have problems with the persistent-net rules,"
542 elog "just delete the rules file"
543 elog "\trm ${ROOT}etc/udev/rules.d/70-persistent-net.rules"
544 elog "and then reboot."
545 elog
546 elog "This may however number your devices in a different way than they are now."
547
548 ewarn
549 ewarn "If you build an initramfs including udev, then please"
550 ewarn "make sure that the /sbin/udevadm binary gets included,"
551 ewarn "and your scripts changed to use it,as it replaces the"
552 ewarn "old helper apps udevinfo, udevtrigger, ..."
553
554 ewarn
555 ewarn "mount options for directory /dev are no longer"
556 ewarn "set in /etc/udev/udev.conf, but in /etc/fstab"
557 ewarn "as for other directories."
558
559 if use devfs-compat; then
560 ewarn
561 ewarn "devfs-compat use flag is enabled (by default)."
562 ewarn "This enables devfs compatible device names."
563 ewarn "If you use /dev/md/*, /dev/loop/* or /dev/rd/*,"
564 ewarn "then please migrate over to using the device names"
565 ewarn "/dev/md*, /dev/loop* and /dev/ram*."
566 ewarn "The devfs-compat rules will be removed in the future."
567 ewarn "For reference see Bug #269359."
568 fi
569
570 elog
571 elog "For more information on udev on Gentoo, writing udev rules, and"
572 elog " fixing known issues visit:"
573 elog " http://www.gentoo.org/doc/en/udev-guide.xml"
574 }

  ViewVC Help
Powered by ViewVC 1.1.20