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

VERSION=0.5.2
ARCH=i486
BUILD=2

cd $TMP
rm -rf utempter-$VERSION
tar xzvf $CWD/utempter-$VERSION.tar.gz
cd utempter-$VERSION
chown -R root.root .
find . -perm 664 -exec chmod 644 {} \;
find . -perm 775 -exec chmod 755 {} \;
make
strip --strip-unneeded libutempter.so utempter
mkdir -p $PKG/usr/lib
cat libutempter.so > $PKG/usr/lib/libutempter.so.$VERSION
chmod 755 $PKG/usr/lib/libutempter.so.$VERSION
( cd $PKG/usr/lib
  ln -sf libutempter.so.$VERSION libutempter.so.`echo $VERSION | cut -f 1 -d .`
  ln -sf libutempter.so.$VERSION libutempter.so
)
mkdir -p $PKG/usr/sbin
cat utempter > $PKG/usr/sbin/utempter
chown root.utmp $PKG/usr/sbin/utempter
chmod 2755 $PKG/usr/sbin/utempter
chown root.bin $PKG/usr/sbin
mkdir -p $PKG/usr/include
cp -a utempter.h $PKG/usr/include/utempter.h
chmod 644 $PKG/usr/include/utempter.h
mkdir -p $PKG/usr/doc/utempter-$VERSION
cp -a COPYING $PKG/usr/doc/utempter-$VERSION
chmod 644 $PKG/usr/doc/utempter-$VERSION/COPYING
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

