#!/bin/sh

. config/options

PKG_DIR=`find $PACKAGES -type d -name $1`

mkdir -p $INSTALL/sbin
  cp $PKG_BUILD/$1/udevadm $INSTALL/sbin
  cp $PKG_BUILD/$1/udevd $INSTALL/sbin

mkdir -p $INSTALL/usr/lib
  cp -PR $PKG_BUILD/libudev/.libs/libudev.so* $INSTALL/usr/lib

mkdir -p $INSTALL/lib/udev
#  cp $PKG_BUILD/extras/floppy/create_floppy_devices $INSTALL/lib/udev
  cp $PKG_BUILD/extras/firmware/firmware.sh $INSTALL/lib/udev
  cp $PKG_BUILD/extras/rule_generator/rule_generator.functions $INSTALL/lib/udev
  cp $PKG_BUILD/extras/rule_generator/write_cd_rules $INSTALL/lib/udev
  cp $PKG_BUILD/extras/rule_generator/write_net_rules $INSTALL/lib/udev
  chmod +x $INSTALL/lib/udev/write_*_rules
  for i in ata_id cdrom_id collect edd_id fstab_import path_id scsi_id usb_id v4l_id; do
    cp $PKG_BUILD/extras/$i/$i $INSTALL/lib/udev
  done

mkdir -p $INSTALL/lib/udev/rules.d
  cp $PKG_BUILD/extras/cdrom_id/*.rules $INSTALL/lib/udev/rules.d
  cp $PKG_BUILD/extras/edd_id/*.rules $INSTALL/lib/udev/rules.d
  cp $PKG_BUILD/extras/firmware/*.rules $INSTALL/lib/udev/rules.d
#  cp $PKG_BUILD/extras/fstab_import/*.rules $INSTALL/lib/udev/rules.d
  cp $PKG_BUILD/extras/rule_generator/*.rules $INSTALL/lib/udev/rules.d
  cp $PKG_BUILD/extras/v4l_id/*.rules $INSTALL/lib/udev/rules.d
  cp $PKG_BUILD/rules/rules.d/50-udev-default.rules $INSTALL/lib/udev/rules.d
  cp $PKG_BUILD/rules/rules.d/60-persistent-alsa.rules $INSTALL/lib/udev/rules.d
  cp $PKG_BUILD/rules/rules.d/60-persistent-input.rules $INSTALL/lib/udev/rules.d
  cp $PKG_BUILD/rules/rules.d/60-persistent-serial.rules $INSTALL/lib/udev/rules.d
#  cp $PKG_BUILD/rules/rules.d/60-persistent-storage-tape.rules $INSTALL/lib/udev/rules.d
  cp $PKG_BUILD/rules/rules.d/60-persistent-storage.rules $INSTALL/lib/udev/rules.d
  cp $PKG_BUILD/rules/rules.d/80-drivers.rules $INSTALL/lib/udev/rules.d
  cp $PKG_BUILD/rules/rules.d/95-udev-late.rules $INSTALL/lib/udev/rules.d

mkdir -p $INSTALL/etc/udev
  cp $PKG_BUILD/udev.conf $INSTALL/etc/udev

mkdir -p $INSTALL/etc/udev/rules.d
