#!/bin/sh
# Slackbuild for likepython
# Written by JK Wood <joshuakwood@gmail.com>
#
# SlackBuild is released under the Dog-on-Fire License:
# If use of the SlackBuild causes your dog to catch on fire,
# you agree to send me five dollars.  Or a picture
# of the dog on fire.
# Otherwise, you're on your own.  I've tested it
# on my own computer, and it hasn't broken anything.
# So if it does it on your computer, that falls in
# the realm of "Not my problem."
#
# Of course, if you'll send a bug report to the above
# email address, I may be able to see what you did
# wrong and prevent it from happening in the future.
# In which case, I may just send YOU five dollars.

PRGNAM=likepython
VERSION=${VERSION:-0.1}
ARCH=noarch
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP || exit 1
rm -rf $PRGNAM-$VERSION
mkdir $PRGNAM-$VERSION
tar -xzvf $CWD/$PRGNAM\_$VERSION.tgz -C $PRGNAM-$VERSION|| exit 1
cd $PRGNAM-$VERSION || exit 1
chown -R root:root .
find -L . \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 -o -perm 511 \) \
 -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
  -exec chmod 644 {} \;

mkdir -p $PKG/usr/bin
cp -a likepython $PKG/usr/bin
chmod 755 $PKG/usr/bin/likepython

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a README hello_world.lp \
  $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
cat $CWD/LICENSE > $PKG/usr/doc/$PRGNAM-$VERSION/LICENSE
find $PKG/usr/doc -type f -exec chmod 644 {} \;

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}
