#!/bin/sh
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-bin
VERSION=8.3.2
ARCH=alpha
BUILD=5
TARGET=$ARCH-alphaslack-linux

rm -rf $PKG
mkdir -p $PKG
( cd $TMP
rm -rf debianutils-3.2.3
tar xf $CWD/debianutils_3.2.3.tar.bz2
cd debianutils-3.2.3
./configure \
 --prefix=/usr \
 --mandir=/usr/man \
 --build=$TARGET || exit
make || exit
make install DESTDIR=$PKG || exit
rm -rf $PKG/usr/man/man1/which.1
rm -rf $PKG/usr/man/man8/run-parts.8

cd $TMP
tar xzf $CWD/banners.tar.gz
cd banners
make || exit
cat bban > $PKG/usr/bin/bban
cat sysvbanner > $PKG/usr/bin/sysvbanner
chmod 755 $PKG/usr/bin/{bban,sysvbanner}

# These are a couple of really old scripts that might still
# be useful for a couple more years.  :-)
cat $CWD/scripts/diskcopy > $PKG/usr/bin/diskcopy
cat $CWD/scripts/xx > $PKG/usr/bin/xx
chmod 755 $PKG/usr/bin/diskcopy
chmod 755 $PKG/usr/bin/xx

gzip -9 $PKG/usr/man/{fr/man?,man?}/*.?

( cd $PKG
 find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
 find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
)

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
echo "n" | makepkg $TMP/bin-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/bin.build.log
