#!/usr/bin/env bash # Monta o Mini Grand Prix (corrida cartoon de monolugares de xhhdaxx / hexinhao, MIT; JavaScript em modulos ES + canvas 2D, sem etapa de # build) a partir do commit 4134e95 de github.com/xhhdaxx/Mini-Grand-Prix. Serve so index.html, src/ e world.geojson (dados do Natural # Earth, dominio publico); ficam de fora o server.js e a pagina do controle por celular, o gerador de QR (scripts/qr-svg.js, MIT com a # clausula "Good, not Evil"), os testes, a documentacao e as imagens de divulgacao. # # Mudancas (mini-grand-prix/patch.py, publicado junto do fonte): circuitos com nomes ficticios (o jogo usava nomes reais), sem o # controle por celular (WebSocket e fetch('/ips')), interface sempre em ingles e uma CSP sem requisicao externa. # # src/FredGames.Bundler/Builds/build-mini-grand-prix.sh # # Saida: artifacts/build/mini-grand-prix-4134e95/mini-grand-prix-4134e95-dist.tar.gz (dist/index.html, src/, world.geojson); o tar.gz tem # que sair igual em dois builds. set -euo pipefail COMMIT=4134e95b0bf6c1bffa410eaa0f73f0e178184117 SHA256=6c163189b19c97e0180130371ef2dc20d706f02e2851f3929251af49b4270e90 here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(git -C "$here" rev-parse --show-toplevel 2>/dev/null || pwd)" out="$root/artifacts/build/mini-grand-prix-${COMMIT:0:7}" cache="$root/artifacts/build/cache" tgz="$cache/mini-grand-prix-${COMMIT:0:7}.tar.gz" mkdir -p "$cache" if [ ! -f "$tgz" ]; then curl -fsSL --retry 4 "https://github.com/xhhdaxx/Mini-Grand-Prix/archive/$COMMIT.tar.gz" -o "$tgz.partial" && mv "$tgz.partial" "$tgz" fi echo "$SHA256 $tgz" | shasum -a 256 -c - rm -rf "$out" mkdir -p "$out/tree" "$out/dist" tar -xzf "$tgz" -C "$out/tree" --strip-components 1 python3 -I "$here/mini-grand-prix/patch.py" "$out/tree" cp -R "$out/tree/index.html" "$out/tree/src" "$out/tree/world.geojson" "$out/dist/" rm -rf "$out/tree" # nada de endereco externo no que o jogo executa if grep -rnE 'https?://|new WebSocket|fetch\(.(/ips|/ws)' "$out/dist/src" | grep -v 'w3.org' ; then echo "Sobrou referencia externa." >&2; exit 1 fi # dist/ vira um tar.gz deterministico (datas fixas, ordem fixa, sem dono). cd "$out" find dist -exec touch -t 202611060000 {} + find dist -type f | LC_ALL=C sort > files.txt COPYFILE_DISABLE=1 tar --format=ustar --uid 0 --gid 0 --uname root --gname root -n -cf - -T files.txt \ | gzip -n -9 > "mini-grand-prix-${COMMIT:0:7}-dist.tar.gz" rm files.txt ls -l "mini-grand-prix-${COMMIT:0:7}-dist.tar.gz" shasum -a 256 "mini-grand-prix-${COMMIT:0:7}-dist.tar.gz"