#!/bin/sh
# Heavily based on the Slackware 12.0 SlackBuild
# MPlayer Codecs Full Version
# http://www.mplayerhq.hu/MPlayer/releases/codecs/
# Packager Salbutamolo ( alessandro_ranieri@virgilio.it )

CWD=`pwd`
if ["$TMP" = ""]; then
 TMP=/tmp
fi

PKG=$TMP/package-all
NAME=all
VERSION=20071007
ARCH=noarch
BUILD=1sal

SOURCE=http://www.mplayerhq.hu/MPlayer/releases/codecs/$NAME-$VERSION.tar.bz2

if [ ! -e $NAME-$VERSION.tar.bz2 ]; then
wget -c $SOURCE
fi

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

cd $TMP
tar xjvf $CWD/$NAME-$VERSION.tar.bz2
cd $NAME-$VERSION
mkdir -p $PKG/usr/lib/codecs
cp -a * $PKG/usr/lib/codecs
mkdir -p $PKG/usr/doc/$NAME-$VERSION
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $CWD
cp -a all.SlackBuild slack-desc $PKG/usr/doc/$NAME-$VERSION
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 $NAME-$VERSION
rm -rf $PKG
fi
