diff options
author | Matthias Schwarzott <zzam@gentoo.org> | 2008-02-02 20:36:54 +0000 |
---|---|---|
committer | Matthias Schwarzott <zzam@gentoo.org> | 2008-02-02 20:36:54 +0000 |
commit | 75e0c81869eb12e2d855cb7db164d90734340b04 (patch) | |
tree | 6a07e12583e290643c3be0ecdd35fef9f7c00468 /sys-fs/udev | |
parent | Stable on amd64, bug #208035 (diff) | |
download | historical-75e0c81869eb12e2d855cb7db164d90734340b04.tar.gz historical-75e0c81869eb12e2d855cb7db164d90734340b04.tar.bz2 historical-75e0c81869eb12e2d855cb7db164d90734340b04.zip |
Add openrc capable start-scripts. Based on code by Uberlord, Bug #208245. This removes mount-options from udev.conf, now they are taken from fstab.
Package-Manager: portage-2.1.4.1
Diffstat (limited to 'sys-fs/udev')
-rw-r--r-- | sys-fs/udev/ChangeLog | 10 | ||||
-rw-r--r-- | sys-fs/udev/Manifest | 12 | ||||
-rw-r--r-- | sys-fs/udev/files/shell-compat-118-r2.sh | 57 | ||||
-rw-r--r-- | sys-fs/udev/files/udev-start-118-r2.sh | 203 | ||||
-rwxr-xr-x | sys-fs/udev/files/udev-stop-118-r2.sh | 71 | ||||
-rw-r--r-- | sys-fs/udev/udev-118-r2.ebuild | 350 |
6 files changed, 698 insertions, 5 deletions
diff --git a/sys-fs/udev/ChangeLog b/sys-fs/udev/ChangeLog index 78be2d297dd7..fd0e66167d6c 100644 --- a/sys-fs/udev/ChangeLog +++ b/sys-fs/udev/ChangeLog @@ -1,6 +1,14 @@ # ChangeLog for sys-fs/udev # Copyright 1999-2008 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/sys-fs/udev/ChangeLog,v 1.369 2008/02/01 14:52:43 zzam Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-fs/udev/ChangeLog,v 1.370 2008/02/02 20:36:54 zzam Exp $ + +*udev-118-r2 (02 Feb 2008) + + 02 Feb 2008; Matthias Schwarzott <zzam@gentoo.org> + +files/shell-compat-118-r2.sh, +files/udev-start-118-r2.sh, + +files/udev-stop-118-r2.sh, +udev-118-r2.ebuild: + Add openrc capable start-scripts. Based on code by Uberlord, Bug #208245. + This removes mount-options from udev.conf, now they are taken from fstab. *udev-118-r1 (01 Feb 2008) diff --git a/sys-fs/udev/Manifest b/sys-fs/udev/Manifest index 4d2237d986e5..ad876b487ed6 100644 --- a/sys-fs/udev/Manifest +++ b/sys-fs/udev/Manifest @@ -18,6 +18,7 @@ AUX net-104-r10.sh 719 RMD160 e0c3a76c24108d43518f301ebe5cff7f3e06081d SHA1 baa0 AUX net-118-r1.sh 861 RMD160 44335ca0bf482757683fcaf014d2b9072c8fa10c SHA1 7729b61627b71038928310b27099bd02175825df SHA256 90054aeda808a7b82ff08d7185a198f89f9a0b5ad0e3ff8e92940fdec4b7d68a AUX pnp-aliases 537 RMD160 e0144801b7b9c77eb4897692678b75a661723725 SHA1 8276e2dd1a3be1aa2343797b3f9906606d58c9ca SHA256 690b32a166d060c1c663030c51d5b2298eb9d314c8cef737373e0b16ed751e99 AUX seq_node.sh 1628 RMD160 2851f756afdcf1a7ee8c9e7652e129ce6a71d828 SHA1 b991fe67410841471a978429b18b1c660cf366f9 SHA256 e79b4f5dc92714d6051912188cce0cc827bb0cd7a662f13cbdef2218bba65cee +AUX shell-compat-118-r2.sh 1050 RMD160 9cffc5b6b1159fcf87a6befbfaaf01a632828d9f SHA1 75b90a518372624a850c045993885104e27728dc SHA256 f3a71925ca6b99a34018150b3280c4990b465aa297de55f7784f90b1fe9b5e6a AUX udev-104-netif-rename-busywait.patch 962 RMD160 d6e2ea0538c382fd06ee61ef6d0845651b7bfea1 SHA1 7b6c3f41c174f8e34d00374929ab1e77e44b8ba0 SHA256 32c65c4461d9a4d273464d4773c33ea38ab749a88914ca40008dbfe1c3fc58eb AUX udev-104-peristent-net-disable-xen.patch 1027 RMD160 326cfdb0529348013e9b50edd1cf878808d980d1 SHA1 743af3cdd57c72a6286ef17e25ebafbf71e15b0a SHA256 07ae5cb9ead44ebb032c0322cd93b19d9eba7e43704c3ec55d29ac21f5e24ab0 AUX udev-104-persistent-net-fix-name-dups.patch 573 RMD160 49e11cd8b88676aca12c6b62381031f0fcea6de0 SHA1 bc0db37772f40bdcedbbba8dbf2e25c4a5157708 SHA256 82565a21d776f064500b69bc4fc2f4c7484b7fedc1b2777f5f8f52564904d0f4 @@ -45,10 +46,12 @@ AUX udev-start-114-r1.sh 6218 RMD160 a7348ac44768096b3da712a9be0ef4bf9af6ec17 SH AUX udev-start-115-r3.sh 5160 RMD160 55843eff0e0e3d85fef44c82ec03ffde9d220617 SHA1 884b54cceb3eeeda3ee29242d1e8d789691495b3 SHA256 83f2d59bbb887d941768ee283c089c9ab1c1bc519a75952448884b1245c58026 AUX udev-start-115-r6.sh 5237 RMD160 47b9b267d99dae5c02ddea3145beb5ad39e990de SHA1 99ea6d9dc21d3bb05a6b01cd7473e44fe0a56ec1 SHA256 4aee73d21d34c0f20cab2800ea9b86ab6cb14efadaade23321b0d61f9b58fc17 AUX udev-start-118-r1.sh 5353 RMD160 159826d39461d4c01256b0247c4c27a44abf16dd SHA1 8b5a0738df2adf4650840d1c62d2d79b55ae95ae SHA256 3145a511043ddf6909743ff01a4c5375025932367df8862d5e453561793526f6 +AUX udev-start-118-r2.sh 5072 RMD160 24b469dc45b70b6eac82ae3a32f1fb8b0d062c5f SHA1 259ffce13605ad5dd4495926862a1c30ed9c1b51 SHA256 90b6a7616767facf64bcc21563f7333f63633044c24fa56f6ca5647c5b8ee5dc AUX udev-stop-104-r13.sh 3213 RMD160 aedef1ca5fe853eb3f5a774f354dc36dccbd31e5 SHA1 0ced2a331cf516019326d87e2b3c7978d2c02d23 SHA256 2762507dc5a640eb66823a87402d1ddae9c3430b47f69ff95a7e55f7c2f95be9 AUX udev-stop-104-r8.sh 3208 RMD160 76a1fa5ce68250710c79e141d76d83b3331a4f2e SHA1 78ec2b84513e9acba286dd5abb95e21f6d54d999 SHA256 5b1eb2912a33987eae9502297f804a189e14e41498b7ea08d97423bcfb2e2f2c AUX udev-stop-110-r1.sh 2792 RMD160 2e91f2b3c71d1c9efd0fcf2b29330845abaa2948 SHA1 f76f618d9581530be3f62fedbf2f01be97f0c5ad SHA256 38df53470d073d14a28b2b56f2c1c3ec94d21bc9c75c0fec9549200f389e841f AUX udev-stop-111-r2.sh 2389 RMD160 a3dcd87b999576f552c3a36f43513c68eabf40dd SHA1 a107387dfe9d0e5bbb470cc89186b49248b4e2a9 SHA256 41f0b053033ceaadf1e9334540c129a879aedb35de88f8aff0b3464009fa04fa +AUX udev-stop-118-r2.sh 2160 RMD160 0c3c40fbe3f931a3a8a41b9bcc98b5d6f6592f45 SHA1 9327cd3f6fd805b198ca7f75dcc839a6ebd04066 SHA256 ebda8f0e744e842b2dc563e58ec9bb18f981c9003a4446fdf95cbbe90df5e62e AUX udev.conf.115-r6 166 RMD160 b08173d4eb5b02696f54b6549b68aa5a67f48c01 SHA1 f51804ec5234488e2889d6cf8f30a570be81c7ae SHA256 3c820dcea3dfd356788bd2b25a00db3a9f1d974962ecc5119135a594332ee9fc AUX udev.conf.post_081 681 RMD160 16a7e32f351fa5ca761c32fa387993a3d925d55c SHA1 09647c44f78476031b2fcf1a304069f63ceb231f SHA256 db8f66c5c0f87f5ab3566872c6ec5cd5752cb29ff9d7458607ef9a5c4bf7443a AUX udev.conf.post_108 754 RMD160 a4cf25cd25d08bf8b2f7444206077fa87b249fa7 SHA1 bf304d4a2bb61ed72544b6cff48bcf5b1be20a97 SHA256 587d1756e4a63aaccc2f1c71783b332b62056c41f2fb1ed0db6b3ac067238bef @@ -90,13 +93,14 @@ EBUILD udev-116-r1.ebuild 9565 RMD160 dd1ac0913bcb18c1a2176fc70538fe8053d37c1d S EBUILD udev-116.ebuild 9509 RMD160 5020c05a401528e434fcfb6b043e0c1180b9677c SHA1 5e608351fd71b722532a5cfdfbca172e8f9f69bb SHA256 a2936a298ea7fe62f105b0654bcc78dd6c27b43cffcb7674de16fb57f083214c EBUILD udev-117.ebuild 9482 RMD160 fe6ba1f21b47b036fcade67a3044597bf4fac495 SHA1 f39f626cb1c1302a4981c33af41ffe457eac219c SHA256 eda844e88de47d9a67d8f19bf28e09307ededc9f596fceb3c02bf876bed5aad7 EBUILD udev-118-r1.ebuild 9546 RMD160 7fe0e1ecc4b424e7ad13ca3eaff4927af34e84da SHA1 7dba86bc5c7594ab073fa8e32f88027f0ef0a9c1 SHA256 86c9bb7885dd45d7441e131fa899b6d2d8fe117a4458dcd6e8ba1aa57faa0b63 +EBUILD udev-118-r2.ebuild 9843 RMD160 344071fb8d41c9348286f12464abc56b74bd61f0 SHA1 05a4e160da6e112c41b3f83996f4863adbd5450f SHA256 dc4edd2ed5ceb87c50e8bd4126ec30472e3ecbd45b89dd48607995e51bca34d8 EBUILD udev-118.ebuild 9544 RMD160 72c7e3ea74d0e3681a7a76310f1f233454b247d1 SHA1 9689ed1182a612d4b31a3fbf344a3aa20a10353b SHA256 b51b5742df8e4c5e93ede735d3967cc922e25e0f3ddf4ef2df21b5b12f28c15e -MISC ChangeLog 74272 RMD160 8ddc44d03167f1fa97c437484c7b12fe632b6bba SHA1 fde49ea9ffb0c307c0205da3cd7ac6a7f86ad7c7 SHA256 fb199641bb3172d9bab76f1fd41783365de405c6da8d0401da08820e7db66f69 +MISC ChangeLog 74619 RMD160 176dabfb86cdcd9a9880707d9ff5bfce2a53cdb2 SHA1 e7c4612b41a2eb4c4a9bda01d6802e249a683d5d SHA256 575236b0b7a43cc5c786a61574009af95699f3e8003e2a734dbcc8e2caeda844 MISC metadata.xml 447 RMD160 d1ba09bd6a434b25c718673de9258cc544e090be SHA1 70c43d2863c09958849bfce8c5bb97d406a0662b SHA256 a9881de1424ac71191111bd30c7c1253589673b0cdce13c352204f1499e9d884 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) -iD8DBQFHozJEt2vP6XvVdOcRAgM7AJ91WXQDdFBWNXPJEGZm1a8AQp0AoQCeNiYB -JE7SFO3vSXVzTPhHP3ODD5g= -=2JHb +iD8DBQFHpNRst2vP6XvVdOcRAuqWAJ93pEppBvhwGNztpPB/iAm1MKoaLwCgi4N+ +a1DHnaS/2kA2RIHuxDk6Gow= +=K7v2 -----END PGP SIGNATURE----- diff --git a/sys-fs/udev/files/shell-compat-118-r2.sh b/sys-fs/udev/files/shell-compat-118-r2.sh new file mode 100644 index 000000000000..0b91bf5dc2f7 --- /dev/null +++ b/sys-fs/udev/files/shell-compat-118-r2.sh @@ -0,0 +1,57 @@ +# Copyright 1999-2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +cmd_exist() +{ + type "$1" >/dev/null 2>&1 +} + +if ! cmd_exist yesno; then + yesno() { + [ -z "$1" ] && return 1 + case "$1" in + yes|Yes|YES) return 0 ;; + esac + return 1 + } +fi + +if ! cmd_exist KV_to_int; then + KV_to_int() { + [ -z $1 ] && return 1 + + local x=${1%%-*} + local KV_MAJOR=${x%%.*} + x=${x#*.} + local KV_MINOR=${x%%.*} + x=${x#*.} + local KV_MICRO=${x%%.*} + local KV_int=$((${KV_MAJOR} * 65536 + ${KV_MINOR} * 256 + ${KV_MICRO} )) + + # We make version 2.2.0 the minimum version we will handle as + # a sanity check ... if its less, we fail ... + [ "${KV_int}" -lt 131584 ] && return 1 + + echo "${KV_int}" + } +fi + +if ! cmd_exist get_KV; then + _RC_GET_KV_CACHE="" + get_KV() { + [ -z "${_RC_GET_KV_CACHE}" ] \ + && _RC_GET_KV_CACHE="$(uname -r)" + + echo "$(KV_to_int "${_RC_GET_KV_CACHE}")" + + return $? + } +fi + +if ! cmd_exist fstabinfo; then + # we only query /dev, so ignore all args + fstabinfo() { + yesno "${RC_USE_FSTAB}" + } +fi + diff --git a/sys-fs/udev/files/udev-start-118-r2.sh b/sys-fs/udev/files/udev-start-118-r2.sh new file mode 100644 index 000000000000..b9cc0486e679 --- /dev/null +++ b/sys-fs/udev/files/udev-start-118-r2.sh @@ -0,0 +1,203 @@ +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +[ -e /etc/udev/udev.conf ] && . /etc/udev/udev.conf +. /lib/udev/shell-compat.sh + +rc_coldplug=${rc_coldplug:-${RC_COLDPLUG:-YES}} +rc_device_tarball=${rc_device_tarball:-${RC_DEVICE_TARBALL:-NO}} + +# FIXME +# Instead of this script testing kernel version, udev itself should +# Maybe something like udevd --test || exit $? +check_kernel() +{ + if [ $(get_KV) -le $(KV_to_int '2.6.14') ]; then + eerror "Your kernel is too old to work with this version of udev." + eerror "Current udev only supports Linux kernel 2.6.15 and newer." + return 1 + fi + return 0 +} + + +mount_dev_directory() +{ + # No options are processed here as they should all be in /etc/fstab + ebegin "Mounting /dev for udev" + if fstabinfo --quiet /dev; then + mount -n /dev + else + # Some devices require exec, Bug #92921 + mount -n -t tmpfs -o "exec,nosuid,mode=0755,size=10M" udev /dev + fi + eend $? +} + +unpack_device_tarball() +{ + local device_tarball=/lib/udev/state/devices.tar.bz2 + if yesno "${rc_device_tarball}" && \ + [ -s "${device_tarball}" ] + then + ebegin "Populating /dev with saved device nodes" + tar -jxpf "${device_tarball}" -C /dev + eend $? + fi +} + +seed_dev() +{ + # Seed /dev with some things that we know we need + + # creating /dev/console and /dev/tty1 to be able to write + # to $CONSOLE with/without bootsplash before udevd creates it + [ -c /dev/console ] || mknod /dev/console c 5 1 + [ -c /dev/tty1 ] || mknod /dev/tty1 c 4 1 + + # udevd will dup its stdin/stdout/stderr to /dev/null + # and we do not want a file which gets buffered in ram + [ -c /dev/null ] || mknod /dev/null c 1 3 + + # copy over any persistant things + if [ -d /lib/udev/devices ]; then + cp -RPp /lib/udev/devices/* /dev 2>/dev/null + fi + + # Not provided by sysfs but needed + ln -snf /proc/self/fd /dev/fd + ln -snf fd/0 /dev/stdin + ln -snf fd/1 /dev/stdout + ln -snf fd/2 /dev/stderr + [ -e /proc/kcore ] && ln -snf /proc/kcore /dev/core + + # Create problematic directories + mkdir -p /dev/pts /dev/shm +} + +start_udev() +{ + ebegin "Starting udevd" + start-stop-daemon --start --exec /sbin/udevd -- --daemon + eend $? +} + +# populate /dev with devices already found by the kernel +populate_udev() +{ + if get_bootparam "nocoldplug" ; then + rc_coldplug="NO" + ewarn "Skipping udev coldplug as requested in kernel cmdline" + fi + + ebegin "Populating /dev with existing devices through uevents" + if yesno "${rc_coldplug}"; then + udevtrigger + else + # Do not run any init-scripts, Bug #206518 + udevadm control --env do_not_run_plug_service=1 + + # only create device nodes + udevtrigger --attr-match=dev + + # run persistent-net stuff, bug 191466 + udevtrigger --subsystem-match=net + fi + eend $? + + ebegin "Waiting for uevents to be processed" + udevsettle --timeout=60 + eend $? + + udevadm control --env do_not_run_plug_service= + return 0 +} + +compat_device_nodes() +{ + # Only do this for baselayout-1* + if [ ! -e /lib/librc.so ]; then + + # Create nodes that udev can't + [ -x /sbin/lvm ] && \ + /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null + # Running evms_activate on a LiveCD causes lots of headaches + [ -z "${CDBOOT}" -a -x /sbin/evms_activate ] && \ + /sbin/evms_activate -q &>/dev/null + fi +} + +check_persistent_net() +{ + # check if there are problems with persistent-net + local syspath= devs= problem=false + for syspath in /sys/class/net/*_rename*; do + if [ -d "${syspath}" ]; then + devs="${devs} ${syspath##*/}" + problem=true + fi + done + + ${problem} || return 0 + + eerror "UDEV: Your system has a problem assigning persistent names" + eerror "to these network interfaces: ${devs}" + + einfo "Checking persistent-net rules:" + # the sed-expression lists all duplicate lines + # from the input, like "uniq -d" does, but uniq + # is installed into /usr/bin and not available at boot. + dups=$( + RULES_FILE='/etc/udev/rules.d/70-persistent-net.rules' + . /lib/udev/rule_generator.functions + find_all_rules 'NAME=' '.*' | \ + tr ' ' '\n' | \ + sort | \ + sed '$!N; s/^\(.*\)\n\1$/\1/; t; D' + ) + if [ -n "${dups}" ]; then + ewarn "The rules create multiple entries assigning these names:" + eindent + ewarn "${dups}" + eoutdent + else + ewarn "Found no duplicate names in persistent-net rules," + ewarn "there must be some other problem!" + fi + return 1 +} + +check_kernel || exit $? +mount_dev_directory || exit $? + +# Create a file so that our rc system knows it's still in sysinit. +# Existance means init scripts will not directly run. +# rc will remove the file when done with sysinit. +touch /dev/.rcsysinit + +# Selinux lovin; /selinux should be mounted by selinux-patched init +if [ -x /sbin/restorecon -a -c /selinux/null ]; then + restorecon /dev > /selinux/null +fi + +unpack_device_tarball +seed_dev + +if [ -e /proc/sys/kernel/hotplug ]; then + echo "" >/proc/sys/kernel/hotplug +fi + +start_udev || exit $? + +/lib/udev/write_root_link_rule +populate_udev + +compat_device_nodes + +check_persistent_net + +# trigger executing initscript when /etc is writable +IN_HOTPLUG=1 /etc/init.d/udev-postmount start >/dev/null 2>&1 + +# udev started successfully +exit 0 diff --git a/sys-fs/udev/files/udev-stop-118-r2.sh b/sys-fs/udev/files/udev-stop-118-r2.sh new file mode 100755 index 000000000000..990130f88dfa --- /dev/null +++ b/sys-fs/udev/files/udev-stop-118-r2.sh @@ -0,0 +1,71 @@ +# Copyright 1999-2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +/lib/udev/move_tmp_persistent_rules.sh + +. /lib/udev/shell-compat.sh + +device_tarball=/lib/udev/state/devices.tar.bz2 + +rc_device_tarball=${rc_device_tarball:-${RC_DEVICE_TARBALL:-NO}} +if [ -e /dev/.devfsd ] || [ ! -e /dev/.udev ] || [ ! -z "${CDBOOT}" ] || \ + ! yesno "${rc_device_tarball}" || \ + ! touch "${device_tarball}" 2>/dev/null +then + exit 0 +fi + +ebegin "Saving device nodes" +# Handle our temp files +save_tmp_base=/tmp/udev.savedevices."$$" +devices_udev="${save_tmp_base}"/devices.udev +devices_real="${save_tmp_base}"/devices.real +devices_totar="${save_tmp_base}"/devices.totar +device_tmp_tarball="${save_tmp_base}"/devices + +rm -rf "${save_tmp_base}" +mkdir "${save_tmp_base}" +touch "${devices_udev}" "${devices_real}" \ +"${devices_totar}" "${device_tmp_tarball}" + +if [ -f "${devices_udev}" -a -f "${devices_real}" -a \ + -f "${devices_totar}" -a -f "${device_tmp_tarball}" ] +then + cd /dev + # Find all devices, but ignore .udev directory + find . -xdev -type b -or -type c -or -type l | \ + cut -d/ -f2- | \ + grep -v ^\\.udev >"${devices_real}" + + # Figure out what udev created + udevinfo --export-db | sed -ne 's,^[SN]: \(.*\),\1,p' >"${devices_udev}" + # These ones we also do not want in there + for x in MAKEDEV core fd initctl pts shm stderr stdin stdout root; do + echo "${x}" >> "${devices_udev}" + done + if [ -d /lib/udev/devices ]; then + cd /lib/udev/devices + find . -xdev -type b -or -type c -or -type l | \ + cut -d/ -f2- >> "${devices_udev}" + cd /dev + fi + + fgrep -x -v -f "${devices_udev}" "${devices_real}" > "${devices_totar}" + + # Now only tarball those not created by udev if we have any + if [ -s "${devices_totar}" ]; then + # we dont want to descend into mounted filesystems (e.g. devpts) + # looking up username may involve NIS/network + # and net may be down + tar --one-file-system --numeric-owner \ + -jcpf "${device_tmp_tarball}" -T "${devices_totar}" + mv -f "${device_tmp_tarball}" "${device_tarball}" + else + rm -f "${device_tarball}" + fi + eend 0 +else + eend 1 "Could not create temporary files!" +fi + +rm -rf "${save_tmp_base}" diff --git a/sys-fs/udev/udev-118-r2.ebuild b/sys-fs/udev/udev-118-r2.ebuild new file mode 100644 index 000000000000..687248e16c19 --- /dev/null +++ b/sys-fs/udev/udev-118-r2.ebuild @@ -0,0 +1,350 @@ +# Copyright 1999-2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-fs/udev/udev-118-r2.ebuild,v 1.1 2008/02/02 20:36:54 zzam Exp $ + +inherit eutils flag-o-matic multilib toolchain-funcs versionator + +DESCRIPTION="Linux dynamic and persistent device naming support (aka userspace devfs)" +HOMEPAGE="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html" +SRC_URI="mirror://kernel/linux/utils/kernel/hotplug/${P}.tar.bz2" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86" +IUSE="selinux" + +DEPEND="selinux? ( sys-libs/libselinux )" +RDEPEND="!sys-apps/coldplug + !<sys-fs/device-mapper-1.02.19-r1" +RDEPEND="${DEPEND} ${RDEPEND} + >=sys-apps/baselayout-1.12.5" +# We need the lib/rcscripts/addon support +PROVIDE="virtual/dev-manager" + +pkg_setup() { + udev_helper_dir="/$(get_libdir)/udev" + + myconf= + extras="extras/ata_id \ + extras/cdrom_id \ + extras/edd_id \ + extras/firmware \ + extras/floppy \ + extras/path_id \ + extras/scsi_id \ + extras/usb_id \ + extras/volume_id \ + extras/collect \ + extras/rule_generator" + + use selinux && myconf="${myconf} USE_SELINUX=true" + + # comparing kernel version without linux-info.eclass to not pull + # virtual/linux-sources + + local KV=$(uname -r) + local KV_MAJOR=$(get_major_version ${KV}) + local KV_MINOR=$(get_version_component_range 2 ${KV}) + local KV_MICRO=$(get_version_component_range 3 ${KV}) + + local ok=0 + if [[ ${KV_MAJOR} == 2 && ${KV_MINOR} == 6 && ${KV_MICRO} -ge 15 ]] + then + ok=1 + fi + + if [[ ${ok} == 0 ]] + then + ewarn + ewarn "${P} does not support Linux kernel before version 2.6.15!" + ewarn "If you want to use udev you need to update" + ewarn "to kernel >=2.6.15!" + ewarn + ebeep + fi +} + +sed_helper_dir() { + sed -e "s#/lib/udev#${udev_helper_dir}#" -i "$@" +} + +src_unpack() { + unpack ${A} + + cd "${S}" + + # patches go here... + + # No need to clutter the logs ... + sed -ie '/^DEBUG/ c\DEBUG = false' Makefile + # Do not use optimization flags from the package + sed -ie 's|$(OPTIMIZATION)||g' Makefile + # Do not require xmlto to refresh manpages + sed -ie 's|$(MAN_PAGES)||g' Makefile + + # Make sure there is no sudden changes to upstream rules file + # (more for my own needs than anything else ...) + MD5=$(md5sum < "${S}/etc/udev/rules.d/50-udev-default.rules") + MD5=${MD5/ -/} + if [[ ${MD5} != a71a3459f46eb61b209a73fc0c6a299f ]] + then + echo + eerror "50-udev-default.rules has been updated, please validate!" + die "50-udev-default.rules has been updated, please validate!" + fi + + sed_helper_dir \ + etc/udev/rules.d/50-udev-default.rules \ + extras/rule_generator/write_*_rules \ + udev_rules_parse.c \ + udev_rules.c + + # Use correct multilib dir + sed -i extras/volume_id/lib/Makefile \ + -e "/ =/s-/lib-/$(get_libdir)-" +} + +src_compile() { + filter-flags -fprefetch-loop-arrays + + if [[ -z ${extras} ]]; then + eerror "Variable extras is unset!" + eerror "It seems you suffer from Bug #190994" + die "Variable extras is unset!" + fi + + # Not everyone has full $CHOST-{ld,ar,etc...} yet + local mycross="" + type -p ${CHOST}-ar && mycross=${CHOST}- + + emake \ + EXTRAS="${extras}" \ + libudevdir=${udev_helper_dir} \ + CROSS_COMPILE=${mycross} \ + OPTFLAGS="" \ + ${myconf} || die "compiling udev failed" +} + +src_install() { + into / + emake \ + DESTDIR="${D}" \ + libudevdir=${udev_helper_dir} \ + EXTRAS="${extras}" \ + ${myconf} \ + install || die "make install failed" + + exeinto "${udev_helper_dir}" + newexe "${FILESDIR}"/net-118-r1.sh net.sh || die "net.sh not installed properly" + newexe "${FILESDIR}"/move_tmp_persistent_rules-112-r1.sh move_tmp_persistent_rules.sh \ + || die "move_tmp_persistent_rules.sh not installed properly" + doexe "${FILESDIR}"/write_root_link_rule \ + || die "write_root_link_rule not installed properly" + newexe "${FILESDIR}"/shell-compat-118-r2.sh shell-compat.sh \ + || die "shell-compat.sh not installed properly" + + keepdir "${udev_helper_dir}"/state + keepdir "${udev_helper_dir}"/devices + + # create symlinks for these utilities to /sbin + # where multipath-tools expect them to be (Bug #168588) + dosym "..${udev_helper_dir}/vol_id" /sbin/vol_id + dosym "..${udev_helper_dir}/scsi_id" /sbin/scsi_id + + # vol_id library (needed by mount and HAL) + into / + rm "${D}/$(get_libdir)"/libvolume_id.so* 2>/dev/null + dolib extras/volume_id/lib/*.so* || die "Failed installing libvolume_id.so" + into /usr + dolib extras/volume_id/lib/*.a || die "Failed installing libvolume_id.a" + + # handle static linking bug #4411 + rm -f "${D}/usr/$(get_libdir)/libvolume_id.so" + gen_usr_ldscript libvolume_id.so + + # Add gentoo stuff to udev.conf + echo "# If you need to change mount-options, do it in /etc/fstab" \ + >> "${D}"/etc/udev/udev.conf + + # Now installing rules + cd etc/udev + insinto /etc/udev/rules.d/ + + # Our rules files + doins gentoo/??-*.rules + doins packages/40-alsa.rules + + # Adding arch specific rules + if [[ -f packages/40-${ARCH}.rules ]] + then + doins "packages/40-${ARCH}.rules" + fi + cd "${S}" + + # our udev hooks into the rc system + insinto /$(get_libdir)/rcscripts/addons + newins "${FILESDIR}"/udev-start-118-r2.sh udev-start.sh + newins "${FILESDIR}"/udev-stop-118-r2.sh udev-stop.sh + + # The udev-post init-script + newinitd "${FILESDIR}"/udev-postmount-initd-111-r2 udev-postmount + + insinto /etc/modprobe.d + newins "${FILESDIR}"/blacklist-110 blacklist + doins "${FILESDIR}"/pnp-aliases + + # convert /lib/udev to real used dir + sed_helper_dir \ + "${D}/$(get_libdir)"/rcscripts/addons/*.sh \ + "${D}"/etc/init.d/udev* \ + "${D}"/etc/modprobe.d/* + + # documentation + dodoc ChangeLog FAQ README TODO RELEASE-NOTES + dodoc docs/{overview,udev_vs_devfs} + + cd docs/writing_udev_rules + mv index.html writing_udev_rules.html + dohtml *.html + + cd "${S}" + + newdoc extras/volume_id/README README_volume_id + + echo "CONFIG_PROTECT_MASK=\"/etc/udev/rules.d\"" > 20udev + doenvd 20udev +} + +pkg_preinst() { + if [[ -d ${ROOT}/lib/udev-state ]] + then + mv -f "${ROOT}"/lib/udev-state/* "${D}"/lib/udev/state/ + rm -r "${ROOT}"/lib/udev-state + fi + + if [[ -f ${ROOT}/etc/udev/udev.config && + ! -f ${ROOT}/etc/udev/udev.rules ]] + then + mv -f "${ROOT}"/etc/udev/udev.config "${ROOT}"/etc/udev/udev.rules + fi + + # delete the old udev.hotplug symlink if it is present + if [[ -h ${ROOT}/etc/hotplug.d/default/udev.hotplug ]] + then + rm -f "${ROOT}"/etc/hotplug.d/default/udev.hotplug + fi + + # delete the old wait_for_sysfs.hotplug symlink if it is present + if [[ -h ${ROOT}/etc/hotplug.d/default/05-wait_for_sysfs.hotplug ]] + then + rm -f "${ROOT}"/etc/hotplug.d/default/05-wait_for_sysfs.hotplug + fi + + # delete the old wait_for_sysfs.hotplug symlink if it is present + if [[ -h ${ROOT}/etc/hotplug.d/default/10-udev.hotplug ]] + then + rm -f "${ROOT}"/etc/hotplug.d/default/10-udev.hotplug + fi + + # is there a stale coldplug initscript? (CONFIG_PROTECT leaves it behind) + coldplug_stale="" + if [[ -f ${ROOT}/etc/init.d/coldplug ]] + then + coldplug_stale="1" + fi +} + +pkg_postinst() { + # people want reminders, I'll give them reminders. Odds are they will + # just ignore them anyway... + + if [[ ${coldplug_stale} == 1 ]] + then + ewarn "A stale coldplug init script found. You should run:" + ewarn + ewarn " rc-update del coldplug" + ewarn " rm -f /etc/init.d/coldplug" + ewarn + ewarn "udev now provides its own coldplug functionality." + fi + + # delete 40-scsi-hotplug.rules - all integrated in 50-udev.rules + if has_version "=sys-fs/udev-103-r3" && + [[ -e ${ROOT}/etc/udev/rules.d/40-scsi-hotplug.rules ]] + then + ewarn "Deleting stray 40-scsi-hotplug.rules" + ewarn "installed by sys-fs/udev-103-r3" + rm -f "${ROOT}"/etc/udev/rules.d/40-scsi-hotplug.rules + fi + + # Removing some device-nodes we thought we need some time ago + if [[ -d ${ROOT}/lib/udev/devices ]] + then + rm -f "${ROOT}"/lib/udev/devices/{null,zero,console,urandom} + fi + + # Removing some old file + if has_version "<sys-fs/udev-104-r5" + then + rm -f "${ROOT}"/etc/dev.d/net/hotplug.dev + rmdir --ignore-fail-on-non-empty "${ROOT}"/etc/dev.d/net 2>/dev/null + fi + + if has_version "<sys-fs/udev-106-r5" && + [[ -e ${ROOT}/etc/udev/rules.d/95-net.rules ]] + then + rm -f "${ROOT}"/etc/udev/rules.d/95-net.rules + fi + + # Try to remove /etc/dev.d as that is obsolete + if [[ -d ${ROOT}/etc/dev.d ]] + then + rmdir --ignore-fail-on-non-empty "${ROOT}"/etc/dev.d/default "${ROOT}"/etc/dev.d 2>/dev/null + if [[ -d ${ROOT}/etc/dev.d ]] + then + ewarn "You still have the directory /etc/dev.d on your system." + ewarn "This is no longer used by udev and can be removed." + fi + fi + + # 64-device-mapper.rules now gets installed by sys-fs/device-mapper + # remove it if user don't has sys-fs/device-mapper installed + if has_version "<sys-fs/udev-113" && + [[ -f ${ROOT}/etc/udev/rules.d/64-device-mapper.rules ]] && + ! has_version sys-fs/device-mapper + then + rm -f "${ROOT}"/etc/udev/rules.d/64-device-mapper.rules + einfo "Removed unneeded file 64-device-mapper.rules" + fi + + if [[ ${ROOT} == / ]] + then + # check if root of init-process is identical to ours + if [[ -r /proc/1/root && /proc/1/root/ -ef /proc/self/root/ ]] + then + einfo "restarting udevd now." + if [[ -n $(pidof udevd) ]] + then + killall -15 udevd &>/dev/null + sleep 1 + killall -9 udevd &>/dev/null + fi + /sbin/udevd --daemon + fi + fi + + ewarn "If you build an initramfs including udev, then please" + ewarn "make sure that the /sbin/udevadm binary gets included," + ewarn "as the helper apps udevinfo, udevtrigger, ... are now" + ewarn "only symlinks to udevadm." + + ewarn + ewarn "mount options for directory /dev are no longer" + ewarn "set in /etc/udev/udev.conf, but in /etc/fstab" + ewarn "as for other directories." + + elog + elog "For more information on udev on Gentoo, writing udev rules, and" + elog " fixing known issues visit:" + elog " http://www.gentoo.org/doc/en/udev-guide.xml" +} |