#!/bin/sh
# Heavily based on the Slackware 12.1 SlackBuild
# http://www.kde-apps.org/content/show.php/remotezip?content=75135
# Packager Michelino Chionchio - www.slacky.eu
# Depends on: pyqt4, qt4

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package-remote_zip
NAME=remote_zip
VERSION=0.1
ARCH=${ARCH:-noarch}
BUILD=2mch

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

mkdir -p $PKG/usr/share
cd $PKG/usr/share
tar xvjf $CWD/$NAME-$VERSION.tar.bz2
mv $NAME $NAME-$VERSION
cd $NAME-$VERSION

chown -R root:root .

mkdir -p $PKG/usr/bin
cat << EOF > $PKG/usr/bin/remote_zip
#! /bin/bash
cd /usr/share/remote_zip-0.1/
python remote_zip.py
EOF
chmod 755 $PKG/usr/bin/remote_zip

mkdir -p $PKG/usr/doc/$NAME-$VERSION
mv AUTHORS COPYING INSTALL README REQUIREMENTS $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

ADD="python >= 2.5.2-i486-1,pyqt4 >= 4.4.2-i486-1as,qt4 >= 4.4.0-i686-2as" \
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
