summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-05-17 12:37:37 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-05-17 12:37:37 +0000
commit592e32a35be2934bf0627758a0bcd57c2ef13be1 (patch)
treeff07ba29702e2e1b29b77adfae604e1913c4f08e
parentbceef1f335c5c389a4be19b08f799bc4367c303e (diff)
downloadaports-592e32a35be2934bf0627758a0bcd57c2ef13be1.tar.bz2
aports-592e32a35be2934bf0627758a0bcd57c2ef13be1.tar.xz
extra/udev: new aport
-rw-r--r--extra/udev/APKBUILD41
-rwxr-xr-xextra/udev/move_tmp_persistent_rules.sh25
-rwxr-xr-xextra/udev/udev-mount.initd83
-rwxr-xr-xextra/udev/udev-postmount.initd31
-rw-r--r--extra/udev/udev-start.sh51
-rwxr-xr-xextra/udev/udev.initd239
-rwxr-xr-xextra/udev/write_root_link_rule29
7 files changed, 499 insertions, 0 deletions
diff --git a/extra/udev/APKBUILD b/extra/udev/APKBUILD
new file mode 100644
index 00000000..d25b5faa
--- /dev/null
+++ b/extra/udev/APKBUILD
@@ -0,0 +1,41 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=udev
+pkgver=142
+pkgrel=0
+pkgdesc="The userspace dev tools (udev)"
+url="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html"
+license="GPL"
+subpackages="$pkgname-dev $pkgname-doc"
+depends="uclibc"
+makedepends=""
+install=
+source="http://www.kernel.org/pub/linux/utils/kernel/hotplug/$pkgname-$pkgver.tar.bz2
+ write_root_link_rule
+ move_tmp_persistent_rules.sh
+ udev-mount.initd
+ udev-postmount.initd
+ udev.initd"
+
+build ()
+{
+ cd "$srcdir"/$pkgname-$pkgver
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --exec-prefix="" \
+ --with-libdir-name=/lib
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ chmod +x "$pkgdir"/lib/udev/write_*_rules
+ for _i in write_root_link_rule move_tmp_persistent_rules.sh; do
+ install -Dm755 ../$_i "$pkgdir"/lib/udev/$_i
+ done
+ for _i in udev udev-mount udev-postmount; do
+ install -Dm755 ../$_i.initd "$pkgdir"/etc/init.d/$_i
+ done
+}
+md5sums="3edc4cf383dccb06d866c5156d59ddd5 udev-142.tar.bz2
+c9de7581099cdfdcd105666cd98a0f0a write_root_link_rule
+7bf11e11519117f743483c73e0767750 move_tmp_persistent_rules.sh
+12760065a66ccbddc9e3a86a6cd2231c udev-mount.initd
+bffb42859ca508cfe1d9fa0a169ba810 udev-postmount.initd
+e913f8f122e8879252d2a05de7dd7499 udev.initd"
diff --git a/extra/udev/move_tmp_persistent_rules.sh b/extra/udev/move_tmp_persistent_rules.sh
new file mode 100755
index 00000000..1a025979
--- /dev/null
+++ b/extra/udev/move_tmp_persistent_rules.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+# Copyright 1999-2007 Gentoo Foundation
+# 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
+
+ for file in /dev/.udev/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/extra/udev/udev-mount.initd b/extra/udev/udev-mount.initd
new file mode 100755
index 00000000..839565a5
--- /dev/null
+++ b/extra/udev/udev-mount.initd
@@ -0,0 +1,83 @@
+#!/sbin/runscript
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+description="Mount tmpfs on /dev"
+[ -e /etc/conf.d/udev ] && . /etc/conf.d/udev
+
+mount_dev_directory()
+{
+ # No options are processed here as they should all be in /etc/fstab
+ ebegin "Mounting /dev"
+ 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 $?
+}
+
+seed_dev()
+{
+ # Seed /dev with some things that we know we need
+
+ # creating /dev/console, /dev/tty and /dev/tty1 to be able to write
+ # to $CONSOLE with/without bootsplash before udevd creates it
+ [ -c /dev/console ] || mknod -m 600 /dev/console c 5 1
+ [ -c /dev/tty1 ] || mknod -m 620 /dev/tty1 c 4 1
+ [ -c /dev/tty ] || mknod -m 666 /dev/tty c 5 0
+
+ # 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 -m 666 /dev/null c 1 3
+
+ # so udev can add its start-message to dmesg
+ [ -c /dev/kmsg ] || mknod -m 660 /dev/kmsg c 1 11
+
+ # 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
+ return 0
+}
+
+
+start()
+{
+ # do not run this on too old baselayout - udev-addon is already loaded!
+ if [ ! -f /etc/init.d/sysfs ]; then
+ eerror "The $SVCNAME init-script is written for baselayout-2!"
+ eerror "Please do not use it with baselayout-1!".
+ return 1
+ fi
+
+ _start
+}
+
+_start()
+{
+ mount_dev_directory || return 1
+
+ # Selinux lovin; /selinux should be mounted by selinux-patched init
+ if [ -x /sbin/restorecon -a -c /selinux/null ]; then
+ restorecon /dev > /selinux/null
+ fi
+
+ # make sure it exists
+ mkdir -p /dev/.udev
+
+ seed_dev
+
+ return 0
+}
diff --git a/extra/udev/udev-postmount.initd b/extra/udev/udev-postmount.initd
new file mode 100755
index 00000000..96beb845
--- /dev/null
+++ b/extra/udev/udev-postmount.initd
@@ -0,0 +1,31 @@
+#!/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/136/udev-postmount.initd,v 1.3 2009/02/23 16:30:53 zzam Exp $
+
+depend() {
+ need localmount
+}
+
+dir_writeable()
+{
+ mkdir "$1"/.test.$$ 2>/dev/null && rmdir "$1"/.test.$$
+}
+
+start() {
+ # check if this system uses udev
+ [ -d /dev/.udev/ ] || return 0
+
+ # only continue if rules-directory is writable
+ dir_writeable /etc/udev/rules.d || return 0
+
+ # store persistent-rules that got created while booting
+ # when / was still read-only
+ /lib/udev/move_tmp_persistent_rules.sh
+}
+
+stop() {
+ :
+}
+
+# vim:ts=4
diff --git a/extra/udev/udev-start.sh b/extra/udev/udev-start.sh
new file mode 100644
index 00000000..87c3a6ac
--- /dev/null
+++ b/extra/udev/udev-start.sh
@@ -0,0 +1,51 @@
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+[ -e /etc/conf.d/udev ] && . /etc/conf.d/udev
+
+compat_volume_nodes()
+{
+ # Only do this for baselayout-1*
+ # This check is likely to get false positives due to some multilib stuff,
+ # but that should not matter, as this can only happen on old openrc versions
+ # no longer available as ebuilds.
+ 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
+}
+
+start_initd()
+{
+ (
+ . /etc/init.d/"$1"
+ _start
+ )
+}
+
+# mount tmpfs on /dev
+start_initd udev-mount || exit 1
+
+# 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.
+# this is no longer needed as of openrc-0.4.0
+touch /dev/.rcsysinit
+
+# load device tarball
+start_initd udev-dev-tarball
+
+# run udevd
+start_initd udev || exit 1
+
+compat_volume_nodes
+
+# inject into boot runlevel
+IN_HOTPLUG=1 /etc/init.d/udev-postmount start >/dev/null 2>&1
+
+# udev started successfully
diff --git a/extra/udev/udev.initd b/extra/udev/udev.initd
new file mode 100755
index 00000000..26774ab4
--- /dev/null
+++ b/extra/udev/udev.initd
@@ -0,0 +1,239 @@
+#!/sbin/runscript
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+description="Run udevd and create the device-nodes"
+
+[ -e /etc/udev/udev.conf ] && . /etc/udev/udev.conf
+
+rc_coldplug=${rc_coldplug:-${RC_COLDPLUG:-YES}}
+
+depend()
+{
+ provide dev
+ if yesno "${rc_device_tarball:-no}"; then
+ need sysfs udev-mount udev-dev-tarball
+ else
+ need sysfs udev-mount
+ fi
+ before checkfs fsck
+
+ # udev does not work inside vservers
+ keyword novserver
+}
+
+cleanup()
+{
+ # fail more gracely and not leave udevd running
+ start-stop-daemon --stop --exec /sbin/udevd
+ exit 1
+}
+
+disable_hotplug_agent()
+{
+ if [ -e /proc/sys/kernel/hotplug ]; then
+ echo "" >/proc/sys/kernel/hotplug
+ fi
+}
+
+root_link()
+{
+ /lib/udev/write_root_link_rule
+}
+
+rules_disable_switch()
+{
+ # 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 bname="$1" onoff="$2"
+
+ if yesno "${onoff}"; then
+ mkdir -p "$d"
+ echo "# This file disables ${bname} due to /etc/conf.d/udev" \
+ > "${d}/${bname}"
+ else
+ rm -f "${d}/${bname}"
+ fi
+}
+
+start_udevd()
+{
+ # load unix domain sockets if built as module, Bug #221253
+ if [ -e /proc/modules ] ; then
+ modprobe -q unix 2>/dev/null
+ fi
+ ebegin "Starting udevd"
+ start-stop-daemon --start --exec /sbin/udevd -- --daemon
+ eend $?
+}
+
+# populate /dev with devices already found by the kernel
+populate_dev()
+{
+ 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
+ udevadm trigger
+ else
+ # 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
+ eend $?
+
+ ebegin "Waiting for uevents to be processed"
+ udevadm settle --timeout=${udev_settle_timeout:-60}
+ eend $?
+
+ udevadm control --env do_not_run_plug_service=
+ return 0
+}
+
+# for debugging
+start_udevmonitor()
+{
+ yesno "${udev_monitor:-no}" || return 0
+
+ udevmonitor_log=/dev/.udev/udevmonitor.log
+ udevmonitor_pid=/dev/.udev/udevmonitor.pid
+
+ einfo "udev: Running udevadm monitor ${udev_monitor_opts} to get a log of all events"
+ start-stop-daemon --start --stdout "${udevmonitor_log}" \
+ --make-pidfile --pidfile "${udevmonitor_pid}" \
+ --background --exec /sbin/udevadm -- monitor ${udev_monitor_opts}
+}
+
+stop_udevmonitor()
+{
+ yesno "${udev_monitor:-no}" || return 0
+
+ if yesno "${udev_monitor_keep_running:-no}"; then
+ ewarn "udev: udevmonitor is still running and writing into ${udevmonitor_log}"
+ else
+ einfo "udev: Stopping udevmonitor: Log is in ${udevmonitor_log}"
+ start-stop-daemon --stop --pidfile "${udevmonitor_pid}" --exec /sbin/udevadm
+ fi
+}
+
+display_hotplugged_services() {
+ local svcfile= svc= services=
+ for svcfile in "${RC_SVCDIR}"/hotplugged/*; do
+ svc="${svcfile##*/}"
+ [ -x "${svcfile}" ] || continue
+
+ # do not display this - better: do only inject it later :)
+ [ "$svc" = "udev-postmount" ] && continue
+
+ services="${services} ${svc}"
+ done
+ [ -n "${services}" ] && einfo "Device initiated services:${HILITE}${services}${NORMAL}"
+}
+
+inject_postmount_initd() {
+ if ! mark_service_hotplugged udev-postmount; then
+ IN_HOTPLUG=1 /etc/init.d/udev-postmount start >/dev/null 2>&1
+ fi
+ #einfo "Injected udev-postmount service"
+}
+
+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_udev_works()
+{
+ # 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
+}
+
+start()
+{
+ # do not run this on old baselayout where udev-addon gets loaded
+ if [ ! -f /etc/init.d/sysfs ]; then
+ eerror "The $SVCNAME init-script is written for baselayout-2!"
+ eerror "Please do not use it with baselayout-1!".
+ return 1
+ fi
+
+ _start
+
+ display_hotplugged_services
+
+ inject_postmount_initd
+}
+
+_start()
+{
+ root_link
+ rules_disable_switch 75-persistent-net-generator.rules "${persistent_net_disable:-no}"
+ rules_disable_switch 75-cd-aliases-generator.rules ${persistent_cd_disable:-no}
+
+ disable_hotplug_agent
+ start_udevd || cleanup
+ start_udevmonitor
+ populate_dev || cleanup
+
+ check_persistent_net
+
+ check_udev_works || cleanup
+ stop_udevmonitor
+
+ return 0
+}
+
+stop() {
+ ebegin "Stopping udevd"
+ start-stop-daemon --stop --exec /sbin/udevd
+ eend $?
+}
+
diff --git a/extra/udev/write_root_link_rule b/extra/udev/write_root_link_rule
new file mode 100755
index 00000000..8eaea117
--- /dev/null
+++ b/extra/udev/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 <zzam@gentoo.org>
+
+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}"
+