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

CWD=`pwd`
if ["$TMP" = ""]; then
 TMP=/tmp/tgz
fi
PKG=$TMP/package-fglrxkonf
NAME=fglrxkonf
VERSION=0.8
ARCH=${ARCH:-noarch}
BUILD=1as

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

mkdir -p $PKG/usr/bin
mkdir -p $PKG/usr/share/applications/kde
mkdir -p $PKG/usr/doc/$NAME-$VERSION
mkdir -p $PKG/usr/share/icons/default.kde/32x32/apps

cp -a  $CWD/$NAME-$VERSION.kmdr   $PKG/usr/bin/$NAME.kmdr
cp -a  $CWD/ati.png $PKG/usr/share/icons/default.kde/32x32/apps

cat << EOF > $PKG/usr/share/applications/kde/$NAME.desktop
[Desktop Entry]
Name=FglrxKonf
GenericName= ATI fglrx "aticonfig" frontend
Exec=kmdr-executor '/usr/bin/$NAME.kmdr'
Type=Application
Icon=ati.png
Categories=Qt;KDE;Utility;
EOF

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 $PKG
fi
