# SliTaz package receipt.

PACKAGE="acpid"
VERSION="2.0.14"
CATEGORY="system-tools"
SHORT_DESC="The ACPI event daemon with netlink"
MAINTAINER="domcox@slitaz.org"
TARBALL="$PACKAGE-$VERSION.tar.gz"
WEB_SITE="http://tedfelix.com/linux/acpid-netlink.html"
WGET_URL="http://www.tedfelix.com/linux/$TARBALL"
KEY_FILE="key-constants"
TAGS="power-management"
SUGGESTED="pm-utils"

# Rules to configure and make the package.
compile_rules()
{
	# Build
	cd $src
	make clean && make
	make DESTDIR=$DESTDIR install
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	mkdir -p $fs/usr
	# acpid
	cp -a $_pkg/usr/sbin $fs/usr
	# acpi_listen
	cp -a $_pkg/usr/bin $fs/usr
	# acpid conf files
	mkdir -p $fs/etc
	cp -a $stuff/init.d $fs/etc/
	cp -a $stuff/acpi $fs/etc/
	chmod go-rwx $fs/etc/acpi/*.sh
	chmod go-rwx $fs/etc/acpi/events/*
}

# Pre and post remove commands for Tazpkg
post_install()
{
	local root
	root=$1
	if [ -z "$root" ]; then
		/etc/init.d/acpid start || continue
	fi
	if ! grep -q ^ACPID_OPTIONS $root/etc/daemons.conf; then
		echo '# ACPI daemon options.' >> $root/etc/daemons.conf
		echo 'ACPID_OPTIONS=""' >> $root/etc/daemons.conf
		echo '' >> $root/etc/daemons.conf
	fi
}	

pre_remove()
{
	/etc/init.d/acpid stop
}