plugins/tools/build_network_pack.py
unimatrixgit 74c8cd95fc
Some checks failed
Lobby Pack Session Overlay / lobby-pack-session (push) Successful in 2m10s
DuneRealms Resourcepack CI / resourcepack (push) Has been cancelled
DuneRealms Plugin CI / plugins (push) Has been cancelled
Pin the actual published input archives for the Lobby pack
2026-12-04 20:59:45 +01:00

43 lines
1.9 KiB
Python

"""Build the network pack from the exact published terrain and supplemental packs."""
import argparse
import hashlib
from pathlib import Path
from plugin_wild_update import digest, read_archive, write_archive
ARRAKIS_SHA = "7a6013ddf7954377529e16292e3ec3857ffb58ee24167c455695da5129b1859b"
FLEET_SHA = "2479515fed5ff0255416f99601cbbaf38298bedda16499fc16628514b43baf71"
SUPPLEMENT_SHA = "808b31785a7a94f24dbbbad581d9a2215bc6c1607cf97f1cd3438138a2f2a36c"
JERBOA = {"jerboa.json", "jerboa_curled.json", "jerboa_walk_left.json", "jerboa_walk_right.json", "jerboa.png"}
def verified(path, sha):
raw = path.read_bytes()
if digest(raw) != sha:
raise ValueError(f"{path.name} differs from its reviewed publication")
return read_archive(raw)
def assemble(arrakis, fleet, supplemental, output):
primary = verified(arrakis, ARRAKIS_SHA)
other = verified(fleet, FLEET_SHA)
extra = verified(supplemental, SUPPLEMENT_SHA)
changed = {path for path in primary if path in other and primary[path] != other[path]}
if set(primary) != set(other) or len(changed) != len(JERBOA) or {Path(path).name for path in changed} != JERBOA:
raise ValueError("Unexpected difference between the two primary packs")
if set(primary) & set(extra) != {"pack.mcmeta"}:
raise ValueError("Unexpected primary and supplemental asset collision")
del extra["pack.mcmeta"]
combined = write_archive(primary | extra)
with output.open("xb") as file:
file.write(combined)
print(f"{len(primary)} primary entries + {len(extra)} supplemental entries")
print(f"SHA-1 {hashlib.sha1(combined).hexdigest()}")
print(f"SHA-256 {digest(combined)}")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
for argument in ("arrakis", "fleet", "supplemental", "output"):
parser.add_argument(argument, type=Path)
assemble(**vars(parser.parse_args()))