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

VERSION=0.17
ARCH=${ARCH:-i486}
BUILD=1

if [ ! -d $TMP ]; then
  mkdir -p $TMP # location to build the source
fi
rm -rf $PKG
mkdir -p $PKG

cd $TMP
rm -rf netkit-rwall-0.17
tar xzvf $CWD/netkit-rwall-0.17.tar.gz || exit 1
cd netkit-rwall-0.17
chown -R root:root .
./configure --prefix=/usr
make || exit 1
cd rpc.rwalld
strip rwalld
mkdir -p $PKG/usr/sbin
cat rwalld > $PKG/usr/sbin/rpc.rwalld
chmod 755 $PKG/usr/sbin/rpc.rwalld
mkdir -p $PKG/usr/man/man{1,8}
cat rpc.rwalld.8 | gzip -9c > $PKG/usr/man/man8/rpc.rwalld.8.gz
cd ../rwall
strip rwall
mkdir -p $PKG/usr/bin
cat rwall > $PKG/usr/bin/rwall
chmod 755 $PKG/usr/bin/rwall
cat rwall.1 | gzip -9c > $PKG/usr/man/man1/rwall.1.gz
cd ..
mkdir -p $PKG/usr/doc/netkit-rwall-0.17
cp -a README $PKG/usr/doc/netkit-rwall-0.17
chown root:root $PKG/usr/doc/netkit-rwall-0.17/*
chmod 644 $PKG/usr/doc/netkit-rwall-0.17/*

# Finish up the package:
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

# Build the package:
cd $PKG
makepkg -l y -c n $TMP/netkit-rwall-$VERSION-$ARCH-$BUILD.tgz