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

  ViewVC Help
Powered by ViewVC 1.1.20