/[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.11 - (show annotations) (download)
Fri Apr 16 20:14:18 2010 UTC (8 years, 6 months ago) by ranger
Branch: MAIN
Changes since 1.10: +2 -2 lines
Marking udev-149 ppc for bug 303031
(Portage version: 2.1.7.17/cvs/Linux ppc64)

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

  ViewVC Help
Powered by ViewVC 1.1.20