diff --git a/sys-fs/udev/files/171-r8/blacklist b/sys-fs/udev/files/171-r8/blacklist new file mode 100644 index 000000000..1a1ee584a --- /dev/null +++ b/sys-fs/udev/files/171-r8/blacklist @@ -0,0 +1,26 @@ +# This file lists modules which will not be loaded by udev, +# not at coldplugging and not on hotplug events. + +# Add your own entries to this file +# in the format "blacklist " + +# Some examples: +# evbug is a debug tool and should be loaded explicitly +blacklist evbug + +# Autoloading eth1394 most of the time re-orders your network +# interfaces, and with buggy kernel 2.6.21, udev persistent-net +# is not able to rename these devices, so you get eth?_rename devices +# plus an exceeded 30sec boot timeout +blacklist eth1394 + +# You probably want this to not get the console beep loud on every tab :) +#blacklist pcspkr + +# these drivers are very simple, the HID drivers are usually preferred +#blacklist usbmouse +#blacklist usbkbd + +# Sometimes loading a framebuffer driver at boot gets the console black +#install pci:v*d*sv*sd*bc03sc*i* /bin/true + diff --git a/sys-fs/udev/files/171-r8/move_tmp_persistent_rules.sh b/sys-fs/udev/files/171-r8/move_tmp_persistent_rules.sh new file mode 100755 index 000000000..c74fdb45c --- /dev/null +++ b/sys-fs/udev/files/171-r8/move_tmp_persistent_rules.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# Distributed under the terms of the GNU General Public License v2 + +. /etc/init.d/functions.sh + +# store persistent-rules that got created while booting +# when / was still read-only +store_persistent_rules() { + local file dest + local ruledir="$(udevadm info --run)" + [ ! -d "$ruledir" ] && return 0 + for file in $ruledir/tmp-rules--*; do + dest=${file##*tmp-rules--} + [ "$dest" = '*' ] && break + type=${dest##70-persistent-} + type=${type%%.rules} + ebegin "Saving udev persistent ${type} rules to /etc/udev/rules.d" + cat "$file" >> /etc/udev/rules.d/"$dest" && rm -f "$file" + eend $? "Failed moving persistent rules!" + done +} + +store_persistent_rules + +# vim:ts=4 diff --git a/sys-fs/udev/files/171-r8/net.sh b/sys-fs/udev/files/171-r8/net.sh new file mode 100755 index 000000000..af61870d8 --- /dev/null +++ b/sys-fs/udev/files/171-r8/net.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# +# net.sh: udev external RUN script +# +# Copyright 2007 Roy Marples +# Distributed under the terms of the GNU General Public License v2 + +IFACE=$1 +ACTION=$2 + +SCRIPT=/etc/init.d/net.$IFACE + +# ignore interfaces that are registered after being "up" (?) +case ${IFACE} in + ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*|br*) + exit 0 ;; +esac + +# stop here if coldplug is disabled, Bug #206518 +if [ "${do_not_run_plug_service}" = 1 ]; then + exit 0 +fi + +if [ ! -x "${SCRIPT}" ] ; then + #do not flood log with messages, bug #205687 + #logger -t udev-net.sh "${SCRIPT}: does not exist or is not executable" + exit 1 +fi + +# If we're stopping then sleep for a bit in-case a daemon is monitoring +# the interface. This to try and ensure we stop after they do. +[ "${ACTION}" == "stop" ] && sleep 2 + +IN_HOTPLUG=1 "${SCRIPT}" --quiet "${ACTION}" diff --git a/sys-fs/udev/files/171-r8/pnp-aliases b/sys-fs/udev/files/171-r8/pnp-aliases new file mode 100644 index 000000000..3675fbbc6 --- /dev/null +++ b/sys-fs/udev/files/171-r8/pnp-aliases @@ -0,0 +1,17 @@ +# /etc/modprobe.d/pnp-aliases +# +# These aliases are used by this udev-rule: +# SUBSYSTEM=="pnp", ENV{MODALIAS}!="?*", RUN+="/bin/sh -c '/sbin/modprobe -a $$(while read id; do echo pnp:d$$id; done < /sys$devpath/id)'" +# +# They should help to autoload drivers used by various pnp-devices +# (if not blacklisted somewhere else) +# +alias pnp:dPNP0510 irtty-sir +alias pnp:dPNP0511 irtty-sir +alias pnp:dPNP0700 floppy +alias pnp:dPNP0800 pcspkr +alias pnp:dPNP0b00 rtc +alias pnp:dPNP0303 atkbd +alias pnp:dPNP0f13 psmouse +alias pnp:dPNPb02f analog + diff --git a/sys-fs/udev/files/171-r8/shell-compat-addon.sh b/sys-fs/udev/files/171-r8/shell-compat-addon.sh new file mode 100644 index 000000000..c271abfd5 --- /dev/null +++ b/sys-fs/udev/files/171-r8/shell-compat-addon.sh @@ -0,0 +1,71 @@ +# Copyright 1999-2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +# functions that may not be defined, but are used by the udev-start and udev-stop addon +# used by baselayout-1 and openrc before version 0.4.0 + +cmd_exist() +{ + type "$1" >/dev/null 2>&1 +} + +# does not exist in baselayout-1, does exist in openrc +if ! cmd_exist yesno; then + yesno() { + [ -z "$1" ] && return 1 + case "$1" in + yes|Yes|YES) return 0 ;; + esac + return 1 + } +fi + +# does not exist in baselayout-1, does exist in openrc +# +# mountinfo +# check if some filesystem is mounted at mountpoint +# +# return value: +# 0 filesystem is mounted at +# 1 no filesystem is mounted exactly at +if ! cmd_exist mountinfo; then + mountinfo() { + [ "$1" = "-q" ] && shift + local dir="$1" + + # check if entry is in /proc/mounts + local ret=$(gawk 'BEGIN { found="false"; } + $1 ~ "^#" { next } + $2 == "'$dir'" { found="true"; } + END { print found; } + ' /proc/mounts) + + "${ret}" + } +fi + +# does not exist in baselayout-1, does exist in openrc +# +# used syntax: fstabinfo --mount /dev +# it should mount /dev if an entry exists in /etc/fstab +# +# return value: +# 0 mount succeeded +# 1 mount failed or no entry exists +# +if ! cmd_exist fstabinfo; then + fstabinfo() { + [ "$1" = "--mount" ] || return 1 + local dir="$2" + + # RC_USE_FSTAB does only exist in baselayout-1 + # this emulation is only needed on bl-1, so check always + yesno "${RC_USE_FSTAB}" || return 1 + + # no need to check fstab, mount does this already for us + + # try mounting - better first check fstab and then mount without surpressing errors + mount -n "${dir}" 2>/dev/null + return $? + } +fi diff --git a/sys-fs/udev/files/171-r8/shell-compat.sh b/sys-fs/udev/files/171-r8/shell-compat.sh new file mode 100644 index 000000000..9d852dbe8 --- /dev/null +++ b/sys-fs/udev/files/171-r8/shell-compat.sh @@ -0,0 +1,71 @@ +# 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 + fstabinfo() { + [ "$1" = "--quiet" ] && shift + local dir="$1" + + # only check RC_USE_FSTAB on baselayout-1 + if [ ! -e /lib/librc.so ]; then + yesno "${RC_USE_FSTAB}" || return 1 + fi + + # check if entry is in /etc/fstab + local ret=$(gawk 'BEGIN { found="false"; } + $1 ~ "^#" { next } + $2 == "'$dir'" { found="true"; } + END { print found; } + ' /etc/fstab) + + "${ret}" + } +fi + diff --git a/sys-fs/udev/files/171-r8/udev-mount.initd b/sys-fs/udev/files/171-r8/udev-mount.initd new file mode 100755 index 000000000..083669994 --- /dev/null +++ b/sys-fs/udev/files/171-r8/udev-mount.initd @@ -0,0 +1,91 @@ +#!/sbin/runscript +# Copyright 1999-2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +description="Mount /dev and let udev create the device-nodes" + +depend() +{ + keyword -openvz -vserver -lxc + provide dev + need sysfs + before checkfs fsck +} + +start() { + if [ "$(cat /proc/mounts | cut -f2 -d" " | grep "^/dev$")" != "" ] + then + einfo "udev: /dev already mounted, skipping..." + return + fi + if [ -e /etc/conf.d/udev ] + then + . /etc/conf.d/udev + fi + + ebegin "udev: Mounting /dev" + if fstabinfo --quiet /dev; then + # if defined in /etc/fstab, use those options: + mount -n /dev + else + # otherwise, automatically mount using these options: + # Some devices require exec, Bug #92921 + mount -n -t tmpfs -o "exec,nosuid,mode=0755,size=10M" udev /dev + fi + eend $? + + touch /dev/.rcsysinit + + # SELINUX STUFF + + if [ -x /sbin/restorecon -a -c /selinux/null ]; then + restorecon /dev > /selinux/null + fi + + # DEVICE TARBALL STUFF + + local tarball_file=/lib/udev/state/devices.tar.bz2 + if yesno "${device_tarball}" && [ -s "${tarball_file}" ] + then + ebegin "udev: Populating /dev with saved device nodes" + tar xpf "${tarball_file}" -C /dev + eend $? + fi + + # copy over any persistant things + if [ -d /lib/udev/devices ]; then + cp -RPp /lib/udev/devices/* /dev 2>/dev/null + fi + + # Create problematic directories + mkdir -p /dev/pts /dev/shm + + if [ -e /proc/sys/kernel/hotplug ]; then + echo "" >/proc/sys/kernel/hotplug + fi + + if [ -e /lib/udev/write_root_link_rule ] + then + /lib/udev/write_root_link_rule + else + /lib/udev/write_root_link_rule + fi + + # this function disables rules files + # by creating new files with the same name + # in a temp rules directory with higher priority + local d=/dev/.udev/rules.d + if yesno "${persistent_net:-yes}"; then + ewarn "udev: Persistent network rules enabled in /etc/conf.d/udev" + else + mkdir -p "$d" + echo "# This file disables persistent-net due to /etc/conf.d/udev" > "$d"/75-persistent-net-generator.rules + fi + + # load unix domain sockets if built as module, Bug #221253 + if [ -e /proc/modules ] ; then + modprobe -q unix 2>/dev/null + fi + + return 0 +} diff --git a/sys-fs/udev/files/171-r8/udev-postmount.initd b/sys-fs/udev/files/171-r8/udev-postmount.initd new file mode 100755 index 000000000..ea030c4db --- /dev/null +++ b/sys-fs/udev/files/171-r8/udev-postmount.initd @@ -0,0 +1,27 @@ +#!/sbin/runscript +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-fs/udev/files/udev-postmount-130-r2.initd,v 1.1 2008/10/28 21:59:05 zzam Exp $ + +depend() { + keyword -openvz -vserver -lxc + need udev-mount localmount +} + +start() { + # check if this system uses udev + [ -d /dev/.udev/ ] || return 0 + + ebegin "udev: storing persistent rules" + + # store persistent-rules that got created while booting + # when / was still read-only + /lib/udev/move_tmp_persistent_rules.sh + eend $? +} + +stop() { + : +} + +# vim:ts=4 diff --git a/sys-fs/udev/files/171-r8/udev-save.initd b/sys-fs/udev/files/171-r8/udev-save.initd new file mode 100755 index 000000000..4d851146d --- /dev/null +++ b/sys-fs/udev/files/171-r8/udev-save.initd @@ -0,0 +1,86 @@ +#!/sbin/runscript +# Copyright 1999-2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +description="Save device nodes to a persistent tarball" + +depend() +{ + keyword -openvz -vserver -lxc + before mount-ro killprocs +} + +start() { + /lib/udev/move_tmp_persistent_rules.sh + tarball_file=/lib/udev/state/devices.tar.bz2 + if [ -e /etc/conf.d/udev ] + then + . /etc/conf.d/udev + fi + device_tarball=${device_tarball:-${RC_DEVICE_TARBALL:-NO}} + if ! yesno "${device_tarball}" + then + ebegin "udev: Device tarball disabled, skipping" + eend 0 + return 0 + fi + ebegin "Saving device nodes" + if ! touch "${tarball_file}" + then + eend 1 "udev: Couldn't write to device tarball." + return 1 + fi + if [ -e /dev/.devfsd ] || [ ! -e /dev/.udev ] + then + eend 1 "udev: Device tarball enabled but udev filesystem not found" + fi + + # 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 + eend 1 "udev: Couldn't create temporary files for device tarball" + return 1 + fi + + 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 + udevadm info --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}" "${tarball_file}" + else + rm -f "${tarball_file}" + fi + eend 0 + einfo "udev: Device tarball created." +} diff --git a/sys-fs/udev/files/171-r8/udev.confd b/sys-fs/udev/files/171-r8/udev.confd new file mode 100644 index 000000000..310cf020f --- /dev/null +++ b/sys-fs/udev/files/171-r8/udev.confd @@ -0,0 +1,25 @@ +# /etc/conf.d/udev: config file for udev + +# Coldplug should be enabled for proper hardware detection and +# module-autoloading. Normally, you will want this enabled. If +# you need to disable it temporarily, you can either do so +# below or use the "nocoldplug" kernel boot option. + +coldplug="yes" + +# Persistent_net will ensure that your network interface names +# don't change. However, it can be disabled if you are planning +# to change your hardware. This will prevent your new hardware +# from showing up as eth1, eth2, etc. Some people prefer it +# disabled. Recommended enabled unless you prefer otherwise. + +persistent_net="yes" + +# If you set the device_tarball option to yes, then +# prior to system shutdown, the state of /dev will be backed up +# to an archive and restored when your system boots. This is +# useful if you need to manually create device nodes and don't +# want to keep repeating yourself. Disabled by default. + +device_tarball="no" + diff --git a/sys-fs/udev/files/171-r8/udevd.initd b/sys-fs/udev/files/171-r8/udevd.initd new file mode 100755 index 000000000..0bec273ed --- /dev/null +++ b/sys-fs/udev/files/171-r8/udevd.initd @@ -0,0 +1,72 @@ +#!/sbin/runscript +# Copyright 1999-2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() { + keyword -openvz -vserver + need udev-mount + before checkfs fsck +} + +start() { + ebegin "Starting udevd daemon" + start-stop-daemon --start --exec /sbin/udevd -- --daemon + if [ $? -ne 0 ] + then + eend 1 + return 1 + fi + + # By default, we want coldplug enabled. "coldplug" means that + # udev will scan the system for already-connected hardware and + # generate synthetic/pretend connection events, which will help + # to load the correct modules, when, for example, you try to + # bring up your eth0 interface and it depends on a module that + # is not currently loaded. + + local coldplug="yes" + + if [ -e /etc/conf.d/udev ] + then + . /etc/conf.d/udev + fi + + # coldplug can be disabled by the "nocoldplug" kernel boot + # parameter. + + if get_bootparam "nocoldplug" ; then + coldplug="NO" + ewarn "Skipping udev coldplug as requested in kernel cmdline" + fi + + ebegin "Populating /dev with existing devices through uevents" + if yesno "${coldplug}"; then + # perform full coldplug: + udevadm trigger + else + # do not perform a full coldplug: + # Do not run any init-scripts, Bug #206518 + udevadm control --env do_not_run_plug_service=1 + # only create device nodes + udevadm trigger --attr-match=dev + # run persistent-net stuff, bug 191466 + udevadm trigger --subsystem-match=net + fi + udevadm settle --timeout=60 + eend $? + + udevadm control --env do_not_run_plug_service= + # should exist on every system, else udev failed + if [ ! -e /dev/zero ]; then + eerror "Assuming udev failed somewhere, as /dev/zero does not exist." + return 1 + fi + return 0 + +} + +stop() { + ebegin "Stopping udevd daemon" + start-stop-daemon --stop /sbin/udevd + eend $? +} diff --git a/sys-fs/udev/files/171-r8/write_root_link_rule b/sys-fs/udev/files/171-r8/write_root_link_rule new file mode 100755 index 000000000..8eaea1176 --- /dev/null +++ b/sys-fs/udev/files/171-r8/write_root_link_rule @@ -0,0 +1,29 @@ +#!/bin/sh +# +# This script should run before doing udevtrigger at boot. +# It will create a rule matching the device directory / is on, and +# creating /dev/root symlink pointing on its device node. +# +# This is especially useful for hal looking at /proc/mounts containing +# a line listing /dev/root as device: +# /dev/root / reiserfs rw 0 0 +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation version 2 of the License. +# +# (c) 2007-2008 Matthias Schwarzott + +eval $(udevadm info --export --export-prefix="ROOT_" --device-id-of-file=/) + +[ $? = 0 ] || exit 0 +[ "$ROOT_MAJOR" = 0 ] && exit 0 + +DIR=/dev/.udev/rules.d +[ -d "$DIR" ] || mkdir -p "$DIR" +RULES=$DIR/10-root-link.rules + +echo "# Created by /lib/udev/write_root_link_rule" > "${RULES}" +echo "# This rule should create /dev/root as link to real root device." >> "${RULES}" +echo "SUBSYSTEM==\"block\", ENV{MAJOR}==\"$ROOT_MAJOR\", ENV{MINOR}==\"$ROOT_MINOR\", SYMLINK+=\"root\"" >> "${RULES}" + diff --git a/sys-fs/udev/udev-171-r8.ebuild b/sys-fs/udev/udev-171-r8.ebuild new file mode 100644 index 000000000..f6925ca92 --- /dev/null +++ b/sys-fs/udev/udev-171-r8.ebuild @@ -0,0 +1,262 @@ +# Distributed under the terms of the GNU General Public License v2 + +EAPI="1" + +inherit eutils flag-o-matic multilib toolchain-funcs linux-info +DESCRIPTION="Linux dynamic and persistent device naming support (aka userspace devfs)" +HOMEPAGE="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html" +#PATCHSET="${P}-gentoo-patchset-v1" +SRC_URI="mirror://kernel/linux/utils/kernel/hotplug/${P}.tar.bz2" + +if [ -n "$PATCHSET" ] +then + SRC_URI="$SRC_URI mirror://gentoo/${PATCHSET}.tar.bz2" +fi + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="*" +IUSE="selinux extras keymap +hwdb +gudev introspection" +MIN_KERNEL="2.6.32" + +COMMON_DEPEND="selinux? ( sys-libs/libselinux ) + virtual/libusb:0 + extras? ( sys-apps/acl dev-libs/gobject-introspection dev-libs/glib:2 ) + gudev? ( dev-libs/glib:2 ) + introspection? ( dev-libs/gobject-introspection ) + hwdb? ( sys-apps/hwids )" +DEPEND="${COMMON_DEPEND} + dev-util/gperf >=sys-kernel/linux-headers-2.6.34 + keymap? ( dev-util/gperf )" +RDEPEND="${COMMON_DEPEND} !sys-apps/coldplug !=sys-apps/baselayout-2.1.6" +PROVIDE="virtual/dev-manager" + +pkg_setup() { + udev_libexec_dir="/$(get_libdir)/udev" + [ "$ROOT" != "/" ] && return 0 + local fkv="$(uname -r)" + local kv="${fkv%-*}" + local k2="${kv%.*}" + local kmin="${kv##*.}" + echo $USE + if ! use bindist && [ "$k2" == "2.6" ] && [ "$kmin" -lt ${MIN_KERNEL##*.} ] && [ "${FEATURES/safetydance/}" = "${FEATURES}" ] + then + eerror + eerror "Current kernel version: $kv" + eerror "Minimum kernel version: ${MIN_KERNEL}" + eerror + ewarn "You are installing a version of udev that is incompatible with your" + ewarn "currently-running kernel. This version of udev requires a kernel" + ewarn "version of ${MIN_KERNEL} or greater. Please use an earlier version of udev" + ewarn "with your running kernel by masking this version of udev, by adding" + ewarn "the following line to /etc/portage/package.mask:" + ewarn + ewarn ">=sys-fs/udev-160" + ewarn + ewarn "Alternatively, you may choose to upgrade to a compatible kernel, update" + ewarn "your boot loader and reboot your system so that the new kernel is" + ewarn "active. Then this version of udev will be compatible with your kernel" + ewarn "and the udev merge will then proceed without warning." + ewarn + ewarn "If you know what you are doing and want to override this safety check," + ewarn "add 'safetydance' to FEATURES as follows:" + ewarn + ewarn "FEATURES=\"safetydance\" emerge " + ewarn + ewarn "This will cause this runtime safety check to be skipped." + die + fi + return 0 +} + +src_unpack() { + unpack ${A} + + cd "${S}" + if [ -n "$PATCHSET" ] + then + EPATCH_SOURCE="${WORKDIR}/${PATCHSET}" EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" epatch + fi + + # change rules back to group uucp instead of dialout for now - eventually + # fix baselayout - + + sed -e 's/GROUP="dialout"/GROUP="uucp"/' -i rules/{rules.d,arch}/*.rules || die "failed to change group dialout to uucp" +} + +use_extras() { use extras && echo "--enable-${2:-$1}" || use_enable "$@" ; } +src_compile() { + filter-flags -fprefetch-loop-arrays + + # sys-fs/lvm2 may require static libs - generate them just to be on the safe + # side. shared libs get generated too. + + echo $(use_extras introspection) + + econf \ + --prefix=/usr \ + --sysconfdir=/etc \ + --enable-static \ + --sbindir=/sbin \ + --libdir=/usr/$(get_libdir) \ + --with-rootlibdir=/$(get_libdir) \ + --libexecdir="${udev_libexec_dir}" \ + --enable-logging \ + --enable-hwdb \ + --disable-udev_acl \ + --with-pci-ids-path="${EPREFIX}/usr/share/misc/pci.ids" \ + --with-usb-ids-path="${EPREFIX}/usr/share/misc/usb.ids" \ + $(use_extras introspection) \ + $(use_extras gudev) \ + $(use_extras keymap) \ + $(use_enable extras) \ + $(use_with selinux) + + emake || die "compiling udev failed" +} + +src_install() { + into / + emake DESTDIR="${D}" install || die "make install failed" + + exeinto "${udev_libexec_dir}" + local x + for x in net.sh move_tmp_persistent_rules.sh write_root_link_rule shell-compat.sh shell-compat-addon.sh + do + doexe "${FILESDIR}/${PVR}/${x}" || die "${x} not installed properly" + done + + keepdir "${udev_libexec_dir}"/state + keepdir "${udev_libexec_dir}"/devices + + # Use Funtoo's "realdev" command to create initial set of device nodes in + # /lib/udev/devices. This set of device nodes will be copied to /dev when + # udev starts. + + $ROOT/sbin/realdev ${D}${udev_libexec_dir}/devices || die + + # create symlinks for these utilities to /sbin + # where multipath-tools expect them to be (Bug #168588) + dosym "..${udev_libexec_dir}/vol_id" /sbin/vol_id + dosym "..${udev_libexec_dir}/scsi_id" /sbin/scsi_id + + # Add gentoo stuff to udev.conf + echo "# If you need to change mount-options, do it in /etc/fstab" >> "${D}"/etc/udev/udev.conf + + # let the dir exist at least + keepdir /etc/udev/rules.d + + # Now installing rules + cd "${S}"/rules + insinto "${udev_libexec_dir}"/rules.d/ + + # Adding arch specific rules + if [[ -f packages/40-${ARCH}.rules ]] + then + doins "packages/40-${ARCH}.rules" + fi + cd "${S}" + + # The udev-post init-script + local x + for x in udevd udev-save udev-mount udev-postmount + do + newinitd "${FILESDIR}"/${PVR}/${x}.initd ${x} || die "initscript $x install error" + done + + newconfd "${FILESDIR}/${PVR}/udev.confd" udev || die "udev.confd install error" + + insinto /etc/modprobe.d + newins "${FILESDIR}/${PVR}/blacklist" blacklist.conf + newins "${FILESDIR}/${PVR}/pnp-aliases" pnp-aliases.conf + + # keep doc in just one directory, Bug #281137 + rm -rf "${D}/usr/share/doc/${PN}" + if use keymap; then + dodoc extras/keymap/README.keymap.txt || die "failed installing docs" + fi + + echo "CONFIG_PROTECT_MASK=\"/etc/udev/rules.d\"" > 20udev + doenvd 20udev +} + +modfix() { + local mod + + # We want to move any old modprobe.d conf files to the new file name so + # config file protection works correctly. + + for mod in blacklist pnp-aliases + do + if [ -e $ROOT/etc/modprobe.d/$mod ] + then + mv $ROOT/etc/modprobe.d/$mod $ROOT/etc/modprobe.d/${mod}.conf || die "mv failed" + fi + done +} + +pkg_preinst() { + modfix + + 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 + + rm -f /etc/conf.d/udev #FORCE UPDATE +} + +# from the openrc-0.3.0.22081113 ebuild :) +add_init() { + local runl=$1 + if [ ! -e ${ROOT}/etc/runlevels/${runl} ] + then + install -d -m0755 ${ROOT}/etc/runlevels/${runl} + fi + for initd in $* + do + # if the initscript is not going to be installed and is not currently installed, return + [[ -e ${D}/etc/init.d/${initd} || -e ${ROOT}/etc/init.d/${initd} ]] || continue + [[ -e ${ROOT}/etc/runlevels/${runl}/${initd} ]] && continue + elog "Auto-adding '${initd}' service to your ${runl} runlevel" + ln -snf /etc/init.d/${initd} "${ROOT}"/etc/runlevels/${runl}/${initd} + done +} + +pkg_postinst() { + # disable coldplug script + rm -f $ROOT/etc/runlevels/*/coldplug + + # disable any old udev script + rm -f $ROOT/etc/runlevels/*/udev + + rm -f $ROOT/etc/runlevels/*/udev-postmount + + add_init sysinit udev-mount + add_init sysinit udevd + add_init boot udev-postmount + add_init shutdown udev-save + + # requested in Bug #225033: + elog + elog "persistent-net does assigning fixed names to network devices." + elog "If you prefer to disable persistent-net, this can be done via" + elog "/etc/conf.d/udev." + + 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" +}