324.8. sauerbraten-2020.12.29
Cube 2 engine shooter with in-game co-operative map editing, and its data
| Version | 2020.12.29, release 3 |
| Shelf | games-shooter — First-person shooters, Doom and Quake engines, and their data |
| Phase | 44_apps (Applications), 200 of 422 in build order |
| Licence | Zlib AND LicenseRef-Sauerbraten-Data |
| Homepage | http://sauerbraten.org |
| Build time | 3.7 SBU |
| Installed size | 1012.2 MiB in 8972 files |
| Recipe | ports/core/games-shooter/sauerbraten/kpkgbuild |
About
Cube 2: Sauerbraten is a fast first-person shooter on the Cube 2 engine, best known for its in-game map editing, which several players can do together on one server. The release archive carries the source, the complete game data and prebuilt engines; this port compiles the client and the server from the source, installs the data, and never installs the prebuilt engines in bin_unix/.
Sources
sauerbraten-2020.12.29.tar.bz2(940.2 MiB)
sha256cdba7c4a47cefd30d0afdd6a912199a1384319cf1619923cb7189e72e468be70
upstream: https://downloads.sourceforge.net/sauerbraten/sauerbraten_2020_12_29_linux.tar.bz2
archive copy: sources-2/games-shooter--sauerbraten-2020.12.29.tar.bz2
Dependencies
Depends on: pkgconf, sdl2-compat, sdl2-image, sdl2-mixer, zlib, libX11, libglvnd, mesa.
Required by: no port names it.
Patches
build.sh applies these; kpkg applies nothing by itself.
placement-new.patch— Insrc/shared/tools.h, replaces the engine’s own inline definitions of placementnew,new[],deleteanddelete[]with#include <new>.cube.hincludes<math.h>beforetools.h, and libstdc++’s<math.h>brings in<new>through<cmath>, so a second definition of those operators does not compile.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/44_apps/phase.env && kpkg install sauerbraten'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/games-shooter/sauerbraten.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/games-shooter/sauerbraten
echo 'cdba7c4a47cefd30d0afdd6a912199a1384319cf1619923cb7189e72e468be70 sauerbraten-2020.12.29.tar.bz2' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/sauerbraten
SRC=$SRC_ROOT/sauerbraten-2020.12.29
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf sauerbraten-2020.12.29.tar.bz2 -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 -i "$PORT_SRC/placement-new.patch"
cd src
make \
CFLAGS="$CFLAGS -O3 -fomit-frame-pointer" \
CXXFLAGS="$CXXFLAGS -O3 -fomit-frame-pointer -ffast-math" \
CLIENT_INCLUDES="-Ishared -Iengine -Ifpsgame -Ienet/include $(pkg-config --cflags sdl2)" \
CLIENT_LIBS="$LDFLAGS -Lenet -lenet -lX11 $(pkg-config --libs sdl2) -lSDL2_image -lSDL2_mixer -lz -lGL -lrt" \
SERVER_LIBS="$LDFLAGS -Lenet -lenet -lz" \
client server
install -Dm755 sauer_client "$PKG/usr/lib/sauerbraten/sauer_client"
install -Dm755 sauer_server "$PKG/usr/lib/sauerbraten/sauer_server"
cd ..
install -d "$PKG/usr/share/sauerbraten"
cp -R data packages server-init.cfg "$PKG/usr/share/sauerbraten/"
install -d "$PKG/usr/share/doc/sauerbraten"
cp -R docs README.html "$PKG/usr/share/doc/sauerbraten/"
install -Dm644 src/readme_source.txt "$PKG/usr/share/licenses/$name/readme_source.txt"
install -Dm644 src/enet/LICENSE "$PKG/usr/share/licenses/$name/enet-LICENSE"
install -Dm644 data/license.txt "$PKG/usr/share/licenses/$name/data-license.txt"
install -Dm644 README.html "$PKG/usr/share/licenses/$name/README.html"
install -Dm644 data/cube.png \
"$PKG/usr/share/icons/hicolor/256x256/apps/sauerbraten.png"
install -d "$PKG/usr/bin"
cat > "$PKG/usr/bin/sauerbraten" <<'KDOS_SH'
#!/bin/sh
cd /usr/share/sauerbraten || exit 1
exec /usr/lib/sauerbraten/sauer_client "-q$HOME/.sauerbraten" "$@"
KDOS_SH
cat > "$PKG/usr/bin/sauerbraten-server" <<'KDOS_SH'
#!/bin/sh
cd /usr/share/sauerbraten || exit 1
exec /usr/lib/sauerbraten/sauer_server "-q$HOME/.sauerbraten" "$@"
KDOS_SH
chmod 755 "$PKG/usr/bin/sauerbraten" "$PKG/usr/bin/sauerbraten-server"
install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/sauerbraten.desktop" <<'DESKTOP'
[Desktop Entry]
Type=Application
Name=Cube 2: Sauerbraten
GenericName=First-Person Shooter
Comment=Fast shooter with co-operative in-game map editing
Exec=sauerbraten
Icon=sauerbraten
Terminal=false
StartupWMClass=sauer_client
Categories=Game;ActionGame;
Keywords=fps;shooter;cube;sauerbraten;editor;
DESKTOP
chmod 644 "$PKG/usr/share/applications/sauerbraten.desktop"
The switches, and why each is set:
CXXFLAGS— withCFLAGS: the tree’s flags followed by upstream’s own optimisation flags,-O3 -fomit-frame-pointer, and-ffast-mathfor C++. The engine’s makefile assignsCXXFLAGS= -O3 -fomit-frame-pointer -ffast-math, and the bundled ENet’s makefileCFLAGS=-O3 -fomit-frame-pointer; an assignment in a makefile takes precedence over the environment, so the tree’s flags reach the compiler only on themakeline, which also passes them down to ENet’s sub-make. Without them the file-prefix map is lost too, and the binary records the build path.CLIENT_INCLUDES— withCLIENT_LIBS: the client’s include and library lines, given whole. Upstream’s Linux lines callsdl2-config, which sdl2-compat does not install, so SDL2’s flags come frompkg-configinstead. The rest of each line is upstream’s: the bundled ENet,libX11, SDL2_image, SDL2_mixer, zlib,libGLandlibrt.CLIENT_LIBSbegins with the tree’sLDFLAGS, which the makefile’s link line does not otherwise read.SERVER_LIBS— the server’s library line, upstream’s, with the tree’sLDFLAGSin front for the same reason.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/sauerbraten, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf sauerbraten-2020.12.29-3.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/sauerbraten, and runs the triggers its paths call for.
Contents
Installed programs: sauerbraten, sauerbraten-server.
Installed directories: /usr/lib/sauerbraten, /usr/share/doc/sauerbraten, /usr/share/licenses/sauerbraten, /usr/share/sauerbraten.
Notes
The bundled ENet networking library, in src/enet, is built and linked statically by the makefile’s libenet target before the client and the server.
The engine reads its data from the working directory and writes the player’s configuration, maps and demos to the home directory given with -q. Upstream’s sauerbraten_unix launcher does the same, so build.sh installs the programs in /usr/lib/sauerbraten, the data in /usr/share/sauerbraten, and /usr/bin/sauerbraten and /usr/bin/sauerbraten-server as small scripts that change into the data directory and start the engine with -q$HOME/.sauerbraten. The window’s Wayland app id is SDL’s default, the executable’s name, sauer_client, which is what StartupWMClass names.