#!/bin/sh
# Set initial variables:
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-lsof
VERSION=4.72
ARCH=alpha
BUILD=1

rm -rf $PKG
mkdir -p $PKG
( cd $TMP
tar xjf $CWD/lsof_${VERSION}_src.tar.bz2
cd lsof_${VERSION}_src
zcat $CWD/lsof.patch.gz | patch -p0
echo n | ./Configure linux
make
strip lsof
mkdir -p $PKG/usr/bin
cat lsof > $PKG/usr/bin/lsof
# No, NOT suid.
chmod 755 $PKG/usr/bin/lsof
chown -R root.bin $PKG/usr/bin
mkdir -p $PKG/usr/man/man8
cat lsof.8 | gzip -9c > $PKG/usr/man/man8/lsof.8.gz
mkdir -p $PKG/usr/doc/lsof-$VERSION
cp -a 00* $PKG/usr/doc/lsof-$VERSION
chmod 644 $PKG/usr/doc/lsof-$VERSION/*
chown root.root $PKG/usr/doc/lsof-$VERSION/*
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/lsof-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/lsof.build.log
