Reproduce the universal Lobby pack from reviewed fleet assets
This commit is contained in:
parent
dfc181d7d8
commit
24a1c246e0
1 changed files with 43 additions and 0 deletions
43
tools/build_network_pack.py
Normal file
43
tools/build_network_pack.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
"""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 = "901c91854aacae5953cf7fec7d25b00b1aac7aef009d5f2ad998d986405acf44"
|
||||
FLEET_SHA = "f60cfc1e09b5d411af43383e5efac49c0f1a161a3d02d9e127696aefb198ce62"
|
||||
SUPPLEMENT_SHA = "5c31bc23a2d6e67207011dbbe44921c8c7c42848af099fbb93cabe09ee0ca3bb"
|
||||
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()))
|
||||
Loading…
Reference in a new issue

Staff