#!/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

# Copy across the udev binaries
copy_exec /sbin/udevd /sbin
if [ -x /sbin/udevadm.upgrade ]; then
    copy_exec /sbin/udevadm.upgrade /sbin/udevadm
else
    copy_exec /sbin/udevadm /sbin
fi

# 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 50-firmware.rules 60-persistent-storage.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
# 50-firmware.rules
copy_exec /lib/udev/firmware /lib/udev
# 60-persistent-storage.rules
copy_exec /lib/udev/ata_id /lib/udev
copy_exec /sbin/blkid /lib/udev
copy_exec /lib/udev/scsi_id /lib/udev
