#!/bin/sh
# Heavily based on the Slackware 12.2 SlackBuild
# http://f4l.sourceforge.net/
# Packagers Gohanz ( gohanz@infinito.ii)
# http://www.slacky.it

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package-f4l
NAME=f4l
VERSION=`date +%Y%m%d`
ARCH=${ARCH:-i686}
BUILD=1as

if [ ! -d $TMP ]; then
 mkdir -p $TMP
fi
if [ ! -d $PKG ]; then
 mkdir -p $PKG
fi

cd $TMP
cvs -z9 -d:pserver:anonymous@f4l.cvs.sf.net:/cvsroot/f4l co f4l-0.2

cd $NAME-0.2
qmake
make
mkdir -p $PKG/usr/doc/$NAME-$VERSION
cp -a COPYING $PKG/usr/doc/$NAME-$VERSION
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
mkdir -p $PKG/usr/bin
cp -f $TMP/$NAME-0.2/bin/f4l  $PKG/usr/bin/f4l
mkdir -p $PKG/usr/share/pixmaps
mkdir -p $PKG/usr/share/applications/
cp -f $TMP/$NAME-0.2/src/cursor/main_ico.xpm $PKG/usr/share/pixmaps/f4l.xpm
cp -f $CWD/f4l.desktop $PKG/usr/share/applications/f4l.desktop
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/slack-desc > $PKG/usr/doc/$NAME-$VERSION/slack-desc
cat $CWD/$NAME.SlackBuild > $PKG/usr/doc/$NAME-$VERSION/$NAME.SlackBuild
cd $PKG
find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
chown -R root:root .
requiredbuilder -v -y -s $CWD $PKG
makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz

if [ "$1" = "--cleanup" ]; then
 rm -rf $TMP
fi
