#!/bin/sh
# Set initial variables:
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-diff
VERSION=2.8.7
ARCH=alpha
BUILD=1
TARGET=$ARCH-alphaslack-linux

rm -rf $PKG
mkdir -p $PKG
( cd $TMP
rm -rf diffutils-$VERSION
tar xzf $CWD/diffutils-$VERSION.tar.gz
cd diffutils-$VERSION
zcat $CWD/diffutils-sdiff-no-waitpid.patch.gz | patch -p1 || exit
bzcat $CWD/diffutils-2.8.7-i18n.patch.bz2 | patch -p1 || exit
# Prevent ruining sdiff.1 by touching it so it won't "regenerate":
touch man/sdiff.1
chown -R root.root .
./configure \
 --prefix=/usr \
 --build=$TARGET
make || exit
make install DESTDIR=$PKG
( cd $PKG/usr/bin
  strip *
  chown -R root.bin .
)
rm -f $PKG/usr/info/dir
gzip -9 $PKG/usr/info/*info
gzip -9 $PKG/usr/man/man1/*
mkdir -p $PKG/usr/doc/diffutils-$VERSION
cp -a ABOUT-NLS AUTHORS COPYING NEWS README THANKS $PKG/usr/doc/diffutils-$VERSION
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/diffutils-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/diffutils.build.log
