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

Contents of /sys-fs/udev/udev-151-r4.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.24 - (show annotations) (download)
Tue Jul 31 04:43:38 2012 UTC (20 months, 2 weeks ago) by ssuominen
Branch: MAIN
Changes since 1.23: +13 -12 lines
Tarball rest of the legacy files to mirrors.

(Portage version: 2.2.0_alpha116/cvs/Linux x86_64)

1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/sys-fs/udev/udev-151-r4.ebuild,v 1.23 2012/05/16 03:21:30 ssuominen 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-2 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}-151-testsys.tar.bz2 )
19 http://dev.gentoo.org/~ssuominen/${PN}-gentoo-legacy-patchset-1.tar.bz2"
20 [[ -n "${PATCHSET}" ]] && SRC_URI="${SRC_URI} mirror://gentoo/${PATCHSET}.tar.bz2"
21 fi
22 DESCRIPTION="Linux dynamic and persistent device naming support (aka userspace devfs)"
23 HOMEPAGE="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html"
24
25 LICENSE="GPL-2"
26 SLOT="0"
27 KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86"
28 IUSE="selinux devfs-compat old-hd-rules -extras test"
29
30 COMMON_DEPEND="selinux? ( sys-libs/libselinux )
31 extras? (
32 sys-apps/acl
33 >=sys-apps/usbutils-0.82
34 virtual/libusb:0
35 sys-apps/pciutils
36 dev-libs/glib:2
37 )
38 >=sys-apps/util-linux-2.16
39 !<sys-libs/glibc-2.9"
40
41 DEPEND="${COMMON_DEPEND}
42 extras? (
43 dev-util/gperf
44 virtual/pkgconfig
45 )
46 virtual/os-headers
47 !<sys-kernel/linux-headers-2.6.29
48 test? ( app-text/tree )"
49
50 RDEPEND="${COMMON_DEPEND}
51 !sys-apps/coldplug
52 !<sys-fs/lvm2-2.02.45
53 !sys-fs/device-mapper
54 >=sys-apps/baselayout-1.12.5"
55
56 if [[ ${PV} == "9999" ]]; then
57 # for documentation processing with xsltproc
58 DEPEND="${DEPEND}
59 app-text/docbook-xsl-stylesheets
60 app-text/docbook-xml-dtd
61 dev-util/gtk-doc"
62 fi
63
64 # required kernel options
65 CONFIG_CHECK="~INOTIFY_USER ~SIGNALFD ~!SYSFS_DEPRECATED ~!SYSFS_DEPRECATED_V2
66 ~!IDE ~BLK_DEV_BSG"
67
68 # Return values:
69 # 2 - reliable
70 # 1 - unreliable
71 # 0 - too old
72 udev_check_KV() {
73 local ok=0
74 if [[ ${KV_MAJOR} == 2 && ${KV_MINOR} == 6 ]] || [[ ${KV_MAJOR} == 3 ]]
75 then
76 if kernel_is -ge 2 6 ${KV_PATCH_reliable} ; then
77 ok=2
78 elif kernel_is -ge 2 6 ${KV_PATCH_min} ; then
79 ok=1
80 fi
81 fi
82 return $ok
83 }
84
85 pkg_setup() {
86 linux-info_pkg_setup
87
88 udev_libexec_dir="/$(get_libdir)/udev"
89
90 # udev requires signalfd introduced in kernel 2.6.25,
91 # but a glibc compiled against >=linux-headers-2.6.27 uses the
92 # new signalfd syscall introduced in kernel 2.6.27 without falling back
93 # to the old one. So we just depend on 2.6.27 here, see Bug #281312.
94 KV_PATCH_min=25
95 KV_PATCH_reliable=27
96 KV_min=2.6.${KV_PATCH_min}
97 KV_reliable=2.6.${KV_PATCH_reliable}
98
99 # always print kernel version requirements
100 ewarn
101 ewarn "${P} does not support Linux kernel before version ${KV_min}!"
102 if [[ ${KV_PATCH_min} != ${KV_PATCH_reliable} ]]; then
103 ewarn "For a reliable udev, use at least kernel ${KV_reliable}"
104 fi
105
106 echo
107 # We don't care about the secondary revision of the kernel.
108 # 2.6.30.4 -> 2.6.30 is all we check
109 udev_check_KV
110 case "$?" in
111 2) einfo "Your kernel version (${KV_FULL}) is new enough to run ${P} reliably." ;;
112 1) ewarn "Your kernel version (${KV_FULL}) is new enough to run ${P},"
113 ewarn "but it may be unreliable in some cases."
114 ebeep ;;
115 0) eerror "Your kernel version (${KV_FULL}) is too old to run ${P}"
116 ebeep ;;
117 esac
118 echo
119
120 KV_FULL_SRC=${KV_FULL}
121 get_running_version
122 udev_check_KV
123 if [[ "$?" = "0" ]]; then
124 eerror
125 eerror "udev cannot be restarted after emerging,"
126 eerror "as your running kernel version (${KV_FULL}) is too old."
127 eerror "You really need to use a newer kernel after a reboot!"
128 NO_RESTART=1
129 ebeep
130 fi
131 }
132
133 sed_libexec_dir() {
134 sed -e "s#/lib/udev#${udev_libexec_dir}#" -i "$@"
135 }
136
137 src_unpack() {
138 if [[ ${PV} == "9999" ]] ; then
139 git-2_src_unpack
140 else
141 unpack ${A}
142
143 if use test; then
144 mv "${WORKDIR}"/test/sys "${S}"/test/
145 fi
146 fi
147
148 cd "${S}"
149
150 # patches go here...
151
152 # backport some patches
153 if [[ -n "${PATCHSET}" ]]; then
154 EPATCH_SOURCE="${WORKDIR}/${PATCHSET}" EPATCH_SUFFIX="patch" \
155 EPATCH_FORCE="yes" epatch
156 fi
157
158 # Bug 301667
159 epatch "${WORKDIR}"/udev-150-fix-missing-firmware-timeout.diff
160
161 # Bug 413055
162 epatch "${WORKDIR}"/udev-164-remove-v4l1.patch
163
164 if ! use devfs-compat; then
165 # see Bug #269359
166 epatch "${WORKDIR}"/udev-141-remove-devfs-names.diff
167 fi
168
169 # change rules back to group uucp instead of dialout for now
170 sed -e 's/GROUP="dialout"/GROUP="uucp"/' \
171 -i rules/{rules.d,packages,gentoo}/*.rules \
172 || die "failed to change group dialout to uucp"
173
174 if [[ ${PV} != 9999 ]]; then
175 # Make sure there is no sudden changes to upstream rules file
176 # (more for my own needs than anything else ...)
177 MD5=$(md5sum < "${S}/rules/rules.d/50-udev-default.rules")
178 MD5=${MD5/ -/}
179 if [[ ${MD5} != 5685cc3878df54845dda5e08d712447a ]]
180 then
181 echo
182 eerror "50-udev-default.rules has been updated, please validate!"
183 eerror "md5sum: ${MD5}"
184 die "50-udev-default.rules has been updated, please validate!"
185 fi
186 fi
187
188 if use old-hd-rules; then
189 epatch "${WORKDIR}"/udev-151-readd-hd-rules.diff
190 fi
191
192 sed_libexec_dir \
193 rules/rules.d/50-udev-default.rules \
194 rules/rules.d/78-sound-card.rules \
195 extras/rule_generator/write_*_rules \
196 || die "sed failed"
197
198 if [[ ${PV} == 9999 ]]; then
199 gtkdocize --copy
200 eautoreconf
201 fi
202 }
203
204 src_compile() {
205 filter-flags -fprefetch-loop-arrays
206
207 econf \
208 --prefix=/usr \
209 --sysconfdir=/etc \
210 --sbindir=/sbin \
211 --libdir=/usr/$(get_libdir) \
212 --with-rootlibdir=/$(get_libdir) \
213 --libexecdir="${udev_libexec_dir}" \
214 --enable-logging \
215 --enable-static \
216 $(use_with selinux) \
217 $(use_enable extras) \
218 --disable-introspection
219 # we don't have gobject-introspection in portage tree
220
221 emake || die "compiling udev failed"
222 }
223
224 src_install() {
225 local scriptdir="${WORKDIR}/151-r4"
226
227 into /
228 emake DESTDIR="${D}" install || die "make install failed"
229
230 exeinto "${udev_libexec_dir}"
231 newexe "${WORKDIR}"/net-130-r1.sh net.sh || die "net.sh not installed properly"
232 newexe "${WORKDIR}"/move_tmp_persistent_rules-112-r1.sh move_tmp_persistent_rules.sh \
233 || die "move_tmp_persistent_rules.sh not installed properly"
234 newexe "${WORKDIR}"/write_root_link_rule-125 write_root_link_rule \
235 || die "write_root_link_rule not installed properly"
236
237 doexe "${scriptdir}"/shell-compat-KV.sh \
238 || die "shell-compat.sh not installed properly"
239 doexe "${scriptdir}"/shell-compat-addon.sh \
240 || die "shell-compat.sh not installed properly"
241
242 keepdir "${udev_libexec_dir}"/state
243 keepdir "${udev_libexec_dir}"/devices
244
245 # create symlinks for these utilities to /sbin
246 # where multipath-tools expect them to be (Bug #168588)
247 dosym "..${udev_libexec_dir}/scsi_id" /sbin/scsi_id
248
249 # Add gentoo stuff to udev.conf
250 echo "# If you need to change mount-options, do it in /etc/fstab" \
251 >> "${D}"/etc/udev/udev.conf
252
253 # let the dir exist at least
254 keepdir /etc/udev/rules.d
255
256 # Now installing rules
257 cd "${S}"/rules
258 insinto "${udev_libexec_dir}"/rules.d/
259
260 # Our rules files
261 doins gentoo/??-*.rules
262 doins packages/40-isdn.rules
263
264 # Adding arch specific rules
265 if [[ -f packages/40-${ARCH}.rules ]]
266 then
267 doins "packages/40-${ARCH}.rules"
268 fi
269 cd "${S}"
270
271 # our udev hooks into the rc system
272 insinto /$(get_libdir)/rcscripts/addons
273 doins "${scriptdir}"/udev-start.sh \
274 || die "udev-start.sh not installed properly"
275 doins "${scriptdir}"/udev-stop.sh \
276 || die "udev-stop.sh not installed properly"
277
278 local init
279 # udev-postmount and init-scripts for >=openrc-0.3.1, Bug #240984
280 for init in udev udev-mount udev-dev-tarball udev-postmount; do
281 newinitd "${scriptdir}/${init}.initd" "${init}" \
282 || die "initscript ${init} not installed properly"
283 done
284
285 # insert minimum kernel versions
286 sed -e "s/%KV_MIN%/${KV_min}/" \
287 -e "s/%KV_MIN_RELIABLE%/${KV_reliable}/" \
288 -i "${D}"/etc/init.d/udev-mount
289
290 # config file for init-script and start-addon
291 newconfd "${scriptdir}/udev.confd" udev \
292 || die "config file not installed properly"
293
294 insinto /etc/modprobe.d
295 newins "${WORKDIR}"/blacklist-146 blacklist.conf
296 newins "${WORKDIR}"/pnp-aliases pnp-aliases.conf
297
298 # convert /lib/udev to real used dir
299 sed_libexec_dir \
300 "${D}/$(get_libdir)"/rcscripts/addons/*.sh \
301 "${D}/${udev_libexec_dir}"/write_root_link_rule \
302 "${D}"/etc/conf.d/udev \
303 "${D}"/etc/init.d/udev* \
304 "${D}"/etc/modprobe.d/*
305
306 # documentation
307 dodoc ChangeLog README TODO || die "failed installing docs"
308
309 # keep doc in just one directory, Bug #281137
310 rm -rf "${D}/usr/share/doc/${PN}"
311 if use extras; then
312 dodoc extras/keymap/README.keymap.txt || die "failed installing docs"
313 fi
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 #225033:
534 elog
535 elog "persistent-net does assigning fixed names to network devices."
536 elog "If you have problems with the persistent-net rules,"
537 elog "just delete the rules file"
538 elog "\trm ${ROOT}etc/udev/rules.d/70-persistent-net.rules"
539 elog "and then reboot."
540 elog
541 elog "This may however number your devices in a different way than they are now."
542
543 ewarn
544 ewarn "If you build an initramfs including udev, then please"
545 ewarn "make sure that the /sbin/udevadm binary gets included,"
546 ewarn "and your scripts changed to use it,as it replaces the"
547 ewarn "old helper apps udevinfo, udevtrigger, ..."
548
549 ewarn
550 ewarn "mount options for directory /dev are no longer"
551 ewarn "set in /etc/udev/udev.conf, but in /etc/fstab"
552 ewarn "as for other directories."
553
554 if use devfs-compat; then
555 ewarn
556 ewarn "devfs-compat use flag is enabled."
557 ewarn "This enables devfs compatible device names."
558 else
559 ewarn
560 ewarn "This version of udev no longer has devfs-compat enabled"
561 fi
562 ewarn "If you use /dev/md/*, /dev/loop/* or /dev/rd/*,"
563 ewarn "then please migrate over to using the device names"
564 ewarn "/dev/md*, /dev/loop* and /dev/ram*."
565 ewarn "The devfs-compat rules will be removed on the next udev update."
566 ewarn "For reference see Bug #269359."
567
568 if use old-hd-rules; then
569 ewarn
570 ewarn "old-hd-rules use flag is enabled"
571 ewarn "This adds the removed rules for /dev/hd* devices"
572 else
573 ewarn
574 ewarn "This version of udev no longer has use flag old-hd-rules enabled"
575 ewarn "So all special rules for /dev/hd* devices are missing"
576 fi
577 ewarn "Please migrate to the new libata if you need these rules."
578 ewarn "They will be completely removed on the next udev update."
579
580 elog
581 elog "For more information on udev on Gentoo, writing udev rules, and"
582 elog " fixing known issues visit:"
583 elog " http://www.gentoo.org/doc/en/udev-guide.xml"
584 }

  ViewVC Help
Powered by ViewVC 1.1.20