#!/usr/bin/env bash # Compila o Space Trader Classic (porte web do Space Trader de Pieter Spronck, via versao Android de Russell Wolf; GPL-3.0-or-later) # a partir do commit 919e11c de github.com/lunchwine/space-trader-classic: aplica space-trader-classic-fredygames.patch ao fonte # (CSP que bloqueia qualquer requisicao externa; os dois links da caixa "About" viram texto) e roda o scripts/build.py do autor, # que junta codigo, imagens e fontes num unico index.html. Sem o patch, o build.py reproduz byte a byte o index.html do repositorio. # # src/FredGames.Bundler/Builds/build-space-trader-classic.sh # # Precisa so do python3. Saida: artifacts/build/space-trader-classic-919e11c/index.html (o bundle.yaml confere o SHA-256). # Dois builds seguidos dao os mesmos bytes. set -euo pipefail COMMIT=919e11c3b2cd16f803ce84d16c2bdaf977ef7af7 SHA256=54e578069e455faf6f99314ad7f30ab71d87bd8db7eb111f31f70fc696e20393 here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(git -C "$here" rev-parse --show-toplevel 2>/dev/null || pwd)" out="$root/artifacts/build/space-trader-classic-${COMMIT:0:7}" cache="$root/artifacts/build/cache" tarball="space-trader-classic-${COMMIT:0:7}.tar.gz" mkdir -p "$cache" if [ ! -f "$cache/$tarball" ]; then curl -fsSL --retry 4 "https://github.com/lunchwine/space-trader-classic/archive/$COMMIT.tar.gz" -o "$cache/$tarball.partial" && mv "$cache/$tarball.partial" "$cache/$tarball" fi echo "$SHA256 $cache/$tarball" | shasum -a 256 -c - rm -rf "$out" mkdir -p "$out/tree" tar -xzf "$cache/$tarball" -C "$out/tree" --strip-components 1 patch -s -p1 -d "$out/tree" < "$here/space-trader-classic/space-trader-classic-fredygames.patch" (cd "$out/tree" && python3 -I scripts/build.py > "$out/build.log") grep -q "Content-Security-Policy" "$out/tree/index.html" ! grep -q 'target="_blank"' "$out/tree/index.html" cp "$out/tree/index.html" "$out/index.html" rm -rf "$out/tree" ls -l "$out/index.html" shasum -a 256 "$out/index.html"