aboutsummaryrefslogtreecommitdiff
path: root/games/solarwolf/solarwolf.SlackBuild
blob: 2475a2ad4238b9a9f09689d9cca6a908567ea40a (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash

# Slackware build script for solarwolf

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

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

# 20211228 bkw: BUILD=2.
# SDL2_mixer on -current utterly lacks support for tracker music
# (.mod, .it, .xm, etc). This game's music is in .xm format... so
# unless/until Pat adds support in SDL2_mixer, this script works
# around it by using timidity to convert the .xm music to .ogg, which
# SDL2_mixer can handle.
# Add TiMidity++ as a dep, to make this work. It's really only
# build-time, not runtime.
# Also, new-style icon.

# TODO: when running in windowed mode, clicking the window's close
# button does close the window, but leaves the game process running.
# using the Quit option from the main menu works correctly.

# TODO: scaling in fullscreen mode. our pygame is built with SDL2,
# this should be possible.

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

PRGNAM=solarwolf
VERSION=${VERSION:-1.5}
BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i586 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

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}

if [ "$ARCH" = "i586" ]; then
  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIRSUFFIX="64"
else
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
fi

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
cd $PRGNAM-$VERSION
chown -R root:root .

# upstream permissions are especially bletcherous
find . -type d -print0 | xargs -0 chmod 0755
find . -type f -print0 | xargs -0 chmod 0644
find . -name .xvpics -print0 | xargs -0 rm -rf

mkdir -p \
  $PKG/usr/games \
  $PKG/usr/share/games/$PRGNAM \
  $PKG/usr/share/icons/hicolor/64x64/apps \
  $PKG/usr/share/pixmaps \
  $PKG/usr/share/applications \
  $PKG/usr/man/man6

# 20211228 bkw: convert the music to .ogg. Use separate oggenc instead
# of timidity's -Ov, so we can set the bitrate to 64k (to match the
# one .ogg file shipped with the source). This bloats the package by
# 30%, but it still comes out to less than 4MB total, so no problem.
for i in data/music/*.xm; do
  out="data/music/$( basename $i .xm ).ogg"
  timidity -Ow1sl -id -o- $i | oggenc -Q -b 64 -o $out -
  rm -f $i
done

# 20211228 bkw: make the game play the converted .ogg music.
sed -i 's,\.xm,.ogg,g' code/game*.py

# the code is all python, keep in /usr/share along with the game data.
sed -i "s,usr/lib/games/$PRGNAM,usr/share/games/$PRGNAM/code," $PRGNAM.py

cp -a code data $PKG/usr/share/games/$PRGNAM
install -oroot -groot -m0755 $PRGNAM.py $PKG/usr/games/$PRGNAM

# original .desktop file don't validate, use our own
cat $CWD/$PRGNAM.desktop > $PKG/usr/share/applications/$PRGNAM.desktop

cat dist/$PRGNAM.png > $PKG/usr/share/icons/hicolor/64x64/apps/$PRGNAM.png
ln -s ../icons/hicolor/64x64/apps/$PRGNAM.png $PKG/usr/share/pixmaps/$PRGNAM.png

cat dist/$PRGNAM.6.gz > $PKG/usr/man/man6/$PRGNAM.6.gz

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a *.txt $PKG/usr/doc/$PRGNAM-$VERSION
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