#!/bin/sh
# Heavily based on Slackware 12.0 SlackBuild
#http://sancho-gui.sourceforge.net/

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package-sancho-gtk
NAME=sancho-gtk
VERSION=0.9.4.58
ARCH=i386
BUILD=1sid

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

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

cd $TMP
sh $CWD/sancho-0.9.4-58-linux-gtk.sh
cd sancho-0.9.4-58-linux-gtk
mkdir -p $PKG/usr/{bin,share/{sancho-gtk,applications}}
cp -R * $PKG/usr/share/sancho-gtk
cd $PKG/usr/bin
ln -s /usr/share/sancho-gtk/sancho .
cp $CWD/sancho.desktop $PKG/usr/share/applications/
mkdir -p $PKG/usr/doc/sancho-0.9.4-58
mkdir $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/slack-desc > $PKG/usr/doc/sancho-0.9.4-58/slack-desc
cat $CWD/sancho-gtk.SlackBuild > $PKG/usr/doc/sancho-0.9.4-58/sancho-gtk.SlackBuild

cd $PKG
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



