CWD=$(pwd)
TMP=/tmp
PKG=$TMP/package-utempter
rm -rf $PKG
mkdir -p $PKG/usr

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

cd $TMP
# The original package name was "utempter", but this new version
# calls itself "libutempter".  We'll keep the same old package name
# to avoid confusing upgrades.
rm -rf libutempter-$VERSION
tar xjvf $CWD/libutempter-$VERSION.tar.bz2
cd libutempter-$VERSION
chown -R root:root .
## I see no reason to use different paths than in utempter-0.5.2:
#zcat $CWD/libutempter.slack.diff.gz | patch -p1 --verbose || exit 1
find . -perm 664 -exec chmod 644 {} \;
find . -perm 775 -exec chmod 755 {} \;
make
make install DESTDIR=$PKG
# A static libutempter seems like a bad idea, since it wouldn't work
# without the making utempter binary.  That and the shared lib are a
# closely matched set.
rm -f $PKG/usr/lib/libutempter.a
# Set proper permissions:
chown root:utmp $PKG/usr/lib/utempter/utempter
chmod 2755 $PKG/usr/lib/utempter/utempter
chmod 644 $PKG/usr/include/utempter.h
mkdir -p $PKG/usr/doc/utempter-$VERSION
cp -a \
  COPYING README \
  $PKG/usr/doc/utempter-$VERSION
( 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
zcat $CWD/doinst.sh > $PKG/install/doinst.sh

cd $PKG
makepkg -l y -c n $TMP/utempter-$VERSION-$ARCH-$BUILD.tgz