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

( cd $TMP
tar xjf $CWD/xsane-$VERSION.tar.bz2
cd xsane-$VERSION
chown -R root.root .
find . -perm 600 -exec chmod 644 {} \;
./configure --prefix=/usr
make
mkdir -p $PKG/usr/doc/xsane-$VERSION $PKG/usr/bin $PKG/usr/man/man1 $PKG/usr/share/sane/xsane/doc
cp -a xsane.* $PKG/usr/doc/xsane-$VERSION
cp -a doc/*.html doc/*.jpg $PKG/usr/share/sane/xsane/doc
cp -a src/*logo.xpm src/xsane-style.rc src/xsane-eula.txt src/xsane-gpl.txt src/xsane-calibration.pnm src/xsane-startimage.pnm $PKG/usr/share/sane/xsane
rm -f $PKG/usr/doc/xsane-$VERSION/*.spec*
chmod 644 $PKG/usr/doc/xsane-$VERSION/*
cat src/xsane > $PKG/usr/bin/xsane
chmod 755 $PKG/usr/bin/xsane
chown root.bin $PKG/usr/bin/xsane
strip --strip-unneeded $PKG/usr/bin/*
cat doc/xsane.1 |gzip -9c > $PKG/usr/man/man1/xsane.1.gz
cd po
for file in *.gmo ; do
    mkdir -p $PKG/usr/share/locale/`basename $file .gmo`/LC_MESSAGES
    cat $file > $PKG/usr/share/locale/`basename $file .gmo`/LC_MESSAGES/xsane.mo
done
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/xsane-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/xsane.build.log
