#!/bin/sh
# Heavily based on the Slackware 12.1 SlackBuild
# http://www.khertz.net/archives/36
# Packagers Gohanz ( gohanz@infinito.it)
# http://www.slacky.it
# Required : FFmpeg

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package-flvget
NAME=flvget
VERSION=1.6.1
ARCH=${ARCH:-noarch}
BUILD=3as

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

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

cd $NAME-$VERSION

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

install -m 755  $CWD/flvget $PKG/usr/bin
cp -a $CWD/*.desktop $PKG/usr/share/applications/kde
cp -a $TMP/$NAME-$VERSION/* $PKG/usr/share/kommander
cp -a $CWD/youtube.sh $PKG/usr/share/kommander/plugins/
cp -a CHANGELOG COPYING README $PKG/usr/doc/$NAME-$VERSION

cd $CWD
cp -a *.SlackBuild slack-desc $PKG/usr/doc/$NAME-$VERSION
chmod 755 $PKG/usr/share/kommander/plugins/*.sh

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

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
