#!/bin/sh
#
# Copyright 2005 Paul Blazejowski <diffie@gmail.com>
# Available under the terms of the GNU GPL.
#

NAME="udev"
VERSION="070"
REVISION="5"
PKG_SOURCEURL='http://www.us.kernel.org/pub/linux/utils/kernel/hotplug/$NAME-$VERSION.tar.bz2'
PKG_SOURCEMD5=''
PKG_PATCH[0]="compat.rules.unsupported"
PKG_PATCH[1]="devfs.rules.unsupported"
PKG_PATCH[2]="doinst.sh"
PKG_PATCH[3]="floppy-extra-devs.sh"
PKG_PATCH[4]="ide-devfs.sh"
PKG_PATCH[5]="make_extra_nodes.sh"
PKG_PATCH[6]="rc.udev"
PKG_PATCH[7]="scsi-devfs.sh"
PKG_PATCH[8]="udev.conf"
PKG_PATCH[9]="udev.rules"

. $DLG_ROOT/config
. $DLG_ROOT/SCRIPTS/dropline-functions.sh

cflags
cxxflags
export CFLAGS="-fPIC"
prepare
analyzesource
make EXTRAS=extras/run_directory/
make EXTRAS=extras/firmware/
#makecheck
makeinstall

createdir  $PKG_STAGEROOT/etc/hotplug.d/default
spewdo "cd $PKG_STAGEROOT/etc/hotplug.d/default ; rm -rf 10-udev.hotplug"
spewdo "cd $PKG_STAGEROOT/etc/hotplug.d/default ; ln -sf /sbin/udevsend 10-udev.hotplug"
spewdo "cp $PKG_WORKROOT/$NAME-$VERSION/extras/run_directory/udev_run_devd $PKG_STAGEROOT/sbin"
spewdo "cp $PKG_WORKROOT/$NAME-$VERSION/extras/run_directory/udev_run_hotplugd $PKG_STAGEROOT/sbin"
# Copy firmware_helper to /sbin
spewdo "cp $PKG_WORKROOT/$NAME-$VERSION/extras/firmware/firmware_helper $PKG_STAGEROOT/sbin"

removedir $PKG_STAGEROOT/udev
spewdo "mv $PKG_STAGEROOT$PKG_PREFIX/share/man $PKG_STAGEROOT$PKG_PREFIX"
removedir $PKG_STAGEROOT$PKG_PREFIX/share
spewdo "rm -r $PKG_STAGEROOT/etc/udev"
createdir $PKG_STAGEROOT/etc/udev/rules.d
createdir $PKG_STAGEROOT/etc/udev/scripts
createdir $PKG_STAGEROOT/etc/rc.d

findpatch filename udev.conf
spewdo "cp $filename $PKG_STAGEROOT/etc/udev/udev.conf"
findpatch filename compat.rules.unsupported
spewdo "cp $filename $PKG_STAGEROOT/etc/udev/rules.d/compat.rules.unsupported"
findpatch filename devfs.rules.unsupported
spewdo "cp $filename $PKG_STAGEROOT/etc/udev/rules.d/devfs.rules.unsupported"
findpatch filename udev.rules
spewdo "cp $filename $PKG_STAGEROOT/etc/udev/rules.d/udev.rules.new"
findpatch filename floppy-extra-devs.sh
spewdo "cp $filename $PKG_STAGEROOT/etc/udev/scripts/floppy-extra-devs.sh"
findpatch filename ide-devfs.sh
spewdo "cp $filename $PKG_STAGEROOT//etc/udev/scripts/ide-devfs.sh"
findpatch filename make_extra_nodes.sh
spewdo "cp $filename $PKG_STAGEROOT/etc/udev/scripts/make_extra_nodes.sh"
findpatch filename scsi-devfs.sh
spewdo "cp $filename $PKG_STAGEROOT/etc/udev/scripts/scsi-devfs.sh"
spewdo "chmod 755 $PKG_STAGEROOT/etc/udev/scripts/*"
findpatch filename rc.udev
spewdo "cp $filename $PKG_STAGEROOT/etc/rc.d/rc.udev.new"
spewdo "cd $PKG_STAGEROOT$PKG_PREFIX/man/man8 ; rm udevsend.8 ; ln -sf udevd.8 udevsend.8"

tidydocumentation
analyzebinaries
finalizepackage
packagize
cleanup

