#!/bin/sh
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-whois
VERSION=4.7.27
ARCH=alpha
BUILD=1

rm -rf $PKG
mkdir -p $PKG
( cd $TMP
rm -rf whois-$VERSION
tar xzf $CWD/whois_$VERSION.tar.gz
cd whois-$VERSION
chown -R root.root .
make || exit 1
mkdir -p $PKG/usr/bin
cat whois > $PKG/usr/bin/whois
chmod 755 $PKG/usr/bin/whois
chown -R root:bin $PKG/usr/bin
( cd po
 make
 for n in de.mo el.mo es.mo fr.mo it.mo no.mo pl.mo; do \
 l=`basename $n .mo`; \
 /usr/bin/install -c -m 755 -d $PKG/usr/share/locale/$l; \
 /usr/bin/install -c -m 755 -d $PKG/usr/share/locale/$l/LC_MESSAGES; \
 /usr/bin/install -c -m 644 $n $PKG/usr/share/locale/$l/LC_MESSAGES/whois.mo; \
 done
)
mkdir -p $PKG/usr/man/man1
cat whois.1 | gzip -9c > $PKG/usr/man/man1/whois.1.gz
mkdir -p $PKG/usr/doc/whois-$VERSION
cp -a COPYING README $PKG/usr/doc/whois-$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
cd $PKG
makepkg -l y -c n $TMP/whois-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/whois.build.log
