#!/bin/sh
# Heavily based on the Slackware 12.2 SlackBuild
# Packager baldelario ~at~ gmail ~dot~ com
# http://www.muhri.net/gthemeswitch.php3
# http://www.slacky.it

NAME=gtk-theme-switch
VERSION=1.0.1
ARCH=${ARCH:-i686}
BUILD=3bj

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package-$NAME

cd $TMP
rm -rf $PKG
mkdir -p $PKG/usr/{bin,man/man1,share/applications,share/pixmaps}
rm -rf $NAME-$VERSION
tar xzvf $CWD/$NAME-$VERSION.tar.gz
cd $NAME-$VERSION
chown -R root:root .
make

cat switch > $PKG/usr/bin/switch
chmod 755 $PKG/usr/bin/*
gzip -9c switch.1 > $PKG/usr/man/man1/switch.1.gz
cp expand.xpm $PKG/usr/share/pixmaps/switch.xpm

cat << EOF > $PKG/usr/share/applications/switch.desktop
[Desktop Entry]
Type=Application
Name=Switch
Encoding=UTF-8
Exec=switch
GenericName=GTK1 Theme Switcher
Icon=/usr/share/pixmaps/switch.xpm
Terminal=false
Categories=Qt;KDE;Settings;
EOF

mkdir -p $PKG/usr/doc/$NAME-$VERSION
cp -a ChangeLog readme todo $PKG/usr/doc/$NAME-$VERSION

cd $PKG
mkdir -p $PKG/install
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
chown -R root:root .
requiredbuilder -y -v -s $CWD $PKG
makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz

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