#!/usr/bin/env bash # Monta o Bullet Hell (shoot'em up de Amelia Clarke, MIT) a partir do commit 75173f8 de # github.com/selenebun/bullethell. Nao ha etapa de build: o jogo e HTML + JS puro, com o p5.js 0.6.0 (LGPL-2.1, # byte a byte igual ao lib/p5.min.js do pacote p5@0.6.0 do npm) e a fonte Source Code Pro (SIL OFL 1.1) que o # repositorio ja traz. Nenhuma mudanca no jogo; o README do repositorio fica de fora. # # O p5.js e LGPL: o fonte da versao servida (tag 0.6.0 de processing/p5.js) vai junto, como "sources" do bundle. # # src/FredGames.Bundler/Builds/build-bullet-hell.sh # # Saida: artifacts/build/bullet-hell-75173f8/{bullet-hell-75173f8-dist.tar.gz,licenses.txt}; o tar.gz (pasta dist/) # sai igual em dois builds seguidos. set -euo pipefail COMMIT=75173f8c37868ac7f30b886da6d28560e8e4418b SHA256=644fe95328bc87b74f5d56c6903b280289622fa7848aa86e915ef79ed88caf86 P5=0.6.0 P5_NPM_SHA256=89b80415525e144dc37fc2888c0a1f31cec8f8689a0d02e34505afa7301ac5ee P5_MIN_SHA256=183bafd797aa4292ea5af2e446777e12fbec1cb9e01149dead8e410d261f2ee3 FONTS_COMMIT=9862abc066c9b83bf84c3e8ed1fc2d8d48f9bbf0 SCP_OFL_SHA256=cb30d3086a8b3ce0b9e3690bf48d6620402b61160bc658076f95180ccd9e9dae SCP_TTF_SHA256=2967dd73df838d2a2d390a638c6d7cfe9cd60c5ee2e162d8a1c10a70ea742b5c here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(git -C "$here" rev-parse --show-toplevel 2>/dev/null || pwd)" out="$root/artifacts/build/bullet-hell-${COMMIT:0:7}" cache="$root/artifacts/build/cache" mkdir -p "$cache" fetch() { if [ ! -f "$cache/$2" ]; then curl -fsSL --retry 4 "$1" -o "$cache/$2.partial" && mv "$cache/$2.partial" "$cache/$2" fi echo "$3 $cache/$2" | shasum -a 256 -c - } fetch "https://github.com/selenebun/bullethell/archive/$COMMIT.tar.gz" "bullethell-${COMMIT:0:7}.tar.gz" "$SHA256" fetch "https://registry.npmjs.org/p5/-/p5-$P5.tgz" "p5-$P5.tgz" "$P5_NPM_SHA256" fetch "https://raw.githubusercontent.com/google/fonts/$FONTS_COMMIT/ofl/sourcecodepro/OFL.txt" "OFL-sourcecodepro-${FONTS_COMMIT:0:7}.txt" "$SCP_OFL_SHA256" rm -rf "$out" mkdir -p "$out/tree" "$out/dist" tar -xzf "$cache/bullethell-${COMMIT:0:7}.tar.gz" -C "$out/tree" --strip-components 1 echo "$P5_MIN_SHA256 $out/tree/scripts/lib/p5.min.js" | shasum -a 256 -c - echo "$SCP_TTF_SHA256 $out/tree/fonts/SourceCodePro-Regular.ttf" | shasum -a 256 -c - tar -xzOf "$cache/p5-$P5.tgz" package/lib/p5.min.js | shasum -a 256 | grep -q "^$P5_MIN_SHA256" cp -R "$out/tree/index.html" "$out/tree/style.css" "$out/tree/scripts" "$out/tree/fonts" "$out/dist/" { echo "== p5.js $P5 (scripts/lib/p5.min.js): license.txt of the p5 package" tar -xzOf "$cache/p5-$P5.tgz" package/license.txt echo echo "== Source Code Pro (fonts/SourceCodePro-Regular.ttf): OFL.txt" cat "$cache/OFL-sourcecodepro-${FONTS_COMMIT:0:7}.txt" } > "$out/licenses.txt" # dist/ vira um tar.gz deterministico (datas fixas, ordem fixa, sem dono). find "$out/dist" -exec touch -t 202012070000 {} + ( 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 > "bullet-hell-${COMMIT:0:7}-dist.tar.gz" && rm files.txt ) rm -rf "$out/tree" ls -l "$out/bullet-hell-${COMMIT:0:7}-dist.tar.gz" shasum -a 256 "$out/bullet-hell-${COMMIT:0:7}-dist.tar.gz" "$out/licenses.txt"