/[gentoo-x86]/sys-fs/udev/udev-146-r1.ebuild
Gentoo

Contents of /sys-fs/udev/udev-146-r1.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.21 - (show annotations) (download)
Tue Jul 31 04:43:38 2012 UTC (23 months, 3 weeks ago) by ssuominen
Branch: MAIN
Changes since 1.20: +11 -10 lines
Tarball rest of the legacy files to mirrors.

(Portage version: 2.2.0_alpha116/cvs/Linux x86_64)

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

  ViewVC Help
Powered by ViewVC 1.1.20