/[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.16 - (show annotations) (download)
Tue Aug 24 18:28:32 2010 UTC (7 years, 8 months ago) by zzam
Branch: MAIN
Changes since 1.15: +5 -3 lines
Fix pkgconfig dependency to be only in DEPEND and not in RDEPEND.
(Portage version: 2.2_rc67/cvs/Linux x86_64)

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

  ViewVC Help
Powered by ViewVC 1.1.20