#!/bin/sh
# Heavily based on the Slackware 12.0 SlackBuild
# http://dvdripomatic.sourceforge.net
# Packagers Gohanz ( gohanz@infinito.it)
# http://www.slacky.it

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package-dvdripomatic
NAME=dvdripomatic
VERSION=0.95
ARCH=${ARCH:-noarch}
BUILD=1as

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

cd $TMP
tar xvjf $CWD/DVDRipOMatic-$VERSION.tar.bz2

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

cd DVDRipOMatic-$VERSION

mkdir -p $PKG/usr/bin
mkdir -p $PKG/usr/share/applications/kde
mkdir -p $PKG/usr/share/kommander/dvdripomatic
mkdir -p $PKG/usr/doc/$NAME-$VERSION

cp -a $CWD/$NAME.desktop \
$PKG/usr/share/applications/kde
cp -a DVDRipOMatic.kmdr DVDScan banner.png \
$PKG/usr/share/kommander/dvdripomatic
cp -a Changelog README \
$PKG/usr/doc/$NAME-$VERSION
cp -a $CWD/dvdripomatic \
$PKG/usr/bin
chmod 755 $PKG/usr/bin/dvdripomatic

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/slack-desc > $PKG/usr/doc/$NAME-$VERSION/slack-desc
cat $CWD/$NAME.SlackBuild > $PKG/usr/doc/$NAME-$VERSION/$NAME.SlackBuild

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
