#!/bin/sh
# Heavily based on the Slackware 11.0 SlackBuild
# Packager Andrea Sciucca ( gohanz at infinito.it)
# Script By slux83@gmail.com - www.capponcino.it/alessio
# http://www.slacky.it
# Required: Firefox-2.0

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package/slacky_search_plugin
NAME=slacky_search_plugin
VERSION=`date +%Y%m%d`
ARCH=${ARCH:-noarch}
BUILD=1as
SOURCE=http://www.capponcino.it/alessio/files/linux/search_plugins-FF2/slacky.xml

if [ ! -e slacky.xml ]; then
wget -c $SOURCE
fi

SOURCE=http://www.capponcino.it/alessio/files/linux/search_plugins-FF2/slacky_forum.xml

if [ ! -e slacky_forum.xml ]; then
wget -c $SOURCE
fi

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

cd $TMP

echo -e "\E[0;32m+------------------------------------------------+\E[0;0m"
echo -e "\E[0;32m| Start SlackBuild $NAME-$VERSION |\E[0;0m"
echo -e "\E[0;32m+------------------------------------------------+\E[0;0m"

chown -R root:root .

mkdir -p $PKG/usr/lib/firefox/searchplugins
cp -a $CWD/slacky.xml slacky_forum.xml $PKG/usr/lib/firefox/searchplugins
cp -a $CWD/slacky_forum.xml $PKG/usr/lib/firefox/searchplugins

mkdir -p $PKG/usr/doc/$NAME-$VERSION

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

cd $PKG
makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz

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