/[gentoo-x86]/sys-fs/udev/udev-164-r2.ebuild
Gentoo

Contents of /sys-fs/udev/udev-164-r2.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (hide annotations) (download)
Wed Jun 8 17:28:40 2011 UTC (7 years, 4 months ago) by hwoarang
Branch: MAIN
Changes since 1.7: +2 -2 lines
Stable on amd64 wrt bug #352827

(Portage version: 2.1.9.49/cvs/Linux x86_64)

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

  ViewVC Help
Powered by ViewVC 1.1.20