Skip to content

Commit

Permalink
[FL-242] keymap USE flag for udev
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanfrancisroy committed Nov 29, 2012
1 parent 54c92be commit 1d9cf50
Show file tree
Hide file tree
Showing 13 changed files with 836 additions and 0 deletions.
26 changes: 26 additions & 0 deletions 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 <name of module>"

# 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

25 changes: 25 additions & 0 deletions 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
34 changes: 34 additions & 0 deletions sys-fs/udev/files/171-r8/net.sh
@@ -0,0 +1,34 @@
#!/bin/sh
#
# net.sh: udev external RUN script
#
# Copyright 2007 Roy Marples <uberlord@gentoo.org>
# 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}"
17 changes: 17 additions & 0 deletions 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

71 changes: 71 additions & 0 deletions 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 <path>
# check if some filesystem is mounted at mountpoint <path>
#
# return value:
# 0 filesystem is mounted at <path>
# 1 no filesystem is mounted exactly at <path>
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
71 changes: 71 additions & 0 deletions 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

91 changes: 91 additions & 0 deletions 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
}
27 changes: 27 additions & 0 deletions 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

0 comments on commit 1d9cf50

Please sign in to comment.