/[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.1 - (show annotations) (download)
Sat Dec 5 16:34:54 2009 UTC (9 years ago) by zzam
Branch: MAIN
Version bumped. No longer exclude /etc/udev/rules.d from config_protect.
(Portage version: 2.2_rc55/cvs/Linux i686)

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

  ViewVC Help
Powered by ViewVC 1.1.20