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

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-bootparamd-0.17
tar xzvf $CWD/netkit-bootparamd-0.17.tar.gz || exit 1
cd netkit-bootparamd-0.17
chown -R root:root .
./configure --prefix=/usr
make || exit 1
cd rpc.bootparamd
strip bootparamd callbootd
mkdir -p $PKG/usr/{bin,sbin}
cat bootparamd > $PKG/usr/sbin/rpc.bootparamd
chmod 755 $PKG/usr/sbin/rpc.bootparamd
cat callbootd > $PKG/usr/bin/callbootd
chmod 755 $PKG/usr/bin/callbootd
mkdir -p $PKG/usr/man/man8
gzip -9c bootparamd.8 > $PKG/usr/man/man8/rpc.bootparamd.8.gz
mkdir -p $PKG/usr/doc/netkit-bootparamd-0.17
cp -a README $PKG/usr/doc/netkit-bootparamd-0.17
chown root:root $PKG/usr/doc/netkit-bootparamd-0.17/*
chmod 644 $PKG/usr/doc/netkit-bootparamd-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-bootparamd-$VERSION-$ARCH-$BUILD.tgz