#!/bin/sh
# Heavily based on the Slackware 12.1 SlackBuild
# http://kde-apps.org/content/show.php?content=37074
# Packagers Gohanz ( gohanz@infinito.it)
# http://www.slacky.it
# Required : Kommander

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package-knamer
NAME=knamer
VERSION=0.10
ARCH=${ARCH:-noarch}
BUILD=2as

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

cd $TMP
tar xvjf $CWD/knamer0.10.tar.bz2

mkdir -p $PKG/usr/bin
mkdir -p $PKG/usr/share/kommander/$NAME
mkdir -p $PKG/usr/share/applications/kde
mkdir -p $PKG/usr/share/apps/konqueror/servicemenus
mkdir -p $PKG/usr/doc/$NAME-$VERSION

cp -a $CWD/knamer.desktop $PKG/usr/share/applications/kde
cp -a -r TestFiles $PKG/usr/share/kommander/$NAME
cp -a knamer.kmdr $PKG/usr/share/kommander/$NAME
cp -a $CWD/knamer $PKG/usr/bin
cp -a rename_with_knamer.desktop $PKG/usr/share/apps/konqueror/servicemenus

cp -a README $PKG/usr/doc/$NAME-$VERSION

cd $CWD
cp -a *.SlackBuild slack-desc $PKG/usr/doc/$NAME-$VERSION

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

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

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