#!/bin/sh
#
# Heavily based on the Slackware 12.2 SlackBuild
#
# Packager: AsPh4lTo aka albatros_la
#

CWD=$(pwd)
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package-matplotlib
NAME=matplotlib
VERSION=0.98.5.3
ARCH=${ARCH:-i486}
BUILD=1sl

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

cd $TMP
tar xzvf $CWD/$NAME-$VERSION.tar.gz
cd $NAME-$VERSION
chown -R root:root .
chmod -R u+w,go+r-w,a-s .
python setup.py build
python setup.py install --root=$PKG
mkdir -p $PKG/usr/doc/$NAME-$VERSION
cp -a *.txt CHANGELOG INTERACTIVE KNOWN_BUGS TODO  $PKG/usr/doc/$NAME-$VERSION
cd $PKG
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
ADD="numpy >= 1.3.0-i486-1sl, wxpython >= 2.8.10.1-i486-1pv" \
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
