# SliTaz package receipt.

PACKAGE="alsa-utils"
VERSION="1.0.24.2"
CATEGORY="multimedia"
SHORT_DESC="Alsa sound system utilities et config tools."
MAINTAINER="pankso@slitaz.org"
DEPENDS="alsa-lib ncurses util-linux-ng-getopt"
BUILD_DEPENDS="alsa-lib alsa-lib-dev"
TARBALL="$PACKAGE-$VERSION.tar.bz2"
WEB_SITE="http://www.alsa-project.org/"
WGET_URL="ftp://ftp.alsa-project.org/pub/utils/$TARBALL"
CONFIG_FILES="/etc/asound.state"

# Rules to configure and make the package.
compile_rules()
{
	cd $src
	./configure \
		--prefix=/usr \
		--infodir=/usr/share/info \
		--mandir=/usr/share/man \
		--disable-xmlto \
		$CONFIGURE_ARGS &&
	make &&
	make DESTDIR=$PWD/_pkg install
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	mkdir -p $fs/usr $fs/var/lib/alsa $fs/etc
	touch $fs/etc/asound.state
	cp -a $_pkg/usr/bin $fs/usr
	cp -a $_pkg/usr/sbin $fs/usr
	touch $fs/var/lib/alsa/asound.state
	chmod 755 $fs/usr/sbin/*
	# Remove speaker-test (18 Ko and needs sounds)
	rm $fs/usr/bin/speaker-test
	# For conf we need /var/tmp
	mkdir -p $fs/var/tmp
	chmod 1777 $fs/var/tmp
	# Remove alsaconf (use soundconf).
	rm $fs/usr/sbin/alsaconf
}

# Main alsa config (card name, volumes, etc) have moved upstream. So backup
# current one and reenable it after package install so user still have ther
# sound card and settings working.
pre_install()
{
	if [ -f $1/etc/asound.state ]; then
		mv $1/etc/asound.state /tmp
	fi
}

post_install()
{
	if [ -f $1/tmp/asound.state ]; then
		mv $1/tmp/asound.state $1/var/lib/alsa
	fi
}