/[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.2 - (show annotations) (download)
Wed Mar 30 19:03:22 2011 UTC (7 years, 1 month ago) by zzam
Branch: MAIN
Changes since 1.1: +2 -3 lines
Use updated scripts instead of patching them.

(Portage version: 2.1.9.45/cvs/Linux x86_64)

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-r2.ebuild,v 1.1 2011/03/19 11:06:20 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-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 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
151 cd "${S}"
152
153 # patches go here...
154 epatch "${FILESDIR}"/udev-164-remove-v4l1.patch
155
156 # backport some patches
157 if [[ -n "${PATCHSET}" ]]; then
158 EPATCH_SOURCE="${WORKDIR}/${PATCHSET}" EPATCH_SUFFIX="patch" \
159 EPATCH_FORCE="yes" epatch
160 fi
161
162 # change rules back to group uucp instead of dialout for now
163 sed -e 's/GROUP="dialout"/GROUP="uucp"/' \
164 -i rules/{rules.d,arch}/*.rules \
165 || die "failed to change group dialout to uucp"
166
167 if [[ ${PV} != 9999 ]]; then
168 # Make sure there is no sudden changes to upstream rules file
169 # (more for my own needs than anything else ...)
170 MD5=$(md5sum < "${S}/rules/rules.d/50-udev-default.rules")
171 MD5=${MD5/ -/}
172 if [[ ${MD5} != f3c9ade42f70cec0459f9e58a99c632a ]]
173 then
174 echo
175 eerror "50-udev-default.rules has been updated, please validate!"
176 eerror "md5sum: ${MD5}"
177 die "50-udev-default.rules has been updated, please validate!"
178 fi
179 fi
180
181 sed_libexec_dir \
182 rules/rules.d/50-udev-default.rules \
183 rules/rules.d/78-sound-card.rules \
184 extras/rule_generator/write_*_rules \
185 || die "sed failed"
186
187 if [[ ${PV} == 9999 ]]; then
188 gtkdocize --copy
189 eautoreconf
190 fi
191
192 cd "${WORKDIR}/${scriptname}"
193 sed_libexec_dir \
194 helpers/* \
195 rc/*/*
196 }
197
198 src_compile() {
199 filter-flags -fprefetch-loop-arrays
200
201 econf \
202 --prefix=/usr \
203 --sysconfdir=/etc \
204 --sbindir=/sbin \
205 --libdir=/usr/$(get_libdir) \
206 --with-rootlibdir=/$(get_libdir) \
207 --libexecdir="${udev_libexec_dir}" \
208 --enable-logging \
209 --enable-static \
210 $(use_with selinux) \
211 $(use_enable extras) \
212 --disable-introspection
213 # we don't have gobject-introspection in portage tree
214
215 emake || die "compiling udev failed"
216 }
217
218 src_install() {
219 emake -C "${WORKDIR}/${scriptname}" \
220 DESTDIR="${D}" LIBDIR="$(get_libdir)" \
221 KV_min="${KV_min}" KV_reliable="${KV_reliable}" \
222 install || die "make install failed"
223
224 into /
225 emake DESTDIR="${D}" install || die "make install failed"
226
227 exeinto "${udev_libexec_dir}"
228 keepdir "${udev_libexec_dir}"/state
229 keepdir "${udev_libexec_dir}"/devices
230
231 # create symlinks for these utilities to /sbin
232 # where multipath-tools expect them to be (Bug #168588)
233 dosym "..${udev_libexec_dir}/scsi_id" /sbin/scsi_id
234
235 # Add gentoo stuff to udev.conf
236 echo "# If you need to change mount-options, do it in /etc/fstab" \
237 >> "${D}"/etc/udev/udev.conf
238
239 # let the dir exist at least
240 keepdir /etc/udev/rules.d
241
242 # Now installing rules
243 cd "${S}"/rules
244 insinto "${udev_libexec_dir}"/rules.d/
245
246 # support older kernels
247 doins misc/30-kernel-compat.rules
248
249 # Adding arch specific rules
250 if [[ -f arch/40-${ARCH}.rules ]]
251 then
252 doins "arch/40-${ARCH}.rules"
253 fi
254 cd "${S}"
255
256 insinto /etc/modprobe.d
257 newins "${FILESDIR}"/blacklist-146 blacklist.conf
258 newins "${FILESDIR}"/pnp-aliases pnp-aliases.conf
259
260 # documentation
261 dodoc ChangeLog README TODO || die "failed installing docs"
262
263 # keep doc in just one directory, Bug #281137
264 rm -rf "${D}/usr/share/doc/${PN}"
265 if use extras; then
266 dodoc extras/keymap/README.keymap.txt || die "failed installing docs"
267 fi
268 }
269
270 pkg_preinst() {
271 # moving old files to support newer modprobe, 12 May 2009
272 local f dir=${ROOT}/etc/modprobe.d/
273 for f in pnp-aliases blacklist; do
274 if [[ -f $dir/$f && ! -f $dir/$f.conf ]]
275 then
276 elog "Moving $dir/$f to $f.conf"
277 mv -f "$dir/$f" "$dir/$f.conf"
278 fi
279 done
280
281 if [[ -d ${ROOT}/lib/udev-state ]]
282 then
283 mv -f "${ROOT}"/lib/udev-state/* "${D}"/lib/udev/state/
284 rm -r "${ROOT}"/lib/udev-state
285 fi
286
287 if [[ -f ${ROOT}/etc/udev/udev.config &&
288 ! -f ${ROOT}/etc/udev/udev.rules ]]
289 then
290 mv -f "${ROOT}"/etc/udev/udev.config "${ROOT}"/etc/udev/udev.rules
291 fi
292
293 # delete the old udev.hotplug symlink if it is present
294 if [[ -h ${ROOT}/etc/hotplug.d/default/udev.hotplug ]]
295 then
296 rm -f "${ROOT}"/etc/hotplug.d/default/udev.hotplug
297 fi
298
299 # delete the old wait_for_sysfs.hotplug symlink if it is present
300 if [[ -h ${ROOT}/etc/hotplug.d/default/05-wait_for_sysfs.hotplug ]]
301 then
302 rm -f "${ROOT}"/etc/hotplug.d/default/05-wait_for_sysfs.hotplug
303 fi
304
305 # delete the old wait_for_sysfs.hotplug symlink if it is present
306 if [[ -h ${ROOT}/etc/hotplug.d/default/10-udev.hotplug ]]
307 then
308 rm -f "${ROOT}"/etc/hotplug.d/default/10-udev.hotplug
309 fi
310
311 has_version "=${CATEGORY}/${PN}-103-r3"
312 previous_equal_to_103_r3=$?
313
314 has_version "<${CATEGORY}/${PN}-104-r5"
315 previous_less_than_104_r5=$?
316
317 has_version "<${CATEGORY}/${PN}-106-r5"
318 previous_less_than_106_r5=$?
319
320 has_version "<${CATEGORY}/${PN}-113"
321 previous_less_than_113=$?
322 }
323
324 # 19 Nov 2008
325 fix_old_persistent_net_rules() {
326 local rules=${ROOT}/etc/udev/rules.d/70-persistent-net.rules
327 [[ -f ${rules} ]] || return
328
329 elog
330 elog "Updating persistent-net rules file"
331
332 # Change ATTRS to ATTR matches, Bug #246927
333 sed -i -e 's/ATTRS{/ATTR{/g' "${rules}"
334
335 # Add KERNEL matches if missing, Bug #246849
336 sed -ri \
337 -e '/KERNEL/ ! { s/NAME="(eth|wlan|ath)([0-9]+)"/KERNEL=="\1*", NAME="\1\2"/}' \
338 "${rules}"
339 }
340
341 # See Bug #129204 for a discussion about restarting udevd
342 restart_udevd() {
343 if [[ ${NO_RESTART} = "1" ]]; then
344 ewarn "Not restarting udevd, as your kernel is too old!"
345 return
346 fi
347
348 # need to merge to our system
349 [[ ${ROOT} = / ]] || return
350
351 # check if root of init-process is identical to ours (not in chroot)
352 [[ -r /proc/1/root && /proc/1/root/ -ef /proc/self/root/ ]] || return
353
354 # abort if there is no udevd running
355 [[ -n $(pidof udevd) ]] || return
356
357 # abort if no /dev/.udev exists
358 [[ -e /dev/.udev ]] || return
359
360 elog
361 elog "restarting udevd now."
362
363 killall -15 udevd &>/dev/null
364 sleep 1
365 killall -9 udevd &>/dev/null
366
367 /sbin/udevd --daemon
368 sleep 3
369 if [[ ! -n $(pidof udevd) ]]; then
370 eerror "FATAL: udev died, please check your kernel is"
371 eerror "new enough and configured correctly for ${P}."
372 eerror
373 eerror "Please have a look at this before rebooting."
374 eerror "If in doubt, please downgrade udev back to your old version"
375 ebeep
376 fi
377 }
378
379 postinst_init_scripts() {
380 # FIXME: we may need some code that detects if this is a system bootstrap
381 # and auto-enables udev then
382 #
383 # 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 # migration to >=openrc-0.4
389 if [[ -e "${ROOT}"/etc/runlevels/sysinit && ! -e "${ROOT}"/etc/runlevels/sysinit/udev ]]
390 then
391 ewarn
392 ewarn "You need to add the udev init script to the runlevel sysinit,"
393 ewarn "else your system will not be able to boot"
394 ewarn "after updating to >=openrc-0.4.0"
395 ewarn "Run this to enable udev for >=openrc-0.4.0:"
396 ewarn "\trc-update add udev sysinit"
397 ewarn
398 fi
399
400 # add udev-postmount to default runlevel instead of that ugly injecting
401 # like a hotplug event, 2009/10/15
402
403 # already enabled?
404 [[ -e "${ROOT}"/etc/runlevels/default/udev-postmount ]] && return
405
406 local enable_postmount=0
407 [[ -e "${ROOT}"/etc/runlevels/sysinit/udev ]] && enable_postmount=1
408 [[ "${ROOT}" = "/" && -d /dev/.udev/ ]] && enable_postmount=1
409
410 if [[ ${enable_postmount} = 1 ]]
411 then
412 local initd=udev-postmount
413
414 if [[ -e ${ROOT}/etc/init.d/${initd} ]] && \
415 [[ ! -e ${ROOT}/etc/runlevels/default/${initd} ]]
416 then
417 ln -snf /etc/init.d/${initd} "${ROOT}"/etc/runlevels/default/${initd}
418 elog "Auto-adding '${initd}' service to your default runlevel"
419 fi
420 else
421 elog "You should add the udev-postmount service to default runlevel."
422 elog "Run this to add it:"
423 elog "\trc-update add udev-postmount default"
424 fi
425 }
426
427 pkg_postinst() {
428 fix_old_persistent_net_rules
429
430 # "losetup -f" is confused if there is an empty /dev/loop/, Bug #338766
431 # So try to remove it here (will only work if empty).
432 rmdir "${ROOT}"/dev/loop 2>/dev/null
433 if [[ -d "${ROOT}"/dev/loop ]]; then
434 ewarn "Please make sure your remove /dev/loop,"
435 ewarn "else losetup may be confused when looking for unused devices."
436 fi
437
438 restart_udevd
439
440 postinst_init_scripts
441
442 # people want reminders, I'll give them reminders. Odds are they will
443 # just ignore them anyway...
444
445 # delete 40-scsi-hotplug.rules, it is integrated in 50-udev.rules, 19 Jan 2007
446 if [[ $previous_equal_to_103_r3 = 0 ]] &&
447 [[ -e ${ROOT}/etc/udev/rules.d/40-scsi-hotplug.rules ]]
448 then
449 ewarn "Deleting stray 40-scsi-hotplug.rules"
450 ewarn "installed by sys-fs/udev-103-r3"
451 rm -f "${ROOT}"/etc/udev/rules.d/40-scsi-hotplug.rules
452 fi
453
454 # Removing some device-nodes we thought we need some time ago, 25 Jan 2007
455 if [[ -d ${ROOT}/lib/udev/devices ]]
456 then
457 rm -f "${ROOT}"/lib/udev/devices/{null,zero,console,urandom}
458 fi
459
460 # Removing some old file, 29 Jan 2007
461 if [[ $previous_less_than_104_r5 = 0 ]]
462 then
463 rm -f "${ROOT}"/etc/dev.d/net/hotplug.dev
464 rmdir --ignore-fail-on-non-empty "${ROOT}"/etc/dev.d/net 2>/dev/null
465 fi
466
467 # 19 Mar 2007
468 if [[ $previous_less_than_106_r5 = 0 ]] &&
469 [[ -e ${ROOT}/etc/udev/rules.d/95-net.rules ]]
470 then
471 rm -f "${ROOT}"/etc/udev/rules.d/95-net.rules
472 fi
473
474 # Try to remove /etc/dev.d as that is obsolete, 23 Apr 2007
475 if [[ -d ${ROOT}/etc/dev.d ]]
476 then
477 rmdir --ignore-fail-on-non-empty "${ROOT}"/etc/dev.d/default "${ROOT}"/etc/dev.d 2>/dev/null
478 if [[ -d ${ROOT}/etc/dev.d ]]
479 then
480 ewarn "You still have the directory /etc/dev.d on your system."
481 ewarn "This is no longer used by udev and can be removed."
482 fi
483 fi
484
485 # 64-device-mapper.rules now gets installed by sys-fs/device-mapper
486 # remove it if user don't has sys-fs/device-mapper installed, 27 Jun 2007
487 if [[ $previous_less_than_113 = 0 ]] &&
488 [[ -f ${ROOT}/etc/udev/rules.d/64-device-mapper.rules ]] &&
489 ! has_version sys-fs/device-mapper
490 then
491 rm -f "${ROOT}"/etc/udev/rules.d/64-device-mapper.rules
492 einfo "Removed unneeded file 64-device-mapper.rules"
493 fi
494
495 # requested in bug #275974, added 2009/09/05
496 ewarn
497 ewarn "If after the udev update removable devices or CD/DVD drives"
498 ewarn "stop working, try re-emerging HAL before filling a bug report"
499
500 # requested in Bug #225033:
501 elog
502 elog "persistent-net does assigning fixed names to network devices."
503 elog "If you have problems with the persistent-net rules,"
504 elog "just delete the rules file"
505 elog "\trm ${ROOT}etc/udev/rules.d/70-persistent-net.rules"
506 elog "and then reboot."
507 elog
508 elog "This may however number your devices in a different way than they are now."
509
510 ewarn
511 ewarn "If you build an initramfs including udev, then please"
512 ewarn "make sure that the /sbin/udevadm binary gets included,"
513 ewarn "and your scripts changed to use it,as it replaces the"
514 ewarn "old helper apps udevinfo, udevtrigger, ..."
515
516 ewarn
517 ewarn "mount options for directory /dev are no longer"
518 ewarn "set in /etc/udev/udev.conf, but in /etc/fstab"
519 ewarn "as for other directories."
520
521 ewarn
522 ewarn "If you use /dev/md/*, /dev/loop/* or /dev/rd/*,"
523 ewarn "then please migrate over to using the device names"
524 ewarn "/dev/md*, /dev/loop* and /dev/ram*."
525 ewarn "The devfs-compat rules have been removed."
526 ewarn "For reference see Bug #269359."
527
528 ewarn
529 ewarn "Rules for /dev/hd* devices have been removed"
530 ewarn "Please migrate to libata."
531
532 elog
533 elog "For more information on udev on Gentoo, writing udev rules, and"
534 elog " fixing known issues visit:"
535 elog " http://www.gentoo.org/doc/en/udev-guide.xml"
536 }

  ViewVC Help
Powered by ViewVC 1.1.20