#!/bin/sh
# Heavily based on the Slackware 11.0 SlackBuild
# http://dvd-slideshow.sourceforge.net/
# Packager Vincenzi Loris - slacky@slacky.it

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package-dvd-slideshow
NAME=dvd-slideshow
VERSION=0.8.0.1
ARCH=noarch
BUILD=1sl

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

cd $TMP
tar xzvf $CWD/$NAME-0.8.0-1.tar.gz
cd $NAME-0.8.0-1
chown -R root:root .
mkdir -p $PKG/usr/man/man1
cp man/* $PKG/usr/man/man1
gzip -9 $PKG/usr/man/man1/*
mkdir -p $PKG/usr/bin
cp -a dir2slideshow dvd-burn dvd-menu dvd-slideshow gallery1-to-slideshow jigl2slideshow $PKG/usr/bin
mkdir -p $PKG/usr/doc/$NAME-$VERSION
cp -a COPYING.txt INSTALL.txt TODO.txt dvd-slideshowrc *.html $PKG/usr/doc/$NAME-$VERSION
cd $PKG
find . -perm 775 -exec chmod 755 {} \;
find . -perm 664 -exec chmod 644 {} \;
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
makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz

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