#!/bin/sh
# Heavily based on the Slackware 11.0 SlackBuild
# Packager Absinthetized
#-----------------------------------------------

#global info section
PKG=$TMP/package-SSANotifier
NAME=SSANotifier
VERSION=0.90.4
ARCH=${ARCH:-noarch}
BUILD=2ab

#prepare packaging temporary directory
CWD=`pwd`
if [ "$TMP" = "" ]; then
 TMP=/tmp
fi

if [ ! -d $TMP ]; then
 mkdir -p $TMP
fi
if [ ! -d $PKG ]; then
 mkdir -p $PKG
fi

#extract source files
cd $TMP
tar xjvf $CWD/$NAME-$VERSION.tar.bz2
cd $NAME-$VERSION

#prepare executable files
TOOLDIR=$PKG/usr/sbin
mkdir -p $TOOLDIR
AUXDIR=$PKG/usr/libexec/SSANotifier
mkdir -p $AUXDIR

cp -a SSANotifier $TOOLDIR
cp -a SSAUpdater $AUXDIR

#prepare configuration files
CONFDIR=$PKG/etc/$NAME
mkdir -p $CONFDIR
cp -a SSANotifier.conf.new $CONFDIR

#gzip the man page(s)
#mkdir -p $PKG/usr/man/man8
#cat tracepkg.8 | gzip -9c > $PKG/usr/man/man8/tracepkg.8.gz

#prepare docs directory
mkdir -p $PKG/usr/doc/$NAME-$VERSION
cp SSANotifier.desktop $PKG/usr/doc/$NAME-$VERSION
cp README $PKG/usr/doc/$NAME-$VERSION
cp license   $PKG/usr/doc/$NAME-$VERSION
cp changelog $PKG/usr/doc/$NAME-$VERSION
cd $CWD
cp -a *.SlackBuild slack-desc $PKG/usr/doc/$NAME-$VERSION

#prepare install directory
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $TMP/$NAME-$VERSION/doinst.sh > $PKG/install/doinst.sh

#build tgz :)
cd $PKG
chown -R root:root .
makepkg -l y -c n $CWD/ssanotifier-$VERSION-$ARCH-$BUILD.tgz

#clean up all temporary stuff if required
if [ "$1" = "--cleanup" ]; then
 rm -rf $TMP/$NAME-$VERSION
 rm -rf $PKG
fi

#EOF
