/[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.5 - (show annotations) (download)
Sun Feb 21 22:35:28 2010 UTC (8 years, 3 months ago) by fauli
Branch: MAIN
Changes since 1.4: +2 -2 lines
stable x86, bug 303031
(Portage version: 2.1.7.17/cvs/Linux i686)

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

  ViewVC Help
Powered by ViewVC 1.1.20