#!/bin/sh
# Heavily based on the Slackware 12.2 SlackBuild
# http://mybashburn.sourceforge.net/
# Packager Michelino Chionchio - Thanks to www.slacky.eu

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package-mybashburn
NAME=mybashburn
VERSION=1.0.2
ARCH=noarch
BUILD=3mch

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

cd $TMP
tar jxvf $CWD/$NAME-$VERSION.tar.bz2
cd $NAME-$VERSION

mkdir -p $PKG/usr/bin $PKG/etc $PKG/usr/man/man1 $PKG/usr/doc/mybashburn-1.0.2 $PKG/usr/share/mybashburn
cp MyBashBurn.sh $PKG/usr/share/mybashburn/
cp man/mybashburn.1.gz $PKG/usr/man/man1/
cp ChangeLog COPYING CREDITS FAQ FILES HOWTO INSTALL README TODO $PKG/usr/doc/mybashburn-1.0.2/
cp -Rp lang convert menus burning misc config etc $PKG/usr/share/mybashburn

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
cat $CWD/doinst.sh > $PKG/install/doinst.sh

cd $PKG
chown -R root:root .

requiredbuilder -v -y -s $CWD $PKG
makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz

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