#!/bin/sh
# Set initial variables:
CWD=`pwd`
if [ "$TMP" = "" ]; then
  TMP=/tmp
fi
PKG=$TMP/package-up

if [ ! -d $TMP ]; then
  mkdir -p $TMP # location to build the source
fi
if [ ! -d $PKG ]; then
  mkdir -p $PKG # place for the package to be built
fi

# Explode the package framework:
cd $PKG
explodepkg $CWD/_up.tar.gz

echo "+========+"
echo "| up-0.3 |"
echo "+========+"
cd $TMP
tar xzvf $CWD/up-0.3.tar.gz
cd up-0.3
make
strip up
cat up > $PKG/usr/bin/up
cat up.1 | gzip -9c > $PKG/usr/man/man1/up.1.gz
cp -a README INSTALL ChangeLog COPYING $PKG/usr/doc/up-0.3

# Build the package:
cd $PKG
echo "n" | makepkg $TMP/up.tgz

# Clean up the extra stuff:
if [ "$1" = "--cleanup" ]; then
  rm -rf $TMP/up-0.3
  rm -rf $PKG
fi