#!/usr/bin/env bash # Gera o the-return-of-the-rogue.love de The Return of the Rogue (Bastien Leonard, 7DRL 2022, GPL-3.0) a partir do # commit 305cbe6 do repositorio, com um patch nosso (publicado junto do fonte): # the-return-of-the-rogue/web.patch comeca em janela (nao em tela cheia); liga os modulos audio, sound e data do # conf.lua (o love.js quebra com eles desligados: "null function" no start); a escala # da interface nao liga a tela cheia so para medir a tela; a tela de morte nao tem Quit. # O .love segue o `make build` do autor: o conteudo de src/ na raiz do zip, mais assets/ e vendor/ (que so tem o # submodulo vazio do profiler, usado apenas se run_profiler for true), mais o LICENSE.txt. Zip deterministico # (ordem alfabetica, data fixa, deflate). # # src/FredGames.Bundler/Builds/build-the-return-of-the-rogue.sh # # Saida: artifacts/build/the-return-of-the-rogue-305cbe6/the-return-of-the-rogue.love set -euo pipefail COMMIT=305cbe6b6b27c70edafd46d471cd59ac4dcb7a69 SHA256=10bb1d5b0e7d923b31cb35510735a834cb95057d02cf62bce7c0fca88ed3b599 here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(git -C "$here" rev-parse --show-toplevel 2>/dev/null || pwd)" out="$root/artifacts/build/the-return-of-the-rogue-305cbe6" cache="$root/artifacts/build/cache" mkdir -p "$cache" tarball="$cache/the-return-of-the-rogue-305cbe6.tar.gz" [ -f "$tarball" ] || curl -fsSL "https://github.com/bastienleonard/7drl2022/archive/$COMMIT.tar.gz" -o "$tarball" echo "$SHA256 $tarball" | shasum -a 256 -c - rm -rf "$out" mkdir -p "$out/tree" tar -xzf "$tarball" -C "$out/tree" --strip-components 1 patch -d "$out/tree" -p1 < "$here/the-return-of-the-rogue/web.patch" python3 -I - "$out/tree" "$out/the-return-of-the-rogue.love" <<'PY' import os, sys, zipfile src, dest = sys.argv[1:] files = {} def add(base, prefix=''): for d, dirs, fs in os.walk(base): for f in fs: full = os.path.join(d, f) rel = prefix + os.path.relpath(full, base).replace(os.sep, '/') files[rel] = full add(os.path.join(src, 'src')) add(os.path.join(src, 'assets'), 'assets/') add(os.path.join(src, 'vendor'), 'vendor/') files['LICENSE.txt'] = os.path.join(src, 'LICENSE.txt') with zipfile.ZipFile(dest, 'w', zipfile.ZIP_DEFLATED, compresslevel=9) as z: for rel in sorted(files): info = zipfile.ZipInfo(rel, (1980, 1, 1, 0, 0, 0)) info.compress_type = zipfile.ZIP_DEFLATED info.external_attr = 0o644 << 16 info.create_system = 3 with open(files[rel], 'rb') as fh: z.writestr(info, fh.read(), compresslevel=9) PY shasum -a 256 "$out/the-return-of-the-rogue.love"