#!/usr/bin/env bash # Exporta o Ball2Box (Simon Dalvai; codigo AGPL-3.0-or-later, arte propria CC BY-SA 4.0, musica CC BY 4.0, sons e # icones CC0, fonte Manrope SIL OFL; codeberg.org/dulvui/ball2box, commit cb98f96, o mesmo commit do espelho # antigo github.com/dulvui/ball2box, ja arquivado) para a web com o Godot 3.5.3 oficial (o projeto e do Godot 3.x # e o autor tem exemplo de export HTML5): renderer GLES2 do proprio projeto, modelo webassembly_release (sem # threads: nao precisa de SharedArrayBuffer nem de COOP/COEP), sem PWA. O projeto fica na pasta game/ do repositorio; # o preset de exportacao e nosso. Por ser AGPL, o fonte exato vai junto (o repositorio inteiro, ja com as mudancas), # e as mudancas do projeto (todas em ball2box/patch.py, publicado) sao a retirada de botoes e links para sites # externos (GitHub, site, doacao, lojas, Mastodon, YouTube), mais um aviso de modificacao na tela de informacoes (cujo botao, escondido pelo autor, passa a aparecer) e o CSV de traducoes sem reimportar (para o export ser reprodutivel). # # src/FredGames.Bundler/Builds/build-ball2box.sh # # O editor (macOS universal) e os modelos de exportacao vem do release 3.5.3-stable do GitHub, conferidos pelo # SHA-256 (os mesmos arquivos do SHA512-SUMS.txt do release) e ficam em artifacts/tools/godot-3.5.3 (instalados # sob lockf; outros scripts compartilham a pasta). O editor roda com HOME dentro da pasta de saida # (configuracao e modelo isolados). # # Saida: artifacts/build/ball2box-cb98f96/{web/,ball2box-cb98f96.tar.gz}, que o bundle.yaml do jogo confere pelo # SHA-256. O tar.gz e o fonte do jogo inteiro (AGPL-3.0, com o fonte exato servido e as mudancas de patch.py ja feitas) e sai igual a cada execucao. set -euo pipefail SLUG=ball2box COMMIT=cb98f9647726a21e59223ce315326847366eb2fc SHORT=${COMMIT:0:7} SHA256=1f9a4276ef3db479daa65f46f5a8fd17718ea1722d234ddc984885f3964115f2 GODOT=3.5.3 GODOT_URL=https://github.com/godotengine/godot/releases/download/$GODOT-stable GODOT_MAC_SHA256=d448bf70a438edfd506c6878963327d7814d83fd636d132294fb7abb1f971246 GODOT_TPZ_SHA256=ae3c1f6fbd431b9e3b67c1f9e42539a6d270a0ccc35558f13072f04b968312d1 here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(git -C "$here" rev-parse --show-toplevel 2>/dev/null || pwd)" out="$root/artifacts/build/$SLUG-$SHORT" cache="$root/artifacts/build/cache" tools="$root/artifacts/tools" 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 - } install_godot() { [ -d "$tools/godot-$GODOT" ] && return 0 fetch "$GODOT_URL/Godot_v$GODOT-stable_osx.universal.zip" "Godot_v$GODOT-stable_osx.universal.zip" "$GODOT_MAC_SHA256" fetch "$GODOT_URL/Godot_v$GODOT-stable_export_templates.tpz" "Godot_v$GODOT-stable_export_templates.tpz" "$GODOT_TPZ_SHA256" rm -rf "$tools/godot-$GODOT.tmp" mkdir -p "$tools/godot-$GODOT.tmp" unzip -q "$cache/Godot_v$GODOT-stable_osx.universal.zip" -d "$tools/godot-$GODOT.tmp" unzip -q "$cache/Godot_v$GODOT-stable_export_templates.tpz" templates/webassembly_release.zip templates/version.txt \ -d "$tools/godot-$GODOT.tmp" mv "$tools/godot-$GODOT.tmp" "$tools/godot-$GODOT" } if [ "${1:-}" = "--install" ]; then install_godot; exit 0; fi fetch "https://codeberg.org/dulvui/ball2box/archive/cb98f9647726a21e59223ce315326847366eb2fc.tar.gz" "ball2box-$SHORT.tar.gz" "$SHA256" if [ ! -d "$tools/godot-$GODOT" ]; then lockf -k "$root/artifacts/godot-$GODOT.lock" bash "${BASH_SOURCE[0]}" --install fi rm -rf "$out" mkdir -p "$out/tree" "$out/web" tar -xzf "$cache/ball2box-$SHORT.tar.gz" -C "$out/tree" --strip-components 1 project="$out/tree/game" # Mudancas no projeto (ver patch.py): sem links para sites externos; aviso de modificacao (AGPL). python3 -I "$here/$SLUG/patch.py" "$project" cat > "$out/tree/FREDYGAMES-CHANGES.txt" <<'EOF' This is Ball2Box (https://codeberg.org/dulvui/ball2box, commit cb98f9647726a21e59223ce315326847366eb2fc), modified for FredyGames on 2026-10-29 (AGPL-3.0-or-later, section 5a). The changes are the ones in ball2box-patch.py, published next to this archive: the buttons and links that opened external sites (the author's website and GitHub page, donation page, app stores, Mastodon, a YouTube video) were removed, the two shop balls that were unlocked by opening those pages are free, the information button (credits and licences), hidden in the original, is shown and its screen says the game was modified, and the translations are loaded from the .translation files in the repository instead of being re-imported from the CSV (so that the export is reproducible). Nothing else was changed. EOF # Data fixa nos arquivos e fonte publicado: o projeto (ja com as mudancas acima), em tar deterministico # (ordem, dono e data fixos), sem o export_presets.cfg do autor. TZ=UTC find "$out/tree" -exec touch -t 202001010000 {} + ( cd "$out/tree" && find . -type f | sed 's|^\./||' | LC_ALL=C sort > "$out/files.txt" ) ( cd "$out/tree" && COPYFILE_DISABLE=1 tar --format=ustar --uid 0 --gid 0 --uname root --gname root -n \ -cf - -T "$out/files.txt" ) | gzip -n -9 > "$out/$SLUG-$SHORT.tar.gz" cp "$here/$SLUG/export_presets.cfg" "$project/export_presets.cfg" export HOME="$out/home" TZ=UTC LC_ALL=C templates="$HOME/Library/Application Support/Godot/templates/$GODOT.stable" mkdir -p "$templates" cp "$tools/godot-$GODOT/templates/webassembly_release.zip" "$tools/godot-$GODOT/templates/version.txt" "$templates/" godot="$tools/godot-$GODOT/Godot.app/Contents/MacOS/Godot" cd "$project" # O editor do Godot 3 sai do --quit antes de terminar de importar ("Scan thread aborted"): o que falta # (audio, modelos) so e importado durante um export. Por isso: uma passada do editor, um export descartavel # (que termina de importar) e o export final, que nao pode ter reimportado nada nem falhado em abrir um # recurso importado. "$godot" --path . --editor --quit --no-window > "$out/import.log" 2>&1 || true mkdir -p "$out/warmup" "$godot" --path . --export "Web" "$out/warmup/index.html" --no-window > "$out/warmup.log" 2>&1 || true rm -rf "$out/warmup" "$godot" --path . --export "Web" "$out/web/index.html" --no-window > "$out/export.log" 2>&1 if grep -q -E "Cannot open file|reimport: begin|Scan thread aborted" "$out/export.log"; then echo "export com importacao incompleta, veja $out/export.log" >&2; exit 1 fi ls -l "$out/web"