#!/bin/sh
# Heavily based on the Slackware 12.1 SlackBuild
# http://kde-apps.org/content/show.php/ManDVD?content=83906
# Packagers Andrea Sciucca Gohanz ( gohanz@infinito.it)
# http://www.slacky.eu
# Depends from: DVD Slideshow >= 0.7.5, Mencoder, Xine > 0.99.4, Lame >= 3.97, Dvdauthor >= 0.6.11
# Mjpegtools >= 1.8.0, Netpbm >= 10.29, Transcode >= 1.0.2, Dvd+rw-tools >= 5.21.4

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package-mandvd
NAME=mandvd
SVERSION=2.5-4
VERSION=2.5.4
ARCH=${ARCH:-i686}
BUILD=1as

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

cd $TMP
tar xvzf $CWD/$NAME-$SVERSION.fc9.tar.gz

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

cd $NAME-2.5

find . -perm 777 -exec chmod 755 {} \;
find . -perm 775 -exec chmod 755 {} \;
find . -perm 555 -exec chmod 755 {} \;
find . -perm 666 -exec chmod 644 {} \;
find . -perm 664 -exec chmod 644 {} \;
find . -perm 444 -exec chmod 644 {} \;

qmake
make

mkdir -p $PKG/usr/bin
cp -a mandvd $PKG/usr/bin/mandvd

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

mkdir -p $PKG/usr/share/applications
cp -a $TMP/mandvd-2.5/mandvd.desktop $PKG/usr/share/applications

sed -i "s|Icon=mandvd|Icon=mandvdico.png|g" $PKG/usr/share/applications/mandvd.desktop

mkdir -p $PKG/usr/share/pixmaps
cp -a    $TMP/mandvd-2.5/mandvdico.png $PKG/usr/share/pixmaps

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

strip --strip-unneeded $PKG/usr/bin/*

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
fi
