#!/bin/sh
# Heavily based on the Slackware 13.0 SlackBuild
# http://sourceforge.net/projects/logapp/
# http://www.slacky.eu

CWD=`pwd`
TMP=${TMP:-/tmp/txz}
NAME=logapp
PKG=$TMP/package/$NAME
VERSION=0.14
ARCH=${ARCH:-i686}
BUILD=1slacky



rm -rf $PKG
mkdir -p $PKG/usr/bin

SOURCE=http://downloads.sourceforge.net/project/logapp/logapp/logapp-$VERSION/$NAME-$VERSION.tar.gz

if [ ! -e $NAME-$VERSION.tar.gz ]; then
wget -c $SOURCE
fi

cd $TMP
rm -rf $NAME-$VERSION 
tar xzf $CWD/$NAME-$VERSION.tar.gz
cd $NAME-$VERSION
chown -R root:root .

make
install -m 755 -p -D logapp $PKG/usr/bin/logapp
strip $PKG/usr/bin/*

mkdir -p $PKG/usr/doc/$NAME-$VERSION/SlackBuild
cp -a *.conf COPYING README TODO $PKG/usr/doc/$NAME-$VERSION

cd $PKG
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/slack-desc > $PKG/usr/doc/$NAME-$VERSION/SlackBuild/slack-desc
cat $CWD/$NAME.SlackBuild > $PKG/usr/doc/$NAME-$VERSION/SlackBuild/$NAME.SlackBuild
chown -R root:root .
requiredbuilder -y -v -s $CWD $PKG
makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.txz

if [ "$1" = "--cleanup" ]; then
 rm -rf $TMP
fi
