#!/bin/sh
#
# kTm port by Juzer
#
#       regards to hns & psych
#

# local config:
BUILD="1"
PACKAGE="alsa-utils"

check() {
# Checking for configuration
# Downloading sources lists
INSTALLED="`ls -1 $PACKAGES/packages/|grep $PACKAGE|cut -d "-" -f 1,2,3`"
$WGET -q ftp://ftp.alsa-project.org/pub/utils/
NEW=`grep $PACKAGE index.html|grep .tar.bz2|grep -v rc|cut -d / -f 6|cut -d '"' -f 1|sed -e s/.tar.*//|tail -1`
#Checking for new version
    checkpkg
# clean
rm index.html
}

download() {
# Downloading version from "${VERFILE}"
$WGET -P $DOWNL ftp://ftp.alsa-project.org/pub/utils/$SRC.tar.bz2
}

build() {
# Creating new
tar jxvf $DOWNL/$SRC.tar.bz2
cd $SRC
zcat $CWD/alsa-utils.alsaconf.diff.gz | patch -p1 --verbose
./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --build=$TARGET --host=$TARGET || exit
make || exit
make install DESTDIR=$PKG || exit
mkdir -p $PKG/etc/rc.d
zcat $CWD/rc.alsa.gz > $PKG/etc/rc.d/rc.alsa.new
chmod 755 $PKG/etc/rc.d/rc.alsa.new
    postbuild
}

source "${DATA:-/usr/lib/ktm}/ktm.ports.sh"

