/[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.13 - (hide annotations) (download)
Mon Aug 2 20:52:59 2010 UTC (7 years, 6 months ago) by zzam
Branch: MAIN
Changes since 1.12: +2 -1 lines
Added pkgconfig dependency for udev-149 and newer when using extras use-flag, Bug #327713.
(Portage version: 2.2_rc67/cvs/Linux x86_64)

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

  ViewVC Help
Powered by ViewVC 1.1.20