#!/usr/bin/env bash # Prepara o Neon Rumble (luta 2D em canvas de koma / hao035414-cmyk, MIT; github.com/hao035414-cmyk/neon-rumble, # commit aae5d27) para o site: index.html, style.css e src/ do commit, com o patch # neon-rumble/neon-rumble-fredygames.patch: # - index.html: tira o link para o GitHub e poe uma CSP que bloqueia qualquer conexao fora da propria origem; # - src/: traduz para o ingles os poucos textos em chines das telas de selecao (papeis dos lutadores, nomes dos # atributos, ajuda de teclas e nomes dos cenarios). # O jogo nao tem imagens nem arquivos de audio (tudo e desenhado em canvas e a musica e sintetizada em WebAudio). # # src/FredGames.Bundler/Builds/build-neon-rumble.sh # # Saida: artifacts/build/neon-rumble-aae5d27/neon-rumble-aae5d27-dist.tar.gz (pasta dist/; igual em dois builds # seguidos). set -euo pipefail COMMIT=aae5d278a49e7a958057c088caf01dbf015d53e7 SHA256=36fc30ad18a0c735b47d3c51de1c51cbb940d2fd74923c51c69e460d11f151b3 here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(git -C "$here" rev-parse --show-toplevel 2>/dev/null || pwd)" out="$root/artifacts/build/neon-rumble-${COMMIT:0:7}" cache="$root/artifacts/build/cache" tarball="neon-rumble-${COMMIT:0:7}.tar.gz" mkdir -p "$cache" if [ ! -f "$cache/$tarball" ]; then curl -fsSL --retry 4 "https://github.com/hao035414-cmyk/neon-rumble/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" "$out/dist" tar -xzf "$cache/$tarball" -C "$out/tree" --strip-components 1 patch -s -p1 -d "$out/tree" < "$here/neon-rumble/neon-rumble-fredygames.patch" if find "$out/tree/src" "$out/tree/index.html" -type f -print0 \ | xargs -0 perl -CSD -0777 -ne 'if (/[\x{4e00}-\x{9fff}]/) { print "$ARGV\n"; $bad = 1 } END { exit $bad }' | grep .; then echo "restou texto em chines" >&2; exit 1 fi cp -R "$out/tree/src" "$out/dist/src" cp "$out/tree/index.html" "$out/tree/style.css" "$out/dist/" find "$out/dist" -exec touch -t 202610200000 {} + ( cd "$out" && 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 > "neon-rumble-${COMMIT:0:7}-dist.tar.gz" && rm files.txt ) ls -l "$out/neon-rumble-${COMMIT:0:7}-dist.tar.gz" shasum -a 256 "$out/neon-rumble-${COMMIT:0:7}-dist.tar.gz"