summaryrefslogtreecommitdiffstats
path: root/games/jfsw_registered_data/jfsw_registered_data.SlackBuild
blob: 7dca1ca21075f4f022e931c2f01a5a2c3eade2df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/sh

# Slackware build script for jfsw_registered_data

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

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

# This game is offered as a free download on both Steam and GoG. It also
# was available from www.oldpcgaming.net from 2014 to late 2019, and
# has been available on archive.org since late 2018.

# 20200428 bkw: the old .7z from oldpcgaming.net has vanished along
# with the site. Switched to a CD image from archive.org, in bin/cue
# format. More work for this script to do, but as a nice bonus, we get
# the CD audio tracks installed too.

PRGNAM=jfsw_registered_data
VERSION=${VERSION:-1.2}
BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}

# Depending on what was used to do the download, the %XX hex escapes
# might get interpreted or not, handle either name.
SRCNAM="Shadow Warrior (USA)"
ZIPNAME1="$SRCNAM.zip"
ZIPNAME2="Shadow%20Warrior%20%28USA%29.zip"

ARCH=noarch
CWD=$(pwd)
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

[ -e "$CWD/$ZIPNAME1" ] && ZIPNAME="$ZIPNAME1" || ZIPNAME="$ZIPNAME2"
unzip "$CWD/$ZIPNAME"
chown -R root:root .
chmod 644 *

# The "source" file is a bin/cue cdrom image with multiple .bin files.
# It took some effort to get bchunk to extract this correctly, and I've
# moved the code into a separate script so that users of other distros
# can possibly make use of it. In fact it's been tested on MacOSX :)
sh $CWD/extract-shadow-warrior.sh "$SRCNAM.cue"

# Loop mount the iso to extract the stuff we need from it.
# N.B. sandbox wrappers like sbrun or slackrepo might complain that
# /etc/mtab has been modified. We could prevent this by using the
# --no-mtab option with the mount and umount commands below, but
# if something makes the script die before it's finished, we would
# have left behind an invisible mount that could cause confusion and
# irritation later...
MNTPNT="$( mktemp -d cdmount.XXXXXX )"
mount -o loop track01.iso $MNTPNT

cd $MNTPNT/swinst
  mkdir -p $PKG/usr/share/games/jfsw
  install -m0644 SW.GRP $PKG/usr/share/games/jfsw/sw_registered.grp

  mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  for i in CREDITS.TXT license.txt; do
    sed 's,\r,,' < $i > $PKG/usr/doc/$PRGNAM-$VERSION/$( echo $i | tr A-Z a-z )
  done
cd -

cat $MNTPNT/sw.ico > $PKG/usr/doc/$PRGNAM-$VERSION/sw.ico
umount $MNTPNT
rmdir $MNTPNT

# Done with the iso, now for the audio tracks (which have already been
# converted to ogg).
mkdir -p $PKG/usr/share/games/jfsw
cp track??.ogg $PKG/usr/share/games/jfsw

cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

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

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