#!/bin/bash

# Slackware build script for Sl

# Written by B. Watson (urchlay@slackware.uk)

# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.

# There's already an "sl" on SBo, so this is named Sl. The version number
# comes from the -version option.

cd $(dirname $0) ; CWD=$(pwd)

PRGNAM=Sl
VERSION=${VERSION:-1.1.3}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}
ARCH=noarch

if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  exit 0
fi

TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

SRCNAM="sl"

PKGBIN=$PKG/usr/bin
PKGMAN1=$PKG/usr/man/man1
PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
PKGINST=$PKG/install

set -e

rm -rf $PKG
mkdir -p $OUTPUT $PKGBIN $PKGDOC $PKGMAN1 $PKGINST

# Look, Ma, no source directory!
cat $SRCNAM > $PKGBIN/$PRGNAM
chmod 755 $PKGBIN/$PRGNAM

gzip -9c < $PRGNAM.1 > $PKGMAN1/$PRGNAM.1.gz

# README.upstream is just a text rendition of the homepage, sl.tcl-example
# is linked to by the homepage.
cat README.upstream > $PKGDOC/README.txt
cat sl.tcl.example > $PKGDOC/sl.tcl.example
cat README > $PKGDOC/README_SBo.txt
cat $PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild

cat slack-desc > $PKGINST/slack-desc
cat $CWD/doinst.sh > $PKGINST/doinst.sh

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