# SliTaz package receipt.

PACKAGE="pm-utils"
VERSION="1.4.1"
CATEGORY="system-tools"
SHORT_DESC="Collection of scripts that handle suspend and resume."
MAINTAINER="domcox@slitaz.org"
DEPENDS="bash kbd"
TARBALL="$PACKAGE-$VERSION.tar.gz"
WEB_SITE="http://pm-utils.freedesktop.org/"
WGET_URL="http://pm-utils.freedesktop.org/releases/$TARBALL"
CONFIG_FILES="/etc/pm"
TAGS="power-management"

# Rules to configure and make the package.
compile_rules()
{
	cd $src
	# workaround grep -x not implemented in busybox
	echo -n "Applying grep -x patch.."
	patch -p1 pm/functions.in $stuff/grep-x.patch > /dev/null \
		&& echo done. || echo failed.
	# remove acoustic management not implemented in busybox
	echo -n "Applying harddrive patch.."
	patch -p1 pm/power.d/harddrive $stuff/harddrive.patch > /dev/null \
		&& echo done. || echo failed.
	# build
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		$CONFIGURE_ARGS &&
	make &&
	make DESTDIR=$PWD/_pkg install
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	# main
	mkdir -p $fs/usr/lib
	cp -a $_pkg/usr/bin $fs/usr
	cp -a $_pkg/usr/sbin $fs/usr
	cp -a $_pkg/usr/lib/pm-utils $fs/usr/lib

	# sysconfig
	mkdir -p $fs/etc
	cp -a $_pkg/etc/pm $fs/etc

	# remove incompatible hooks
	echo "remove incompatible hooks"
	# NetworkManager hook
	rm -f $fs/usr/lib/pm-utils/sleep.d/55NetworkManager
	# grub hook (Redhat specific)
	rm -f $fs/usr/lib/pm-utils/sleep.d/01grub
	# readahead hook (not busybox compliant)
	rm -f $fs/usr/lib/pm-utils/power.d/readahead
	# sata_alpm (causes disk errors on many hardware)
	rm -f $fs/usr/lib/pm-utils/power.d/sata_alpm

	# add video quirks
	echo -n "Add video quirks"
	cp -a $stuff/video-quirks $fs/usr/lib/pm-utils
	status
}