#!/usr/bin/env bash # Monta o Linjat (puzzle de Juho Snellman, MIT; jQuery 3.3.1, MIT; fonte Coiny, SIL OFL 1.1) a partir do commit # 915d2db de github.com/jsnell/linjat. O jogo e a pasta www/ do repositorio, sem etapa de build (os puzzles ja # vem gerados em www/data/puzzles.json). O jQuery e a fonte Coiny sao os arquivos do proprio repositorio; os # textos das licencas (que o repositorio nao traz) vem do jquery/jquery 3.3.1 e do google/fonts num commit fixo. # # Mudancas no jogo (linjat/linjat-fredygames.patch): sem as meta tags og:/twitter:, sem os links para o site do # autor, o GitHub, o jQuery e a Coiny (viram texto), o caminho absoluto /stc/ da fonte no CSS vira relativo # (o jogo roda numa subpasta) e uma CSP bloqueia qualquer conexao fora da propria origem. A imagem # stc/linjat-big.png (so da meta og:image) fica de fora. # # src/FredGames.Bundler/Builds/build-linjat.sh # # Saida: artifacts/build/linjat-915d2db/{linjat-915d2db-dist.tar.gz,licenses.txt}; o tar.gz (pasta dist/) sai # igual em dois builds seguidos. set -euo pipefail COMMIT=915d2db10bbecc0f8342be043d3a1a0389088616 SHA256=b92b05020a442ad4467d8aa684e8c95a7965a23ccf11fa6c8f04fb63faf06fb5 JQUERY_LICENSE_SHA256=2b3ed8ba424423a50b023e728530d94bc385cfc7c328ad65a3dfee9c7c0531c5 FONTS_COMMIT=9862abc066c9b83bf84c3e8ed1fc2d8d48f9bbf0 COINY_OFL_SHA256=5c289da4a19f054ace8e31a144a6a254601898cd7faf9eaa301141afda0adbbe here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(git -C "$here" rev-parse --show-toplevel 2>/dev/null || pwd)" out="$root/artifacts/build/linjat-${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/jsnell/linjat/archive/$COMMIT.tar.gz" "linjat-${COMMIT:0:7}.tar.gz" "$SHA256" fetch "https://raw.githubusercontent.com/jquery/jquery/3.3.1/LICENSE.txt" "jquery-3.3.1-LICENSE.txt" "$JQUERY_LICENSE_SHA256" fetch "https://raw.githubusercontent.com/google/fonts/$FONTS_COMMIT/ofl/coiny/OFL.txt" "OFL-coiny-${FONTS_COMMIT:0:7}.txt" "$COINY_OFL_SHA256" rm -rf "$out" mkdir -p "$out/tree" "$out/dist" tar -xzf "$cache/linjat-${COMMIT:0:7}.tar.gz" -C "$out/tree" --strip-components 1 patch -s -p1 -d "$out/tree" < "$here/linjat/linjat-fredygames.patch" cp -R "$out/tree/www/." "$out/dist/" rm "$out/dist/stc/linjat-big.png" { echo "== jQuery 3.3.1 (stc/third-party/jquery-3.3.1.min.js): LICENSE.txt" cat "$cache/jquery-3.3.1-LICENSE.txt" echo echo "== Coiny (stc/third-party/Coiny-Regular.ttf): OFL.txt" cat "$cache/OFL-coiny-${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 201905190000 {} + ( 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 > "linjat-${COMMIT:0:7}-dist.tar.gz" && rm files.txt ) rm -rf "$out/tree" ls -l "$out/linjat-${COMMIT:0:7}-dist.tar.gz" shasum -a 256 "$out/linjat-${COMMIT:0:7}-dist.tar.gz" "$out/licenses.txt"