Files
tidewall/tools/dist.sh
T
claudeandClaude Opus 5.5 6873ba4ab4 R4: Originality and licence audit
- docs/ASSET_PROVENANCE.md traces each of the 162 files under assets/ to
  the script that generates it, or to its hand-written original (the app
  icon's SVG). It's written by tools/provenance.gd, and the new
  test_asset_provenance fails on a file with no rule, a rule naming a
  generator that doesn't exist, or a stale document. The release package
  and the .deb now ship it next to PROVENANCE.md (make dist-check and
  make deb-check pass).
- Searched code, data, assets, docs and packaging for commercial game
  names, characters, item and place names: none. The only matches are the
  genre wording ("battle royale") and, in the DEVLOG, an open-source engine
  another task uses. Item and place names are Tidewall's own (dock carbine,
  fowling piece, tern chapel...).
- Licence notices: the Godot engine's licence and its third-party notices
  (ENGINE-LICENSES.txt, generated from the engine) already ship in the
  tarball and the .deb's copyright; there are no other libraries, addons or
  fonts. CREDITS.md links the new trace.
- Name check for "Tidewall" noted on R7 (#66).

Closes #63

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:27:28 -05:00

108 lines
5.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# R1: exports the Linux x86_64 game, which is also the dedicated server, with the
# official Godot export templates and packs them into build/dist/tidewall-<version>-linux-x86_64.tar.gz.
#
# tools/dist.sh
#
# The templates come from tools/godot/ (git-ignored), checked against
# tools/engine.sha512 before use, and are installed into the repo-local engine data
# (.godot-home/), never the user's home. The version is project.godot's
# application/config/version; the commit is written into the export as
# build_commit.txt, which BuildInfo reads.
#
# The package holds:
# tidewall.x86_64 the engine (the official release template)
# tidewall.pck the game
# tidewall-server runs the same game headless as a dedicated server, with
# clean SIGTERM handling
# tidewall starts the game from this folder, from any directory (R2)
# install-desktop-entry.sh adds it to the user's application menu (R2)
# tidewall.png the application icon
# server.cfg an example server configuration
# ENGINE-LICENSES.txt the Godot engine's licence and its third-party notices
# LICENSE, LICENSE-ASSETS, README.md, PROVENANCE.md, ASSET_PROVENANCE.md, VERSION
set -euo pipefail
repo="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$repo"
engine_version="$(cut -d. -f1-3 tools/engine.version)" # 4.7.2
engine_tag="${engine_version}.$(cut -d. -f4 tools/engine.version)" # 4.7.2.stable
templates_zip="tools/godot/Godot_v${engine_version}-stable_export_templates.tpz"
templates_dir=".godot-home/data/godot/export_templates/$engine_tag"
version="$(sed -n 's/^config\/version="\(.*\)"$/\1/p' project.godot)"
[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "dist FAIL: no version in project.godot" >&2; exit 1; }
commit="$(git rev-parse --short=12 HEAD)"
if [[ -n "$(git status --porcelain --untracked-files=no)" ]]; then
commit="$commit-dirty"
fi
name="tidewall-$version-linux-x86_64"
out="build/dist"
stage="$out/stage"
package="$out/$name"
tools/godot.sh --verify >/dev/null
# The official templates, checked, then only the Linux x86_64 ones installed.
if [[ ! -f "$templates_dir/linux_release.x86_64" || "$(cat "$templates_dir/.verified" 2>/dev/null)" != "$(grep 'export_templates\.tpz$' tools/engine.sha512 | cut -d' ' -f1)" ]]; then
[[ -f "$templates_zip" ]] || { echo "dist FAIL: missing $templates_zip (see tools/godot.sh)" >&2; exit 1; }
echo "dist: checking the export templates against tools/engine.sha512" >&2
grep 'export_templates\.tpz$' tools/engine.sha512 | sha512sum --check --quiet
mkdir -p "$templates_dir"
unzip -q -o -j "$templates_zip" templates/linux_release.x86_64 templates/linux_debug.x86_64 templates/version.txt -d "$templates_dir"
[[ "$(cat "$templates_dir/version.txt")" == "$engine_tag" ]] || { echo "dist FAIL: templates are for $(cat "$templates_dir/version.txt"), not $engine_tag" >&2; exit 1; }
grep 'export_templates\.tpz$' tools/engine.sha512 | cut -d' ' -f1 >"$templates_dir/.verified"
fi
rm -rf "$stage" "$package" "$out/$name.tar.gz" "$out/$name.tar.gz.sha256"
mkdir -p "$stage" "$package"
trap 'rm -f "$repo/build_commit.txt"' EXIT
printf '%s\n' "$commit" >build_commit.txt
tools/godot.sh --import --quit >/dev/null 2>&1 || true
export_preset() {
local preset="$1" target="$2" raw
echo "dist: exporting '$preset'" >&2
if ! raw="$(tools/godot.sh --export-release "$preset" "$repo/$target" 2>&1)"; then
echo "dist FAIL: exporting '$preset' failed" >&2
tail -n 20 <<<"$raw" >&2
exit 1
fi
if grep -E '^(ERROR|SCRIPT ERROR)' <<<"$raw" >&2; then
echo "dist FAIL: errors while exporting '$preset'" >&2
exit 1
fi
[[ -f "$repo/$target" ]] || { echo "dist FAIL: '$preset' wrote no $target" >&2; exit 1; }
}
export_preset "Linux" "$stage/tidewall.x86_64"
rm -f build_commit.txt
# The exported binary must be the verified official template, unchanged.
cmp -s "$stage/tidewall.x86_64" "$templates_dir/linux_release.x86_64" || { echo "dist FAIL: the exported binary isn't the release template" >&2; exit 1; }
install -m 0755 "$stage/tidewall.x86_64" "$package/tidewall.x86_64"
install -m 0644 "$stage/tidewall.pck" "$package/tidewall.pck"
install -m 0755 packaging/dist/tidewall-server "$package/tidewall-server"
install -m 0644 LICENSE LICENSE-ASSETS "$package/"
install -m 0644 packaging/server/server.cfg "$package/server.cfg"
install -m 0644 packaging/dist/README.md "$package/README.md"
install -m 0644 assets/PROVENANCE.md "$package/PROVENANCE.md"
install -m 0644 docs/ASSET_PROVENANCE.md "$package/ASSET_PROVENANCE.md"
install -m 0755 packaging/dist/tidewall "$package/tidewall"
install -m 0755 packaging/dist/install-desktop-entry.sh "$package/install-desktop-entry.sh"
install -m 0644 assets/icons/app/tidewall-256.png "$package/tidewall.png"
tools/godot.sh --script res://tools/engine_licenses.gd -- --out="$repo/$package/ENGINE-LICENSES.txt" >/dev/null 2>&1
grep -q "Permission is hereby granted" "$package/ENGINE-LICENSES.txt" || { echo "dist FAIL: no engine licence text" >&2; exit 1; }
chmod 0644 "$package/ENGINE-LICENSES.txt"
printf 'Tidewall %s\ncommit %s\nengine Godot %s\n' "$version" "$commit" "$(cat tools/engine.version)" >"$package/VERSION"
# Reproducible-ish archive: fixed owner, sorted names, mtimes from the commit.
stamp="$(git log -1 --format=%ct)"
tar --sort=name --owner=0 --group=0 --numeric-owner --mtime="@$stamp" \
-C "$out" -czf "$out/$name.tar.gz" "$name"
(cd "$out" && sha256sum "$name.tar.gz" >"$name.tar.gz.sha256")
rm -rf "$stage"
echo "dist: $out/$name.tar.gz ($(du -h "$out/$name.tar.gz" | cut -f1)), commit $commit"
tar -tzvf "$out/$name.tar.gz" | awk '{print " " $3 "\t" $6}'