aboutsummaryrefslogtreecommitdiff
path: root/games/tetrinet/tetrinet.SlackBuild
blob: 8ef23c8dbfa533b4f453e11acf91afbe1a88e5b7 (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
#!/bin/bash

# Slackware build script for tetrinet

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

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

# I started writing this SlackBuid in 2020 and just now remembered to
# finish it. It's the same version packaged by Debian, so it should
# interoperate with servers running Debian.

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

PRGNAM=tetrinet
VERSION=${VERSION:-0.11+cvs20070911}
BUILD=${BUILD:-1}
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
tar xvf $CWD/${PRGNAM}_${VERSION^^}.orig.tar.gz
cd $PRGNAM
chown -R root:root .
find -L .  -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
        \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+

# 20230213 bkw: patch came from Debian:
# http://deb.debian.org/debian/pool/main/t/tetrinet/tetrinet_0.11+CVS20070911-2.1.debian.tar.xz
patch -p1 < $CWD/patches/gcc10.diff

# 20201120 bkw: fix compiler warnings, at least the ones that look like
# they might cause real problems.
patch -p1 < $CWD/patches/compilefix.diff

# 20201120 bkw: we're not building the server into the client, so don't
# offer it as an option in the help message.
sed -i '/^"  *-server/d' $PRGNAM.c

# 20201121 bkw: since we can't seem to get all the various terminals
# and ncurses to agree on the escape sequences for F1/F2/F3, allow
# switching windows with the Tab key. Grr.
patch -p1 < $CWD/patches/tab_key.diff

# 20201121 bkw: allow vi HJKL movement along with arrow keys. Also
# make the existing letter keystrokes case-insensitive.
patch -p1 < $CWD/patches/vikeys.diff

# 20201121 bkw: actually check the terminal size and abort if too
# small. This won't help if the user resizes the terminal while the
# game is running, but it's better than starting up an unplayable
# game.
patch -p1 < $CWD/patches/check_term_size.diff

# No other way to apply our flags...
sed -i "/CFLAGS/s|-g|$SLKCFLAGS|" Makefile

# *Finally*:
make

# Do not use 'make install', no DESTDIR or PREFIX/etc support.
PKGMAN6=$PKG/usr/man/man6
PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKG/usr/games $PKGMAN6 $PKGDOC

# Man pages come from upstream post-release CVS. I've fixed some
# typos, cleaned up the formatting, and documented all the stuff the
# patches do.
for i in $PRGNAM $PRGNAM-server; do
  install -s -m0755 $i $PKG/usr/games
  gzip -9c < $CWD/man/$i.6 > $PKGMAN6/$i.6.gz
done

# Original upstream calls the client "tetrinet", Debian calls it
# "tetrinet-client". Use symlinks to support both names.
ln -s $PRGNAM $PKG/usr/games/$PRGNAM-client
ln -s $PRGNAM.6.gz $PKG/usr/man/man6/$PRGNAM-client.6.gz

cp -a AUTHORS Change* README TODO $PRGNAM.txt $PKGDOC
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