/[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.25 - (show annotations) (download)
Tue Sep 11 16:24:47 2012 UTC (19 months ago) by williamh
Branch: MAIN
Changes since 1.24: +2 -2 lines
According to armin76, udev works fine on sh with glibc-2.11. To keep things simple, I am adjusting the block to allow glibc-2.11 on all archs.

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

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

  ViewVC Help
Powered by ViewVC 1.1.20