diff --git a/templates/udev/template b/templates/udev/template index c236056cb4c..1a6bd82da15 100644 --- a/templates/udev/template +++ b/templates/udev/template @@ -13,4 +13,22 @@ long_desc=" udev is a implementation of devfs in userspace using sysfs and /sbin/hotplug. It requires a 2.5/2.6 kernel to run properly." -run_depends="glibc-2.8" +build_depends="initramfs-tools-0.92 procps-3.2.7" +run_depends="glibc-2.8 $build_depends" + +post_install() +{ + local destdir=$XBPS_DESTDIR/$pkgname-$version + + # Install the initramfs-tools udev scripts. + mkdir -p $destdir/usr/share/initramfs-tools/hooks + mkdir -p $destdir/usr/share/initramfs-tools/scripts/init-premount + mkdir -p $destdir/usr/share/initramfs-tools/scripts/init-bottom + + install -m 755 $XBPS_TEMPLATESDIR/udev/udev.initramfs-hook \ + $destdir/usr/share/initramfs-tools/hooks/udev + install -m 755 $XBPS_TEMPLATESDIR/udev/udev.initramfs-premount \ + $destdir/usr/share/initramfs-tools/scripts/init-premount/udev + install -m 755 $XBPS_TEMPLATESDIR/udev/udev.initramfs-bottom \ + $destdir/usr/share/initramfs-tools/scripts/init-bottom/udev +} diff --git a/templates/udev/udev.initramfs-bottom b/templates/udev/udev.initramfs-bottom new file mode 100644 index 00000000000..6c59eb0a95b --- /dev/null +++ b/templates/udev/udev.initramfs-bottom @@ -0,0 +1,28 @@ +#!/bin/sh -e +# initramfs premount script for udev + +PREREQ="" + +# Output pre-requisites +prereqs() +{ + echo "$PREREQ" +} + +case "$1" in + prereqs) + prereqs + exit 0 + ;; +esac + + +# Stop udevd, we'll miss a few events while we run init, but we catch up +pkill udevd + +# udevd might have been in the middle of something when we killed it, +# but it doesn't matter because we'll do everything again in userspace +rm -rf /dev/.udev/queue + +# Move /dev to the real filesystem +mount -n -o move /dev ${rootmnt}/dev diff --git a/templates/udev/udev.initramfs-hook b/templates/udev/udev.initramfs-hook new file mode 100644 index 00000000000..7ad35950525 --- /dev/null +++ b/templates/udev/udev.initramfs-hook @@ -0,0 +1,51 @@ +#!/bin/sh -e +# initramfs hook for udev + +MINKVER="2.6.24" +PREREQ="" + +# Output pre-requisites +prereqs() +{ + echo "$PREREQ" +} + +case "$1" in + prereqs) + prereqs + exit 0 + ;; +esac + + +. /usr/share/initramfs-tools/hook-functions + +# We use pkill +copy_exec /usr/bin/pkill /sbin + +# Copy across the udev binaries +copy_exec /sbin/udevd /sbin +copy_exec /sbin/udevadm /sbin + +# Copy udev configuration +mkdir -p ${DESTDIR}/etc/udev +cp -p /etc/udev/udev.conf ${DESTDIR}/etc/udev + +# Only copy across relevant rules +mkdir -p ${DESTDIR}/lib/udev/rules.d +for rules in 50-udev-default.rules 60-persistent-storage.rules \ + 61-persistent-storage-edd.rules 80-drivers.rules 95-udev-late.rules; do + cp -p /lib/udev/rules.d/$rules ${DESTDIR}/lib/udev/rules.d +done + +# Copy across helpers the rules need +mkdir -p ${DESTDIR}/lib/udev +# 50-udev-default.rules +# 60-persistent-storage.rules +copy_exec /lib/udev/ata_id /lib/udev +copy_exec /lib/udev/usb_id /lib/udev +copy_exec /lib/udev/vol_id /lib/udev +copy_exec /lib/udev/scsi_id /lib/udev +copy_exec /lib/udev/path_id /lib/udev +# 61-persistent-storage-edd.rules +#copy_exec /lib/udev/edd_id /lib/udev diff --git a/templates/udev/udev.initramfs-premount b/templates/udev/udev.initramfs-premount new file mode 100644 index 00000000000..c413b253bfc --- /dev/null +++ b/templates/udev/udev.initramfs-premount @@ -0,0 +1,29 @@ +#!/bin/sh -e +# initramfs premount script for udev + +PREREQ="" + +# Output pre-requisites +prereqs() +{ + echo "$PREREQ" +} + +case "$1" in + prereqs) + prereqs + exit 0 + ;; +esac + + +# It's all over netlink now +echo "" > /proc/sys/kernel/hotplug + +# Start the udev daemon to process events +/sbin/udevd --daemon --resolve-names=never + +# Iterate sysfs and fire off everything; if we include a rule for it then +# it'll get handled; otherwise it'll get handled later when we do this again +# in the main boot sequence. +/sbin/udevadm trigger