diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2010-08-25 19:09:32 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2010-08-25 19:09:32 +0000 |
commit | 4040eea16ce61c966c51e440452272b3edeba6be (patch) | |
tree | b341717802eb349b8aa505b4afdfa2ce7cf69d71 /testing | |
parent | 39e7f49d9c884b6c054d9ba793da52dd3a0876cf (diff) | |
download | aports-4040eea16ce61c966c51e440452272b3edeba6be.tar.bz2 aports-4040eea16ce61c966c51e440452272b3edeba6be.tar.xz |
testing/udev: import initd script from gentoo
Diffstat (limited to 'testing')
-rw-r--r-- | testing/udev/APKBUILD | 25 | ||||
-rw-r--r--[-rwxr-xr-x] | testing/udev/udev-mount.initd | 48 | ||||
-rw-r--r--[-rwxr-xr-x] | testing/udev/udev-postmount.initd | 12 | ||||
-rw-r--r-- | testing/udev/udev-start.sh | 51 | ||||
-rw-r--r-- | testing/udev/udev.confd | 64 | ||||
-rw-r--r--[-rwxr-xr-x] | testing/udev/udev.initd | 59 |
6 files changed, 124 insertions, 135 deletions
diff --git a/testing/udev/APKBUILD b/testing/udev/APKBUILD index 76fbb0276b..4689cf6e0e 100644 --- a/testing/udev/APKBUILD +++ b/testing/udev/APKBUILD @@ -1,7 +1,7 @@ # Maintainer: Natanael Copa <ncopa@alpinelinux.org> pkgname=udev pkgver=161 -pkgrel=0 +pkgrel=1 pkgdesc="The userspace dev tools (udev)" url="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html" license="GPL" @@ -22,8 +22,10 @@ build () cd "$srcdir"/$pkgname-$pkgver ./configure --prefix=/usr \ --sysconfdir=/etc \ + --sbindir=/sbin \ + --libdir=/usr/lib \ + --with-rootlibdir=/lib \ --libexecdir=/lib/udev \ - --exec-prefix="" \ || return 1 make || return 1 } @@ -33,15 +35,6 @@ package() { make DESTDIR="$pkgdir" install mkdir -p "$pkgdir"/usr/lib/pkgconfig - mv "$pkgdir"/usr/share/pkgconfig/* \ - "$pkgdir"/lib/pkgconfig/* \ - "$pkgdir"/usr/lib/pkgconfig/ \ - && rmdir "$pkgdir"/lib/pkgconfig "$pkgdir"/usr/share/pkgconfig \ - || return 1 - mv "$pkgdir"/lib/*.la \ - "$pkgdir"/lib/girepository* \ - "$pkgdir"/usr/lib/ || return 1 - 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 @@ -53,13 +46,13 @@ package() { libgudev() { pkgdesc="A GObject wrapper of the library gudev" - mkdir -p "$subpkgdir"/lib - mv "$pkgdir"/lib/libgudev* "$subpkgdir"/lib/ + mkdir -p "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/lib/libgudev* "$subpkgdir"/usr/lib/ } md5sums="95b6a0ffc9913f3e8021c65f51eb4f88 udev-161.tar.bz2 c9de7581099cdfdcd105666cd98a0f0a write_root_link_rule 7bf11e11519117f743483c73e0767750 move_tmp_persistent_rules.sh -12760065a66ccbddc9e3a86a6cd2231c udev-mount.initd -bffb42859ca508cfe1d9fa0a169ba810 udev-postmount.initd -e913f8f122e8879252d2a05de7dd7499 udev.initd" +884d7faaaa149a323b14e907ea1934f4 udev-mount.initd +8f0a1b371804c7fa30f1a7bfde88e9ea udev-postmount.initd +42b7e4ad49874e68851fc21153f41c4f udev.initd" diff --git a/testing/udev/udev-mount.initd b/testing/udev/udev-mount.initd index 839565a5ba..f0d8cc39f2 100755..100644 --- a/testing/udev/udev-mount.initd +++ b/testing/udev/udev-mount.initd @@ -1,5 +1,5 @@ #!/sbin/runscript -# Copyright 1999-2008 Gentoo Foundation +# Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 description="Mount tmpfs on /dev" @@ -7,13 +7,20 @@ description="Mount tmpfs on /dev" mount_dev_directory() { + if mountinfo -q /dev; then + einfo "/dev is already mounted" + return 0 + fi + # 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 + if ! fstabinfo --mount /dev; then + # we mount devtmpfs if supported + local fs=tmpfs + grep -qs devtmpfs /proc/filesystems && fs=devtmpfs + # Some devices require exec, Bug #92921 - mount -n -t tmpfs -o "exec,nosuid,mode=0755,size=10M" udev /dev + mount -n -t "$fs" -o "exec,nosuid,mode=0755,size=10M" udev /dev fi eend $? } @@ -35,18 +42,6 @@ seed_dev() # 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 @@ -55,27 +50,10 @@ seed_dev() 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 + mkdir -p /dev/.udev /dev/.udev/rules.d seed_dev diff --git a/testing/udev/udev-postmount.initd b/testing/udev/udev-postmount.initd index 96beb845bb..33a412ff87 100755..100644 --- a/testing/udev/udev-postmount.initd +++ b/testing/udev/udev-postmount.initd @@ -1,21 +1,27 @@ #!/sbin/runscript -# Copyright 1999-2007 Gentoo Foundation +# Copyright 1999-2010 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 $ +# $Header: /var/cvsroot/gentoo-x86/sys-fs/udev/files/161/udev-postmount.initd,v 1.1 2010/08/24 18:41:29 zzam Exp $ depend() { need localmount + after dbus # for trigger failed } dir_writeable() { - mkdir "$1"/.test.$$ 2>/dev/null && rmdir "$1"/.test.$$ + printf "" 2>/dev/null >"$1"/.test.$$ && rm "$1"/.test.$$ } start() { # check if this system uses udev [ -d /dev/.udev/ ] || return 0 + einfo "Doing udev cleanups" + + # Run the events that failed at first udev trigger + udevadm trigger --type=failed -v + # only continue if rules-directory is writable dir_writeable /etc/udev/rules.d || return 0 diff --git a/testing/udev/udev-start.sh b/testing/udev/udev-start.sh deleted file mode 100644 index 87c3a6ac93..0000000000 --- a/testing/udev/udev-start.sh +++ /dev/null @@ -1,51 +0,0 @@ -# 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/testing/udev/udev.confd b/testing/udev/udev.confd new file mode 100644 index 0000000000..7c3d3eb229 --- /dev/null +++ b/testing/udev/udev.confd @@ -0,0 +1,64 @@ +# /etc/conf.d/udev: config file for udev + +# We discourage to disable persistent-net!! +# this may lead to random interface naming + +# Disable adding new rules for persistent-net +persistent_net_disable="no" + +# Disable adding new rules for persistent-cd +# Disabling this will stop new cdrom devices to appear +# as /dev/{cdrom,cdrw,dvd,dvdrw} +persistent_cd_disable="no" + +# Set to "yes" if you want to save /dev to a tarball on shutdown +# and restore it on startup. This is useful if you have a lot of +# custom device nodes that udev does not handle/know about. +# +# As this option is fragile, we recommend you +# to create your devices in /lib/udev/devices. +# These will be copied to /dev on boot. +#rc_device_tarball="NO" + +# udev can trigger coldplug events which cause services to start and +# kernel modules to be loaded. +# Services are deferred to start in the boot runlevel. +# Set rc_coldplug="NO" if you don't want this. +# If you want module coldplugging but not coldplugging of services then you +# can disable service coldplugging in baselayout/openrc config files. +# The setting is named different in different versions. +# in /etc/rc.conf: rc_hotplug="!*" or +# in /etc/conf.d/rc: rc_plug_services="!*" +#rc_coldplug="YES" + + + + +# Expert options: + +# Disable warning about unreliable kernel/udev combination +#unreliable_kernel_warning="no" + +# Timeout in seconds to wait for processing of uevents at boot. +# There should be no need to change this. +#udev_settle_timeout="60" + +# Add extra command line options to udevd, use with care +# udevd --help for possible values +#udev_opts="" + +# Run udevd --debug and write output to /dev/.udev/udev.log +# Should not be kept on as it fills diskspace slowly +#udev_debug="YES" + +# Run udevadmin monitor to get a log of all events +# in /dev/.udev/udevmonitor.log +#udev_monitor="YES" + +# Keep udevmonitor running after populating /dev. +#udev_monitor_keep_running="no" + +# Set cmdline options for udevmonitor. +# could be some of --env --kernel --udev +#udev_monitor_opts="--env" + diff --git a/testing/udev/udev.initd b/testing/udev/udev.initd index 26774ab4ac..e48ea9b675 100755..100644 --- a/testing/udev/udev.initd +++ b/testing/udev/udev.initd @@ -1,5 +1,5 @@ #!/sbin/runscript -# Copyright 1999-2008 Gentoo Foundation +# Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 description="Run udevd and create the device-nodes" @@ -19,7 +19,7 @@ depend() before checkfs fsck # udev does not work inside vservers - keyword novserver + keyword novserver nolxc noopenvz } cleanup() @@ -46,14 +46,13 @@ 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" + local f=/dev/.udev/rules.d/"$1" bname="$1" onoff="$2" if yesno "${onoff}"; then - mkdir -p "$d" echo "# This file disables ${bname} due to /etc/conf.d/udev" \ - > "${d}/${bname}" + > "${f}" else - rm -f "${d}/${bname}" + rm -f "${f}" fi } @@ -63,8 +62,15 @@ start_udevd() if [ -e /proc/modules ] ; then modprobe -q unix 2>/dev/null fi + local opts="${udev_opts}" + ebegin "Starting udevd" - start-stop-daemon --start --exec /sbin/udevd -- --daemon + if yesno "${udev_debug:-no}"; then + /sbin/udevd --daemon ${opts} --debug 2>/dev/.udev/udev.log + else + start-stop-daemon --start --exec /sbin/udevd -- --daemon ${opts} + fi + eend $? } @@ -77,25 +83,31 @@ populate_dev() fi ebegin "Populating /dev with existing devices through uevents" + udevadm control --property=STARTUP=1 if yesno "${rc_coldplug}"; then - udevadm trigger + udevadm trigger --action="add" else # Do not run any init-scripts, Bug #206518 - udevadm control --env do_not_run_plug_service=1 + udevadm control --property=do_not_run_plug_service=1 # only create device nodes - udevadm trigger --attr-match=dev + udevadm trigger --action="add" --attr-match=dev # run persistent-net stuff, bug 191466 - udevadm trigger --subsystem-match=net + udevadm trigger --action="add" --subsystem-match=net fi eend $? + # we can speed up booting under these conditions: + # * using devtmpfs so kernel creates device nodes for us + # * only using kernel created device nodes at boot (in /etc/fstab and elsewhere) + # ebegin "Waiting for uevents to be processed" udevadm settle --timeout=${udev_settle_timeout:-60} eend $? - udevadm control --env do_not_run_plug_service= + udevadm control --property=do_not_run_plug_service= + udevadm control --property=STARTUP= return 0 } @@ -131,21 +143,11 @@ display_hotplugged_services() { 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 @@ -198,22 +200,19 @@ check_udev_works() 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 + return 0 } _start() { + if [ ! -e /etc/runlevels/${RC_DEFAULTLEVEL:-default}/udev-postmount ]; then + ewarn "You should add udev-postmount service to your default runlevel." + fi + 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} |