#!/bin/sh
# Heavily based on the Slackware 12.0 SlackBuild
# http://bouveyron.free.fr/kim
# Packagers Gohanz ( gohanz@infinito.it)
# http://www.slacky.it

CWD=`pwd`
if ["$TMP" = ""]; then
 TMP=/tmp/pkg
fi
PKG=$TMP/package-kim
NAME=kim
VERSION=0.9.5
ARCH=${ARCH:-noarch}
BUILD=1as
$KDEDIR=/usr

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

cd $TMP
tar xvzf $CWD/$NAME-$VERSION.tar.gz

echo "+--------------------------------+"
echo "| Starting SlackBuild  $NAME-$VERSION |"
echo "+--------------------------------+"

cd $NAME

mkdir  -p $PKG/$KDEDIR/share/apps/konqueror/servicemenus
mkdir  -p $PKG/$KDEDIR/bin
mkdir  -p $PKG/$KDEDIR/share/apps/kim/slideshow
mkdir  -p $PKG/$KDEDIR/share/apps/kim/galery

cp -a $TMP/$NAME/src/bin/* $PKG/$KDEDIR/bin
chmod a+rx                 $PKG/$KDEDIR/bin

cp -a $TMP/$NAME/src/kim*.desktop $PKG/$KDEDIR/share/apps/konqueror/servicemenus
chmod a+rx $PKG/$KDEDIR/share/apps/konqueror/servicemenus/kim*.desktop

cp -a $TMP/$NAME/src/slideshow/* $PKG/$KDEDIR/share/apps/kim/slideshow
cp -a $TMP/$NAME/src/galery/*    $PKG/$KDEDIR/share/apps/kim/galery

mkdir -p $PKG/usr/doc/$NAME-$VERSION
cp -a \
AUTHORS COPYING ChangeLog INSTALL 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 .
requiredbuilder -y -v -s $CWD $PKG
makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz

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