#!/bin/sh
# Heavily based on the Slackware 13.0 SlackBuild
# http://ant.apache.org
# Packager baldelario ~at~ gmail ~dot~ com
# SubPackager easy77
# http://www.slacky.it

CWD=`pwd`
TMP=${TMP:-/tmp/txz}
PKG=$TMP/package-apache-ant
rm -rf $PKG
mkdir -p $PKG/etc/profile.d
mkdir -p $PKG/usr/{bin,lib/ant}

NAME=apache-ant
VERSION=1.7.1
ARCH=i586
BUILD=3bj

cd $TMP
rm -rf $NAME-$VERSION
tar jxvf $CWD/$NAME-$VERSION-bin.tar.bz2
cd $NAME-$VERSION
chown -R root:root .
cp -rf * $PKG/usr/lib/ant

ln -sf /usr/lib/ant/bin/ant $PKG/usr/bin/ant
rm -rf $PKG/usr/lib/ant/bin/{*.bat,*.cmd}
rm -rf $PKG/usr/lib/ant/docs

( cd $PKG/etc/profile.d; tar xzvf $CWD/profile.d.tar.gz
  chmod 755 $PKG/etc/profile.d/*
)

mkdir -p $PKG/usr/doc/$NAME-$VERSION
mv $PKG/usr/lib/ant/{KEYS,LICENS*,README,NOTICE,WHATSNEW,INSTALL} $PKG/usr/doc/$NAME-$VERSION

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

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

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

