/[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.1 - (hide annotations) (download)
Sat Mar 19 11:06:20 2011 UTC (7 years, 8 months ago) by zzam
Branch: MAIN
Enable udev inside OpenVZ containers, Bug #346885. Disable v4lv1, so that udev compiles with linux-headers-2.6.38, Bug #359407.

(Portage version: 2.1.9.44/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     # $Header: /var/cvsroot/gentoo-x86/sys-fs/udev/udev-164-r1.ebuild,v 1.1 2010/12/12 22:12:43 zzam 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     scriptversion=164
11     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     KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
30     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     # We need the lib/rcscripts/addon support
71     PROVIDE="virtual/dev-manager"
72    
73     udev_check_KV() {
74     local ok=0
75     if [[ ${KV_MAJOR} == 2 && ${KV_MINOR} == 6 ]]
76     then
77     if kernel_is -ge 2 6 ${KV_PATCH_reliable} ; then
78     ok=2
79     elif kernel_is -ge 2 6 ${KV_PATCH_min} ; then
80     ok=1
81     fi
82     fi
83     return $ok
84     }
85    
86     pkg_setup() {
87     linux-info_pkg_setup
88    
89     udev_libexec_dir="/$(get_libdir)/udev"
90    
91     # udev requires signalfd introduced in kernel 2.6.25,
92     # but a glibc compiled against >=linux-headers-2.6.27 uses the
93     # new signalfd syscall introduced in kernel 2.6.27 without falling back
94     # to the old one. So we just depend on 2.6.27 here, see Bug #281312.
95     KV_PATCH_min=25
96     KV_PATCH_reliable=27
97     KV_min=2.6.${KV_PATCH_min}
98     KV_reliable=2.6.${KV_PATCH_reliable}
99    
100     # always print kernel version requirements
101     ewarn
102     ewarn "${P} does not support Linux kernel before version ${KV_min}!"
103     if [[ ${KV_PATCH_min} != ${KV_PATCH_reliable} ]]; then
104     ewarn "For a reliable udev, use at least kernel ${KV_reliable}"
105     fi
106    
107     echo
108     # We don't care about the secondary revision of the kernel.
109     # 2.6.30.4 -> 2.6.30 is all we check
110     udev_check_KV
111     case "$?" in
112     2) einfo "Your kernel version (${KV_FULL}) is new enough to run ${P} reliably." ;;
113     1) ewarn "Your kernel version (${KV_FULL}) is new enough to run ${P},"
114     ewarn "but it may be unreliable in some cases."
115     ebeep ;;
116     0) eerror "Your kernel version (${KV_FULL}) is too old to run ${P}"
117     ebeep ;;
118     esac
119     echo
120    
121     KV_FULL_SRC=${KV_FULL}
122     get_running_version
123     udev_check_KV
124     if [[ "$?" = "0" ]]; then
125     eerror
126     eerror "udev cannot be restarted after emerging,"
127     eerror "as your running kernel version (${KV_FULL}) is too old."
128     eerror "You really need to use a newer kernel after a reboot!"
129     NO_RESTART=1
130     ebeep
131     fi
132     }
133    
134     sed_libexec_dir() {
135     sed -e "s#/lib/udev#${udev_libexec_dir}#" -i "$@"
136     }
137    
138     src_unpack() {
139     if [[ ${PV} == "9999" ]] ; then
140     git_src_unpack
141     else
142     unpack ${A}
143    
144     if use test; then
145     mv "${WORKDIR}"/test/sys "${S}"/test/
146     fi
147     fi
148    
149     cd "${WORKDIR}/${scriptname}"
150     epatch "${FILESDIR}/udev-164-remove-noopenvz.patch"
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     # FIXME: we may need some code that detects if this is a system bootstrap
382     # and auto-enables udev then
383     #
384     # FIXME: inconsistent handling of init-scripts here
385     # * udev is added to sysinit in openrc-ebuild
386     # * we add udev-postmount to default in here
387     #
388    
389     # migration to >=openrc-0.4
390     if [[ -e "${ROOT}"/etc/runlevels/sysinit && ! -e "${ROOT}"/etc/runlevels/sysinit/udev ]]
391     then
392     ewarn
393     ewarn "You need to add the udev init script to the runlevel sysinit,"
394     ewarn "else your system will not be able to boot"
395     ewarn "after updating to >=openrc-0.4.0"
396     ewarn "Run this to enable udev for >=openrc-0.4.0:"
397     ewarn "\trc-update add udev sysinit"
398     ewarn
399     fi
400    
401     # add udev-postmount to default runlevel instead of that ugly injecting
402     # like a hotplug event, 2009/10/15
403    
404     # already enabled?
405     [[ -e "${ROOT}"/etc/runlevels/default/udev-postmount ]] && return
406    
407     local enable_postmount=0
408     [[ -e "${ROOT}"/etc/runlevels/sysinit/udev ]] && enable_postmount=1
409     [[ "${ROOT}" = "/" && -d /dev/.udev/ ]] && enable_postmount=1
410    
411     if [[ ${enable_postmount} = 1 ]]
412     then
413     local initd=udev-postmount
414    
415     if [[ -e ${ROOT}/etc/init.d/${initd} ]] && \
416     [[ ! -e ${ROOT}/etc/runlevels/default/${initd} ]]
417     then
418     ln -snf /etc/init.d/${initd} "${ROOT}"/etc/runlevels/default/${initd}
419     elog "Auto-adding '${initd}' service to your default runlevel"
420     fi
421     else
422     elog "You should add the udev-postmount service to default runlevel."
423     elog "Run this to add it:"
424     elog "\trc-update add udev-postmount default"
425     fi
426     }
427    
428     pkg_postinst() {
429     fix_old_persistent_net_rules
430    
431     # "losetup -f" is confused if there is an empty /dev/loop/, Bug #338766
432     # So try to remove it here (will only work if empty).
433     rmdir "${ROOT}"/dev/loop 2>/dev/null
434     if [[ -d "${ROOT}"/dev/loop ]]; then
435     ewarn "Please make sure your remove /dev/loop,"
436     ewarn "else losetup may be confused when looking for unused devices."
437     fi
438    
439     restart_udevd
440    
441     postinst_init_scripts
442    
443     # people want reminders, I'll give them reminders. Odds are they will
444     # just ignore them anyway...
445    
446     # delete 40-scsi-hotplug.rules, it is integrated in 50-udev.rules, 19 Jan 2007
447     if [[ $previous_equal_to_103_r3 = 0 ]] &&
448     [[ -e ${ROOT}/etc/udev/rules.d/40-scsi-hotplug.rules ]]
449     then
450     ewarn "Deleting stray 40-scsi-hotplug.rules"
451     ewarn "installed by sys-fs/udev-103-r3"
452     rm -f "${ROOT}"/etc/udev/rules.d/40-scsi-hotplug.rules
453     fi
454    
455     # Removing some device-nodes we thought we need some time ago, 25 Jan 2007
456     if [[ -d ${ROOT}/lib/udev/devices ]]
457     then
458     rm -f "${ROOT}"/lib/udev/devices/{null,zero,console,urandom}
459     fi
460    
461     # Removing some old file, 29 Jan 2007
462     if [[ $previous_less_than_104_r5 = 0 ]]
463     then
464     rm -f "${ROOT}"/etc/dev.d/net/hotplug.dev
465     rmdir --ignore-fail-on-non-empty "${ROOT}"/etc/dev.d/net 2>/dev/null
466     fi
467    
468     # 19 Mar 2007
469     if [[ $previous_less_than_106_r5 = 0 ]] &&
470     [[ -e ${ROOT}/etc/udev/rules.d/95-net.rules ]]
471     then
472     rm -f "${ROOT}"/etc/udev/rules.d/95-net.rules
473     fi
474    
475     # Try to remove /etc/dev.d as that is obsolete, 23 Apr 2007
476     if [[ -d ${ROOT}/etc/dev.d ]]
477     then
478     rmdir --ignore-fail-on-non-empty "${ROOT}"/etc/dev.d/default "${ROOT}"/etc/dev.d 2>/dev/null
479     if [[ -d ${ROOT}/etc/dev.d ]]
480     then
481     ewarn "You still have the directory /etc/dev.d on your system."
482     ewarn "This is no longer used by udev and can be removed."
483     fi
484     fi
485    
486     # 64-device-mapper.rules now gets installed by sys-fs/device-mapper
487     # remove it if user don't has sys-fs/device-mapper installed, 27 Jun 2007
488     if [[ $previous_less_than_113 = 0 ]] &&
489     [[ -f ${ROOT}/etc/udev/rules.d/64-device-mapper.rules ]] &&
490     ! has_version sys-fs/device-mapper
491     then
492     rm -f "${ROOT}"/etc/udev/rules.d/64-device-mapper.rules
493     einfo "Removed unneeded file 64-device-mapper.rules"
494     fi
495    
496     # requested in bug #275974, added 2009/09/05
497     ewarn
498     ewarn "If after the udev update removable devices or CD/DVD drives"
499     ewarn "stop working, try re-emerging HAL before filling a bug report"
500    
501     # requested in Bug #225033:
502     elog
503     elog "persistent-net does assigning fixed names to network devices."
504     elog "If you have problems with the persistent-net rules,"
505     elog "just delete the rules file"
506     elog "\trm ${ROOT}etc/udev/rules.d/70-persistent-net.rules"
507     elog "and then reboot."
508     elog
509     elog "This may however number your devices in a different way than they are now."
510    
511     ewarn
512     ewarn "If you build an initramfs including udev, then please"
513     ewarn "make sure that the /sbin/udevadm binary gets included,"
514     ewarn "and your scripts changed to use it,as it replaces the"
515     ewarn "old helper apps udevinfo, udevtrigger, ..."
516    
517     ewarn
518     ewarn "mount options for directory /dev are no longer"
519     ewarn "set in /etc/udev/udev.conf, but in /etc/fstab"
520     ewarn "as for other directories."
521    
522     ewarn
523     ewarn "If you use /dev/md/*, /dev/loop/* or /dev/rd/*,"
524     ewarn "then please migrate over to using the device names"
525     ewarn "/dev/md*, /dev/loop* and /dev/ram*."
526     ewarn "The devfs-compat rules have been removed."
527     ewarn "For reference see Bug #269359."
528    
529     ewarn
530     ewarn "Rules for /dev/hd* devices have been removed"
531     ewarn "Please migrate to libata."
532    
533     elog
534     elog "For more information on udev on Gentoo, writing udev rules, and"
535     elog " fixing known issues visit:"
536     elog " http://www.gentoo.org/doc/en/udev-guide.xml"
537     }

  ViewVC Help
Powered by ViewVC 1.1.20