/[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.19 - (hide annotations) (download)
Wed Jul 6 16:44:44 2011 UTC (6 years, 6 months ago) by williamh
Branch: MAIN
Changes since 1.18: +3 -2 lines
add blk_dev_bsg to config_check for bug #373535.

(Portage version: 2.2.0_alpha43/cvs/Linux i686)

1 ulm 1.17 # Copyright 1999-2011 Gentoo Foundation
2 zzam 1.1 # Distributed under the terms of the GNU General Public License v2
3 williamh 1.19 # $Header: /var/cvsroot/gentoo-x86/sys-fs/udev/udev-149.ebuild,v 1.18 2011/06/05 21:09:22 robbat2 Exp $
4 zzam 1.1
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 zzam 1.8 # please update testsys-tarball whenever udev-xxx/test/sys/ is changed
17 zzam 1.1 SRC_URI="mirror://kernel/linux/utils/kernel/hotplug/${P}.tar.bz2
18 zzam 1.8 test? ( mirror://gentoo/${PN}-149-testsys.tar.bz2 )
19 zzam 1.1 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 armin76 1.14 KEYWORDS="~alpha amd64 arm ~hppa ~ia64 ~m68k ~mips ppc ppc64 ~s390 sh ~sparc x86"
27 zzam 1.1 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 zzam 1.2 >=sys-libs/glibc-2.9"
39 zzam 1.1
40     DEPEND="${COMMON_DEPEND}
41 zzam 1.16 extras? (
42     dev-util/gperf
43     dev-util/pkgconfig
44     )
45 vapier 1.15 virtual/os-headers
46     !<sys-kernel/linux-headers-2.6.29
47 zzam 1.1 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 williamh 1.19 CONFIG_CHECK="~INOTIFY_USER ~SIGNALFD ~!SYSFS_DEPRECATED ~!SYSFS_DEPRECATED_V2
65     ~BLK_DEV_BSG"
66 zzam 1.1
67 robbat2 1.18 # Return values:
68     # 2 - reliable
69     # 1 - unreliable
70     # 0 - too old
71 zzam 1.1 udev_check_KV() {
72     local ok=0
73 robbat2 1.18 if [[ ${KV_MAJOR} == 2 && ${KV_MINOR} == 6 ]] || [[ ${KV_MAJOR} == 3 ]]
74 zzam 1.1 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_src_unpack
139     else
140     unpack ${A}
141 zzam 1.8
142     if use test; then
143     mv "${WORKDIR}"/test/sys "${S}"/test/
144     fi
145 zzam 1.1 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 "${FILESDIR}"/udev-141-remove-devfs-names.diff
158     fi
159    
160     # change rules back to group uucp instead of dialout for now
161     sed -e 's/GROUP="dialout"/GROUP="uucp"/' \
162     -i rules/{rules.d,packages,gentoo}/*.rules \
163     || die "failed to change group dialout to uucp"
164    
165     if [[ ${PV} != 9999 ]]; then
166     # Make sure there is no sudden changes to upstream rules file
167     # (more for my own needs than anything else ...)
168     MD5=$(md5sum < "${S}/rules/rules.d/50-udev-default.rules")
169     MD5=${MD5/ -/}
170     if [[ ${MD5} != f38d3e1344588b6e44746097e1dfd149 ]]
171     then
172     echo
173     eerror "50-udev-default.rules has been updated, please validate!"
174     eerror "md5sum=${MD5}"
175     die "50-udev-default.rules has been updated, please validate!"
176     fi
177     fi
178    
179     sed_libexec_dir \
180     rules/rules.d/50-udev-default.rules \
181     rules/rules.d/78-sound-card.rules \
182     extras/rule_generator/write_*_rules \
183     || die "sed failed"
184    
185     if [[ ${PV} == 9999 ]]; then
186     gtkdocize --copy
187     eautoreconf
188     fi
189     }
190    
191     src_compile() {
192     filter-flags -fprefetch-loop-arrays
193    
194     econf \
195     --prefix=/usr \
196     --sysconfdir=/etc \
197     --sbindir=/sbin \
198     --libdir=/usr/$(get_libdir) \
199     --with-rootlibdir=/$(get_libdir) \
200     --libexecdir="${udev_libexec_dir}" \
201     --enable-logging \
202     $(use_with selinux) \
203     $(use_enable extras) \
204     --disable-introspection
205     # we don't have gobject-introspection in portage tree
206    
207     emake || die "compiling udev failed"
208     }
209    
210     src_install() {
211     local scriptdir="${FILESDIR}/147"
212    
213     into /
214     emake DESTDIR="${D}" install || die "make install failed"
215     # without this code, multilib-strict is angry
216     if [[ "$(get_libdir)" != "lib" ]]; then
217     # check if this code is needed, bug #281338
218     if [[ -d "${D}/lib" ]]; then
219     # we can not just rename /lib to /lib64, because
220     # make install creates /lib64 and /lib
221     einfo "Moving lib to $(get_libdir)"
222     mkdir -p "${D}/$(get_libdir)"
223     mv "${D}"/lib/* "${D}/$(get_libdir)/"
224     rmdir "${D}"/lib
225     else
226     einfo "There is no ${D}/lib, move code can be deleted."
227     fi
228     fi
229    
230     exeinto "${udev_libexec_dir}"
231     newexe "${FILESDIR}"/net-130-r1.sh net.sh || die "net.sh not installed properly"
232     newexe "${FILESDIR}"/move_tmp_persistent_rules-112-r1.sh move_tmp_persistent_rules.sh \
233     || die "move_tmp_persistent_rules.sh not installed properly"
234     newexe "${FILESDIR}"/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 "${FILESDIR}"/blacklist-146 blacklist.conf
296     newins "${FILESDIR}"/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     cd docs/writing_udev_rules
316     mv index.html writing_udev_rules.html
317     dohtml *.html
318     }
319    
320     pkg_preinst() {
321     # moving old files to support newer modprobe, 12 May 2009
322     local f dir=${ROOT}/etc/modprobe.d/
323     for f in pnp-aliases blacklist; do
324     if [[ -f $dir/$f && ! -f $dir/$f.conf ]]
325     then
326     elog "Moving $dir/$f to $f.conf"
327     mv -f "$dir/$f" "$dir/$f.conf"
328     fi
329     done
330    
331     if [[ -d ${ROOT}/lib/udev-state ]]
332     then
333     mv -f "${ROOT}"/lib/udev-state/* "${D}"/lib/udev/state/
334     rm -r "${ROOT}"/lib/udev-state
335     fi
336    
337     if [[ -f ${ROOT}/etc/udev/udev.config &&
338     ! -f ${ROOT}/etc/udev/udev.rules ]]
339     then
340     mv -f "${ROOT}"/etc/udev/udev.config "${ROOT}"/etc/udev/udev.rules
341     fi
342    
343     # delete the old udev.hotplug symlink if it is present
344     if [[ -h ${ROOT}/etc/hotplug.d/default/udev.hotplug ]]
345     then
346     rm -f "${ROOT}"/etc/hotplug.d/default/udev.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/05-wait_for_sysfs.hotplug ]]
351     then
352     rm -f "${ROOT}"/etc/hotplug.d/default/05-wait_for_sysfs.hotplug
353     fi
354    
355     # delete the old wait_for_sysfs.hotplug symlink if it is present
356     if [[ -h ${ROOT}/etc/hotplug.d/default/10-udev.hotplug ]]
357     then
358     rm -f "${ROOT}"/etc/hotplug.d/default/10-udev.hotplug
359     fi
360    
361     has_version "=${CATEGORY}/${PN}-103-r3"
362     previous_equal_to_103_r3=$?
363    
364     has_version "<${CATEGORY}/${PN}-104-r5"
365     previous_less_than_104_r5=$?
366    
367     has_version "<${CATEGORY}/${PN}-106-r5"
368     previous_less_than_106_r5=$?
369    
370     has_version "<${CATEGORY}/${PN}-113"
371     previous_less_than_113=$?
372     }
373    
374     # 19 Nov 2008
375     fix_old_persistent_net_rules() {
376     local rules=${ROOT}/etc/udev/rules.d/70-persistent-net.rules
377     [[ -f ${rules} ]] || return
378    
379     elog
380     elog "Updating persistent-net rules file"
381    
382     # Change ATTRS to ATTR matches, Bug #246927
383     sed -i -e 's/ATTRS{/ATTR{/g' "${rules}"
384    
385     # Add KERNEL matches if missing, Bug #246849
386     sed -ri \
387     -e '/KERNEL/ ! { s/NAME="(eth|wlan|ath)([0-9]+)"/KERNEL=="\1*", NAME="\1\2"/}' \
388     "${rules}"
389     }
390    
391     # See Bug #129204 for a discussion about restarting udevd
392     restart_udevd() {
393     if [[ ${NO_RESTART} = "1" ]]; then
394     ewarn "Not restarting udevd, as your kernel is too old!"
395     return
396     fi
397    
398     # need to merge to our system
399     [[ ${ROOT} = / ]] || return
400    
401     # check if root of init-process is identical to ours (not in chroot)
402     [[ -r /proc/1/root && /proc/1/root/ -ef /proc/self/root/ ]] || return
403    
404     # abort if there is no udevd running
405     [[ -n $(pidof udevd) ]] || return
406    
407     # abort if no /dev/.udev exists
408     [[ -e /dev/.udev ]] || return
409    
410     elog
411     elog "restarting udevd now."
412    
413     killall -15 udevd &>/dev/null
414     sleep 1
415     killall -9 udevd &>/dev/null
416    
417     /sbin/udevd --daemon
418     sleep 3
419     if [[ ! -n $(pidof udevd) ]]; then
420     eerror "FATAL: udev died, please check your kernel is"
421     eerror "new enough and configured correctly for ${P}."
422     eerror
423     eerror "Please have a look at this before rebooting."
424     eerror "If in doubt, please downgrade udev back to your old version"
425     ebeep
426     fi
427     }
428    
429     postinst_init_scripts() {
430     # FIXME: we may need some code that detects if this is a system bootstrap
431     # and auto-enables udev then
432     #
433     # FIXME: inconsistent handling of init-scripts here
434     # * udev is added to sysinit in openrc-ebuild
435     # * we add udev-postmount to default in here
436     #
437    
438     # migration to >=openrc-0.4
439     if [[ -e "${ROOT}"/etc/runlevels/sysinit && ! -e "${ROOT}"/etc/runlevels/sysinit/udev ]]
440     then
441     ewarn
442     ewarn "You need to add the udev init script to the runlevel sysinit,"
443     ewarn "else your system will not be able to boot"
444     ewarn "after updating to >=openrc-0.4.0"
445     ewarn "Run this to enable udev for >=openrc-0.4.0:"
446     ewarn "\trc-update add udev sysinit"
447     ewarn
448     fi
449    
450     # add udev-postmount to default runlevel instead of that ugly injecting
451     # like a hotplug event, 2009/10/15
452    
453     # already enabled?
454     [[ -e "${ROOT}"/etc/runlevels/default/udev-postmount ]] && return
455    
456     local enable_postmount=0
457     [[ -e "${ROOT}"/etc/runlevels/sysinit/udev ]] && enable_postmount=1
458     [[ "${ROOT}" = "/" && -d /dev/.udev/ ]] && enable_postmount=1
459    
460     if [[ ${enable_postmount} = 1 ]]
461     then
462     local initd=udev-postmount
463    
464     if [[ -e ${ROOT}/etc/init.d/${initd} ]] && \
465     [[ ! -e ${ROOT}/etc/runlevels/default/${initd} ]]
466     then
467     ln -snf /etc/init.d/${initd} "${ROOT}"/etc/runlevels/default/${initd}
468     elog "Auto-adding '${initd}' service to your default runlevel"
469     fi
470     else
471     elog "You should add the udev-postmount service to default runlevel."
472     elog "Run this to add it:"
473     elog "\trc-update add udev-postmount default"
474     fi
475     }
476    
477     pkg_postinst() {
478     fix_old_persistent_net_rules
479    
480     restart_udevd
481    
482     postinst_init_scripts
483    
484     # people want reminders, I'll give them reminders. Odds are they will
485     # just ignore them anyway...
486    
487     # delete 40-scsi-hotplug.rules, it is integrated in 50-udev.rules, 19 Jan 2007
488     if [[ $previous_equal_to_103_r3 = 0 ]] &&
489     [[ -e ${ROOT}/etc/udev/rules.d/40-scsi-hotplug.rules ]]
490     then
491     ewarn "Deleting stray 40-scsi-hotplug.rules"
492     ewarn "installed by sys-fs/udev-103-r3"
493     rm -f "${ROOT}"/etc/udev/rules.d/40-scsi-hotplug.rules
494     fi
495    
496     # Removing some device-nodes we thought we need some time ago, 25 Jan 2007
497     if [[ -d ${ROOT}/lib/udev/devices ]]
498     then
499     rm -f "${ROOT}"/lib/udev/devices/{null,zero,console,urandom}
500     fi
501    
502     # Removing some old file, 29 Jan 2007
503     if [[ $previous_less_than_104_r5 = 0 ]]
504     then
505     rm -f "${ROOT}"/etc/dev.d/net/hotplug.dev
506     rmdir --ignore-fail-on-non-empty "${ROOT}"/etc/dev.d/net 2>/dev/null
507     fi
508    
509     # 19 Mar 2007
510     if [[ $previous_less_than_106_r5 = 0 ]] &&
511     [[ -e ${ROOT}/etc/udev/rules.d/95-net.rules ]]
512     then
513     rm -f "${ROOT}"/etc/udev/rules.d/95-net.rules
514     fi
515    
516     # Try to remove /etc/dev.d as that is obsolete, 23 Apr 2007
517     if [[ -d ${ROOT}/etc/dev.d ]]
518     then
519     rmdir --ignore-fail-on-non-empty "${ROOT}"/etc/dev.d/default "${ROOT}"/etc/dev.d 2>/dev/null
520     if [[ -d ${ROOT}/etc/dev.d ]]
521     then
522     ewarn "You still have the directory /etc/dev.d on your system."
523     ewarn "This is no longer used by udev and can be removed."
524     fi
525     fi
526    
527     # 64-device-mapper.rules now gets installed by sys-fs/device-mapper
528     # remove it if user don't has sys-fs/device-mapper installed, 27 Jun 2007
529     if [[ $previous_less_than_113 = 0 ]] &&
530     [[ -f ${ROOT}/etc/udev/rules.d/64-device-mapper.rules ]] &&
531     ! has_version sys-fs/device-mapper
532     then
533     rm -f "${ROOT}"/etc/udev/rules.d/64-device-mapper.rules
534     einfo "Removed unneeded file 64-device-mapper.rules"
535     fi
536    
537     # requested in bug #275974, added 2009/09/05
538     ewarn
539     ewarn "If after the udev update removable devices or CD/DVD drives"
540     ewarn "stop working, try re-emerging HAL before filling a bug report"
541    
542     # requested in Bug #225033:
543     elog
544     elog "persistent-net does assigning fixed names to network devices."
545     elog "If you have problems with the persistent-net rules,"
546     elog "just delete the rules file"
547     elog "\trm ${ROOT}etc/udev/rules.d/70-persistent-net.rules"
548     elog "and then reboot."
549     elog
550     elog "This may however number your devices in a different way than they are now."
551    
552     ewarn
553     ewarn "If you build an initramfs including udev, then please"
554     ewarn "make sure that the /sbin/udevadm binary gets included,"
555     ewarn "and your scripts changed to use it,as it replaces the"
556     ewarn "old helper apps udevinfo, udevtrigger, ..."
557    
558     ewarn
559     ewarn "mount options for directory /dev are no longer"
560     ewarn "set in /etc/udev/udev.conf, but in /etc/fstab"
561     ewarn "as for other directories."
562    
563     if use devfs-compat; then
564     ewarn
565 zzam 1.4 ewarn "devfs-compat use flag is enabled (by default)."
566 zzam 1.1 ewarn "This enables devfs compatible device names."
567     ewarn "If you use /dev/md/*, /dev/loop/* or /dev/rd/*,"
568     ewarn "then please migrate over to using the device names"
569     ewarn "/dev/md*, /dev/loop* and /dev/ram*."
570     ewarn "The devfs-compat rules will be removed in the future."
571     ewarn "For reference see Bug #269359."
572     fi
573    
574     elog
575     elog "For more information on udev on Gentoo, writing udev rules, and"
576     elog " fixing known issues visit:"
577     elog " http://www.gentoo.org/doc/en/udev-guide.xml"
578     }

  ViewVC Help
Powered by ViewVC 1.1.20