#!/bin/sh
#
# Copyright 2005 Zach Borgerding <zborgerd@gmail.com>
# Available under the terms of the GNU GPL.
#

NAME="hal"
VERSION="0.5.4"
REVISION="7"

PKG_SOURCEURL='http://freedesktop.org/~david/dist/$NAME-$VERSION.tar.gz'

# NOTE!  If you attempt to build this package on a pristine Slackware system
# you will fail.  It needs kernel headers from the 2.6.x kernels, not the
# 2.4.x kernels.  If you're using a 2.6.x kernel (which you should be) I have
# put together a kernel-headers pacakge definition which will actually make a
# kernel-headers package with the exact version of the kernel you are running
# so that you can chunk this package out and then put back the originals.

PKG_PATCH[0]='hal-0.5.4-slackware-storage-policy.patch'
PKG_PATCH[1]='rc.hal'

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

# Now that we are truly using sysvinit startups, this is no longer needed.
#configfile /etc/rc.d/rc.hal

# prevent a redundnant /lib in /var
PKG_LOCALSTATEDIR="/var"

cflags
prepare
analyzesource

applypatch 0 1

# Download the latest pci.ids file.  Remove the old one first.
if [ -e $PKG_COREREPOS/pci.ids ]; then
        spewdo "rm $PKG_COREREPOS/pci.ids"
fi
downloadfile $PKG_COREREPOS http://pciids.sourceforge.net/pci.ids 

# Install the latest pci.ids file before building
if [ ! -d $PKG_PREFIX/share/hwdata ]; then
        mkdir -p $PKG_PREFIX/share/hwdata
fi

findpatch filename pci.ids
spewdo "cp $filename $PKG_PREFIX/share/hwdata/"

# Begin build
configure --disable-docbook-docs \
  --disable-doxygen-docs \
  --with-pid-file=/var/run/hal.pid \
  --enable-fstab-sync \
  --with-mnt-root=/mnt \
  --with-dbus-sys=/etc/dbus-1/system.d \
  --with-hotplug=/etc/hotplug.d
make
makeinstall install-strip

# Include pci.ids in the package
spewdo "mkdir -p $PKG_STAGEROOT$PKG_PREFIX/share/hwdata"
findpatch filename pci.ids
spewdo "cp $filename $PKG_STAGEROOT$PKG_PREFIX/share/hwdata/pci.ids"
spewdo "chmod 644 $PKG_STAGEROOT$PKG_PREFIX/share/hwdata/pci.ids"

# Insert our rc.hal script
findpatch initscript ${PKG_PATCH[1]}
sysvinitsetup $initscript 345 91

tidydocumentation
analyzebinaries
finalizepackage
packagize
cleanup
