#!/bin/bash

# Slackware build script for lddsafe

# Written by B. Watson (yalhcru@gmail.com)

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

# 20210228 bkw: I've been using this for years, never got around
# to making a SBo build for it until now. Since it's only one
# self-contained shell script and one README, no point dealing with a
# tarball at all, just link to the 'raw' files on github.

PRGNAM=lddsafe
VERSION=${VERSION:-20110819_02842ba}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}

ARCH=noarch

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

set -e

rm -rf $PKG
mkdir -p $OUTPUT \
  $PKG/usr/bin $PKG/usr/doc/$PRGNAM-$VERSION $PKG/usr/man/man1 $PKG/install
install -m0755 -oroot -groot $CWD/$PRGNAM $PKG/usr/bin/$PRGNAM
gzip -9c < $CWD/$PRGNAM.1 > $PKG/usr/man/man1/$PRGNAM.1.gz
install -m0644 -oroot -groot $CWD/README.textile $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
cat $CWD/slack-desc > $PKG/install/slack-desc

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