diff options
author | root <root@rshg047.dnsready.net> | 2011-05-20 22:47:13 +0000 |
---|---|---|
committer | root <root@rshg047.dnsready.net> | 2011-05-20 22:47:13 +0000 |
commit | 6cf70d41be9abf69b6d19fbb4ce665c76db3a6c6 (patch) | |
tree | d0e12dbaa2cb07b6209b58bddf0943ba8f22bb07 /testing/udev | |
parent | e2fe79d62643f0e50b1c5e194a94cb510b371cc8 (diff) |
Fri May 20 22:47:13 UTC 2011
Diffstat (limited to 'testing/udev')
-rw-r--r-- | testing/udev/80-drivers.rules | 14 | ||||
-rw-r--r-- | testing/udev/81-arch.rules | 114 | ||||
-rw-r--r-- | testing/udev/PKGBUILD | 102 | ||||
-rwxr-xr-x | testing/udev/load-modules.sh | 80 | ||||
-rw-r--r-- | testing/udev/udev.install | 49 |
5 files changed, 359 insertions, 0 deletions
diff --git a/testing/udev/80-drivers.rules b/testing/udev/80-drivers.rules new file mode 100644 index 000000000..56ac06cb4 --- /dev/null +++ b/testing/udev/80-drivers.rules @@ -0,0 +1,14 @@ +# do not edit this file, it will be overwritten on update + +ACTION=="remove", GOTO="drivers_end" + +DRIVER!="?*", ENV{MODALIAS}=="?*", RUN+="/lib/udev/load-modules.sh $env{MODALIAS}" +SUBSYSTEM=="tifm", ENV{TIFM_CARD_TYPE}=="SD", RUN+="/lib/udev/load-modules.sh tifm_sd" +SUBSYSTEM=="tifm", ENV{TIFM_CARD_TYPE}=="MS", RUN+="/lib/udev/load-modules.sh tifm_ms" +SUBSYSTEM=="memstick", RUN+="/lib/udev/load-modules.sh ms_block" +SUBSYSTEM=="memstick", RUN+="/lib/udev/load-modules.sh mspro_block" +SUBSYSTEM=="i2o", RUN+="/lib/udev/load-modules.sh i2o_block" +SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", TEST!="[module/sg]", RUN+="/lib/udev/load-modules.sh sg" +SUBSYSTEM=="module", KERNEL=="parport_pc", RUN+="/lib/udev/load-modules.sh ppdev" + +LABEL="drivers_end" diff --git a/testing/udev/81-arch.rules b/testing/udev/81-arch.rules new file mode 100644 index 000000000..3e71a9118 --- /dev/null +++ b/testing/udev/81-arch.rules @@ -0,0 +1,114 @@ +# Udev rules for Archlinux by Tobias Powalowski <tpowa@archlinux.org> +# do not edit this file, it will be overwritten on update +# +# There are a number of modifiers that are allowed to be used in some +# of the different fields. They provide the following subsitutions: +# +# %n the "kernel number" of the device. +# For example, 'sda3' has a "kernel number" of '3' +# %k the kernel name for the device. +# %M the kernel major number for the device +# %m the kernel minor number for the device +# %b the bus id for the device +# %c the string returned by the PROGRAM +# %s{filename} the content of a sysfs attribute. +# %% the '%' char itself. +# +# There are a number of modifiers that are allowed to be used in some of the +# fields. See the udev man page for a full description of them. +# global stuff +# + +##################################### +###### Hotplug rules - begin +# Only additional modules, +# which are not detectable, +# are loaded here! +##################################### +# check if the device has already been claimed by a driver +ACTION!="add", GOTO="drivers_end" + +#PNP addon modules +SUBSYSTEM=="pnp", ENV{MODALIAS}!="?*", ATTRS{id}=="PNP0800", RUN+="/lib/udev/load-modules.sh pcspkr" +SUBSYSTEM=="pnp", ENV{MODALIAS}!="?*", ATTRS{id}=="*PNP051[01]*", RUN+="/lib/udev/load-modules.sh irtty-sir" +SUBSYSTEM=="pnp", ENV{MODALIAS}!="?*", ATTRS{id}=="PNPb02f", RUN+="/lib/udev/load-modules.sh analog" + +# PARPORT addon modules +SUBSYSTEM=="pnp", ENV{MODALIAS}!="?*", ATTRS{id}=="PNP040*", RUN+="/lib/udev/load-modules.sh lp" +SUBSYSTEM=="pnp", ENV{MODALIAS}!="?*", ATTRS{id}=="PNP040*", RUN+="/lib/udev/load-modules.sh ppdev" + +# fix ide cdrom detection on old proliant servers +SUBSYSTEM=="pci", ENV{MODALIAS}=="pci:v00000E11d00000001sv00000000sd00000000bc06sc02i00", RUN+="/lib/udev/load-modules.sh ide-generic" + +LABEL="drivers_end" +##################################### +##### Hotplug rules - end +##################################### + +##################################### +# Additional Archlinux +# Permissions and Symlinks - begin +##################################### + +# permission for sg devices +KERNEL=="sg[0-9]*", ATTRS{type}!="3|6", GROUP="disk", MODE="0660" + +# permissions for IDE CD devices +SUBSYSTEMS=="ide", KERNEL=="hd[a-z]", ATTR{removable}=="1", ATTRS{media}=="cdrom*", GROUP="optical" + +# permissions for SCSI CD devices +SUBSYSTEMS=="scsi", KERNEL=="sr[0-9]*", ATTRS{type}=="5", SYMLINK+="scd%n", GROUP="optical" +SUBSYSTEMS=="scsi", KERNEL=="sg[0-9]*", ATTRS{type}=="5", GROUP="optical" + +# permissions for removable devices like cardreaders or sticks +KERNEL=="sd*", ATTRS{scsi_level}=="3", ATTRS{type}=="0", GROUP="storage" + +# permissions for firewire external drives +KERNEL=="sd*", ATTRS{scsi_level}=="5", GROUP="storage" + +# permissions for usb to scsi external adapters +KERNEL=="sd*", ATTRS{scsi_level}=="3", ATTRS{type}=="7", GROUP="storage" + +# permissions for ide storage like pcmcia card readers +ACTION!="add", GOTO="pcmcia_end" +SUBSYSTEM!="block", GOTO="pcmcia_end" +KERNEL=="hd*[!0-9]", IMPORT{program}="ata_id --export $tempnode" +KERNEL=="hd*", IMPORT{parent}=="ID_*" +KERNEL=="hd*", ENV{ID_TYPE}=="generic", GROUP="storage" +LABEL="pcmcia_end" + +# permissions for SCSI scanners +SUBSYSTEMS=="scsi", KERNEL=="sg[0-9]*", ATTRS{type}=="6", GROUP="scanner" + +# mem +KERNEL=="ram0", SYMLINK+="ramdisk" +KERNEL=="ram1", SYMLINK+="ram" + +# video4linux + +KERNEL=="vbi0", SYMLINK+="vbi" +KERNEL=="radio0", SYMLINK+="radio" +KERNEL=="radio[0-9]*", GROUP="video" +KERNEL=="video0", SYMLINK+="video" +KERNEL=="vtx0", SYMLINK+="vtx" + +# video devices +### xorg resets those permissions, adjust your xorg.conf! +KERNEL=="3dfx*", GROUP="video" +KERNEL=="fb[0-9]*", GROUP="video" + +# misc +KERNEL=="sgi_fetchop", MODE="0666" +KERNEL=="sonypi", MODE="0666" + +# USB devices +KERNEL=="legousbtower*", MODE="0666" + +# kbd devices +KERNEL=="kbd", MODE="0664" + +# miscellaneous +KERNEL=="rtc|rtc0", GROUP="audio", MODE="0664" +####################################### +# Permissions and Symlinks - end +####################################### diff --git a/testing/udev/PKGBUILD b/testing/udev/PKGBUILD new file mode 100644 index 000000000..26d06b7e2 --- /dev/null +++ b/testing/udev/PKGBUILD @@ -0,0 +1,102 @@ +# $Id: PKGBUILD 124322 2011-05-19 15:55:28Z tomegun $ +# Maintainer: Aaron Griffin <aaron@archlinux.org> +# Maintainer: Tobias Powalowski <tpowa@archlinux.org> +# Maintainer: Thomas Bächler <thomas@archlinux.org> +# Maintainer: Tom Gundersen <teg@jklm.no> + +pkgbase="udev" +pkgname=('udev' 'udev-compat') +pkgver=169 +pkgrel=1 +arch=(i686 x86_64) +url="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html" +license=('GPL') +groups=('base') +# older initscripts versions required start_udev +options=(!makeflags !libtool) +makedepends=('glibc' 'coreutils' 'util-linux' 'pciutils' 'libusb-compat' 'glib2' 'kernel26' 'gperf' 'libxslt' 'gobject-introspection') +source=(http://www.kernel.org/pub/linux/utils/kernel/hotplug/$pkgbase-$pkgver.tar.bz2 + 80-drivers.rules + 81-arch.rules + load-modules.sh) + +build() { + cd $srcdir/$pkgbase-$pkgver + ./configure --sysconfdir=/etc --with-rootlibdir=/lib --libexecdir=/lib/udev\ + --sbindir=/sbin --with-systemdsystemunitdir=/lib/systemd/system\ + --disable-rule-generator + make +} + +package_udev() { + pkgdesc="The userspace dev tools (udev)" + depends=('glibc' 'coreutils' 'util-linux' 'libusb-compat' 'glib2' + 'module-init-tools>=3.11' 'pciutils') + install=udev.install + backup=(etc/udev/udev.conf + etc/modprobe.d/framebuffer_blacklist.conf) + conflicts=('pcmcia-cs' 'hotplug' 'initscripts<2009.07') + replaces=('devfsd') + + cd $srcdir/$pkgbase-$pkgver + make DESTDIR=${pkgdir} install + # Replace original 80-drivers.rules with custom one. + install -D -m644 $srcdir/80-drivers.rules $pkgdir/lib/udev/rules.d/80-drivers.rules + # Install our rule for permissions and symlinks + install -D -m644 $srcdir/81-arch.rules $pkgdir/lib/udev/rules.d/81-arch.rules + # install our module loading subsystem + install -D -m755 $srcdir/load-modules.sh $pkgdir/lib/udev/load-modules.sh + + # create framebuffer blacklist + mkdir -p $pkgdir/etc/modprobe.d/ + for mod in $(find /lib/modules/*/kernel/drivers/video -name '*fb.ko.gz' -exec basename {} .ko.gz \;); do + echo "blacklist $mod" + done | sort -u > $pkgdir/etc/modprobe.d/framebuffer_blacklist.conf + + # create static devices in /lib/udev/devices/ + mkdir ${pkgdir}/lib/udev/devices/pts + mkdir ${pkgdir}/lib/udev/devices/shm + + mknod -m 0600 ${pkgdir}/lib/udev/devices/console c 5 1 + mknod -m 0666 ${pkgdir}/lib/udev/devices/null c 1 3 + mknod -m 0660 ${pkgdir}/lib/udev/devices/zero c 1 5 + mknod -m 0666 ${pkgdir}/lib/udev/devices/kmsg c 1 11 + + ln -snf /proc/self/fd ${pkgdir}/lib/udev/devices/fd + ln -snf /proc/self/fd/0 ${pkgdir}/lib/udev/devices/stdin + ln -snf /proc/self/fd/1 ${pkgdir}/lib/udev/devices/stdout + ln -snf /proc/self/fd/2 ${pkgdir}/lib/udev/devices/stderr + ln -snf /proc/kcore ${pkgdir}/lib/udev/devices/core + + # these static devices are created for convenience, to autoload the modules if necessary + # /dev/loop0 + mknod -m 0660 ${pkgdir}/lib/udev/devices/loop0 b 7 0 + chgrp disk ${pkgdir}/lib/udev/devices/loop0 + # /dev/net/tun + mkdir ${pkgdir}/lib/udev/devices/net + mknod -m 0666 ${pkgdir}/lib/udev/devices/net/tun c 10 200 + # /dev/fuse + mknod -m 0666 ${pkgdir}/lib/udev/devices/fuse c 10 229 + # /dev/ppp + mknod -m 0600 ${pkgdir}/lib/udev/devices/ppp c 108 0 + + # Replace dialout/tape/cdrom group in rules with uucp/storage/optical group + for i in $pkgdir/lib/udev/rules.d/*.rules; do + sed -i -e 's#GROUP="dialout"#GROUP="uucp"#g; + s#GROUP="tape"#GROUP="storage"#g; + s#GROUP="cdrom"#GROUP="optical"#g' $i + done +} + +package_udev-compat() { + pkgdesc="The userspace dev tools (udev) - additional rules for older kernels" + depends=('udev') + groups=('') + cd $srcdir/$pkgbase-$pkgver + install -d -m755 ${pkgdir}/lib/${pkgbase}/rules.d + install -D -m644 ${srcdir}/${pkgbase}-${pkgver}/rules/misc/30-kernel-compat.rules ${pkgdir}/lib/udev/rules.d/30-kernel-compat.rules +} +md5sums=('967c66e6b8e29d7cfc98326c5b00454d' + '4427855146513a4703ab5c7eb8a0156e' + 'd8725e64fd0ce6e784ae795fae424c0a' + 'f91fddc67609b45b244a624977c4247b') diff --git a/testing/udev/load-modules.sh b/testing/udev/load-modules.sh new file mode 100755 index 000000000..1e2af913e --- /dev/null +++ b/testing/udev/load-modules.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# Implement blacklisting for udev-loaded modules + +[ $# -ne 1 ] && exit 1 + +. /etc/rc.conf + +# grab modules from rc.conf +BLACKLIST="${MOD_BLACKLIST[@]}" +MODPROBE="/sbin/modprobe" +LOGGER="/usr/bin/logger" +RESOLVEALIAS="${MODPROBE} --resolve-alias" +USEBLACKLIST="--use-blacklist" + +if [ -f /proc/cmdline ]; then + for cmd in $(cat /proc/cmdline); do + case $cmd in + disablemodules=*) eval $cmd ;; + load_modules=off) exit ;; + esac + done + #parse cmdline entries of the form "disablemodules=x,y,z" + if [ -n "$disablemodules" ]; then + BLACKLIST="$BLACKLIST $(echo $disablemodules | sed 's|,| |g')" + fi +fi + +#MODULES entries in rc.conf that begin with ! are blacklisted +for mod in ${MODULES[@]}; do + if [ "${mod}" != "${mod#!}" ]; then + BLACKLIST="$BLACKLIST ${mod#!}" + fi +done + +if [ "$MOD_AUTOLOAD" = "yes" -o "$MOD_AUTOLOAD" = "YES" ]; then + if [ -n "${BLACKLIST}" ]; then + # If an alias name is on the blacklist, load no modules for this device + if echo "${BLACKLIST}" | /bin/grep -q -e " $1 " -e "^$1 " -e " $1\$"; then + $LOGGER -p info -t "$(basename $0)" "Not loading module alias '$1' because it is blacklisted" + exit + fi + #sanitize the blacklist + BLACKLIST="$(echo "$BLACKLIST" | sed -e 's|-|_|g')" + # Try to find all modules for the alias + mods=$($RESOLVEALIAS $1) + # If no modules could be found, try if the alias name is a module name + # In that case, omit the --use-blacklist parameter to imitate normal modprobe behaviour + [ -z "${mods}" ] && $MODPROBE -qni $1 && mods="$1" && USEBLACKLIST="" + [ -z "${mods}" ] && $LOGGER -p local0.debug -t "$(basename $0)" "'$1' is not a valid module or alias name" + for mod in ${mods}; do + # Find the module and all its dependencies + deps="$($MODPROBE -i --show-depends ${mod})" + [ $? -ne 0 ] && continue + + #sanitize the module names + deps="$(echo "$deps" | sed \ + -e "s#^insmod /lib.*/\(.*\)\.ko.*#\1#g" \ + -e 's|-|_|g')" + + # If the module or any of its dependencies is blacklisted, don't load it + for dep in $deps; do + if echo "${BLACKLIST}" | /bin/grep -q -e " ${dep} " -e "^${dep} " -e " ${dep}\$"; then + if [ "${dep}" = "${mod}" ]; then + $LOGGER -p local0.info -t "$(basename $0)" "Not loading module '${mod}' for alias '$1' because it is blacklisted" + else + $LOGGER -p local0.info -t "$(basename $0)" "Not loading module '${mod}' for alias '$1' because its dependency '${dep}' is blacklisted" + fi + continue 2 + fi + done + # modprobe usually uses the "blacklist" statements from modprobe.conf only to blacklist all aliases + # of a module, but not the module itself. We use --use-blacklist here so that modprobe also blacklists + # module names if we resolved alias names manually above + $MODPROBE $USEBLACKLIST ${mod} + done + else + $MODPROBE $USEBLACKLIST $1 + fi +fi +# vim: set et ts=4: diff --git a/testing/udev/udev.install b/testing/udev/udev.install new file mode 100644 index 000000000..b2ed69467 --- /dev/null +++ b/testing/udev/udev.install @@ -0,0 +1,49 @@ +# arg 1: the new package version +# arg 2: the old package version + +post_upgrade() { + if [ "$(vercmp $2 100)" -lt 0 ]; then + echo "ATTENTION UDEV:" + echo "----------" + echo "udev >=098 rules syntax has changed, please update your own rules." + echo "udev >=099 Added persistent network and CD/DVD Symlink generator rules." + echo "Please read the instructions carefully before reboot." + echo "They are located in /etc/udev/readme-udev-arch.txt" + echo "----------" + fi + if [ "$(vercmp $2 169)" -lt 0 ]; then + echo "ATTENTION UDEV:" + echo "---------------" + echo "Kernel 2.6.32 or newer is now required." + echo "OSS emulation modules are not loaded by default, add to rc.conf if needed." + echo "Arch specific cd symlinks are now no longer created." + echo "cd and net persistent rules will no longer be autogenerated," + echo "see <https://wiki.archlinux.org/index.php/Udev> for details." + echo "Errors are now logged (possibly to the console) by default." + echo "---------------" + fi +} + +post_install() { + # If a ramfs is mounted, we still need to make sure that /dev/{console,null,zero} exist + # The Archlinux installer bind-mounts /dev to /mnt/dev, thus making the real /dev invisible + ROOTDIR="" + [ "$(stat -c %D /)" != "$(stat -c %D /dev)" ] && ROOTDIR=$(mktemp -d /tmp/udevinstall.XXXXXX) + [ -n "${ROOTDIR}" ] && mount --bind / ${ROOTDIR} + if [ ! -c ${ROOTDIR}/dev/console ]; then + rm -f ${ROOTDIR}/dev/console + mknod -m600 ${ROOTDIR}/dev/console c 5 1 + fi + if [ ! -c ${ROOTDIR}/dev/null ]; then + rm -f ${ROOTDIR}/dev/null + mknod -m644 ${ROOTDIR}/dev/null c 1 3 + fi + if [ ! -c ${ROOTDIR}/dev/zero ]; then + rm -f ${ROOTDIR}/dev/zero + mknod -m644 ${ROOTDIR}/dev/zero c 1 5 + fi + if [ -n "${ROOTDIR}" ]; then + umount ${ROOTDIR} + rmdir ${ROOTDIR} + fi +} |