#!/usr/bin/env bash # R2: builds the .deb (tools/deb.sh) and checks it in a throwaway Debian 13 container, # never on this machine: # - it installs with apt, with only its Depends (no recommended graphics libraries); # - the desktop entry passes desktop-file-validate and its icons are in place; # - the dedicated server runs a bot match headless as an ordinary user, from PATH; # - the game itself starts headless, plays an offline match for a few seconds and # reports that it played; # - lintian, for information (its findings are printed, see docs/DEVLOG.md); # - it purges cleanly: no file it installed is left behind. # # tools/deb_check.sh about 3 minutes, needs Docker and Debian's mirrors set -uo pipefail repo="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$repo" tools/deb.sh || { echo "deb-check FAIL: tools/deb.sh failed"; exit 1; } deb="$(ls -t build/dist/tidewall_*_amd64.deb | head -n 1)" name="tidewall-deb-check-$$" cleanup() { docker rm -f "$name" >/dev/null 2>&1 || true; } trap cleanup EXIT docker run --rm --name "$name" --memory=3g --cpus=4 \ -v "$repo/$deb:/check/tidewall.deb:ro" debian:13 bash -c ' set -uo pipefail status=0 fail() { echo "deb-check FAIL: $*"; status=1; } export DEBIAN_FRONTEND=noninteractive apt-get update -qq >/dev/null || { echo "deb-check FAIL: apt-get update"; exit 1; } apt-get install -y -qq --no-install-recommends desktop-file-utils lintian >/dev/null 2>&1 || { echo "deb-check FAIL: tools"; exit 1; } echo "deb-check: install" apt-get install -y -qq --no-install-recommends /check/tidewall.deb >/tmp/install.log 2>&1 || { tail -n 20 /tmp/install.log; echo "deb-check FAIL: install"; exit 1; } dpkg -s tidewall | sed -n "s/^\(Status\|Version\): / \1: /p" dpkg -L tidewall | sort >/tmp/files echo "deb-check: desktop entry and icons" desktop-file-validate /usr/share/applications/tidewall.desktop && echo " desktop-file-validate: ok" || fail "desktop-file-validate" for side in 16 32 48 64 128 256; do [ -s "/usr/share/icons/hicolor/${side}x${side}/apps/tidewall.png" ] || fail "no ${side}px icon" done [ -s /usr/share/icons/hicolor/scalable/apps/tidewall.svg ] || fail "no scalable icon" [ -s /usr/share/doc/tidewall/copyright ] || fail "no copyright file" zcat /usr/share/doc/tidewall/ENGINE-LICENSES.gz >/tmp/engine-licenses grep -q "Permission is hereby granted" /tmp/engine-licenses || fail "no engine licence" man_ok=1 for page in tidewall tidewall-server; do [ -s "/usr/share/man/man6/$page.6.gz" ] || man_ok=0; done [ "$man_ok" -eq 1 ] || fail "manual pages missing" useradd -m player # A login shell, as the desktop has: its PATH has /usr/games, root'"'"'s does not. exec_name="$(sed -n "s/^Exec=//p" /usr/share/applications/tidewall.desktop)" su - player -c "command -v $exec_name" >/dev/null || fail "the entry runs $exec_name, which is not on a user'"'"'s PATH" echo "deb-check: the server, headless, as a user" su - player -c "tidewall-server --seed=2 --bots=24 --ticks=900 --unthrottled" >/tmp/server.log 2>&1 code=$? [ "$code" -eq 0 ] || { tail -n 5 /tmp/server.log; fail "the server exited $code"; } grep -q "\"event\":\"start\"" /tmp/server.log || fail "the server never started" grep -q "\"errors\":0,\"event\":\"stop\"" /tmp/server.log || fail "the server logged errors" grep -m1 "\"event\":\"stop\"" /tmp/server.log | cut -c1-160 | sed "s/^/ /" echo "deb-check: the game, headless, an offline match" su - player -c "tidewall --headless -- --offline --autoplay --client-seconds=15" >/tmp/game.log 2>&1 code=$? report="$(grep -m1 "\"event\":\"client\"" /tmp/game.log || true)" echo " ${report:0:200}" [ "$code" -eq 0 ] || { tail -n 5 /tmp/game.log; fail "the game exited $code"; } [ -n "$report" ] || fail "the game printed no report" if grep -qE "^(ERROR|SCRIPT ERROR|WARNING: .*leaked)" /tmp/game.log; then grep -m3 -E "^(ERROR|SCRIPT ERROR|WARNING)" /tmp/game.log | sed "s/^/ /"; fail "the game logged errors"; fi ls -d /home/player/.local/share/godot/app_userdata/Tidewall >/dev/null 2>&1 && echo " user data in ~/.local/share/godot/app_userdata/Tidewall" echo "deb-check: lintian (for information)" lintian --tag-display-limit 0 /check/tidewall.deb 2>&1 | sed "s/^/ /" || true echo "deb-check: purge" apt-get purge -y -qq tidewall >/tmp/purge.log 2>&1 || fail "purge" dpkg -s tidewall >/dev/null 2>&1 && fail "still installed after purge" left=0 while read -r path; do case "$path" in /.|/|/usr|/usr/share/man|/usr/share/man/man6|/usr/games|/usr/lib|/usr/share|/usr/share/*/|/usr/share/applications|/usr/share/doc|/usr/share/icons|/usr/share/icons/hicolor|/usr/share/icons/hicolor/*/apps|/usr/share/icons/hicolor/*) [ -d "$path" ] && continue ;; esac if [ -e "$path" ]; then echo " left behind: $path"; left=1; fi done