#!/bin/bash

# Slackware build script for hexen_demo_data

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

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

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

PRGNAM=hexen_demo_data
VERSION=${VERSION:-1.1}
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}

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
mkdir -p $PRGNAM-$VERSION
cd $PRGNAM-$VERSION
unzip -a $CWD/hexndemo.zip '*.WAD' '*.TXT'

# Install as hexdemo.wad rather than hexen.wad. ZDoom will accept either,
# and this way we don't stomp on the hexen.wad from the full version of
# the game.
mkdir -p $PKG/usr/share/games/doom
install -m0644 HEXEN.WAD $PKG/usr/share/games/doom/hexdemo.wad

PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC
cat README.TXT > $PKGDOC/README.txt
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild

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
