plugins/tools/plugin_item_origin.py
unimatrixgit 5ff7eca20b
Some checks failed
Item Origin Remainders Build / item-origin (push) Has been cancelled
DuneRealms Plugin CI / plugins (push) Has been cancelled
Preserve fuel bucket and sapling origin metadata
2026-12-03 21:53:32 +01:00

45 lines
1.8 KiB
Python

"""Assemble the item-origin fix onto an exact retained Wild Update JARVIS archive."""
import argparse
from pathlib import Path
from plugin_wild_update import digest, read_archive, write_archive
ROOT = "com/dunerealms/jarvis/"
ENTRIES = {
ROOT + "ItemOriginRemainders.class",
ROOT + "ItemOriginRemainders$Burn.class",
ROOT + "QuestObservations.class",
}
def main():
parser = argparse.ArgumentParser(description=__doc__)
commands = parser.add_subparsers(dest="action", required=True)
pack = commands.add_parser("extract")
pack.add_argument("built", type=Path)
pack.add_argument("output", type=Path)
install = commands.add_parser("assemble")
install.add_argument("baseline", type=Path)
install.add_argument("baseline_sha")
install.add_argument("patch", type=Path)
install.add_argument("patch_sha")
install.add_argument("output", type=Path)
args = parser.parse_args()
if args.action == "extract":
compiled = read_archive(args.built.read_bytes())
result = write_archive({name: compiled[name] for name in ENTRIES})
else:
baseline, patch = args.baseline.read_bytes(), args.patch.read_bytes()
if digest(baseline) != args.baseline_sha or digest(patch) != args.patch_sha:
raise ValueError("Unexpected baseline or provenance overlay")
retained, overlay = read_archive(baseline), read_archive(patch)
if overlay.keys() != ENTRIES or ROOT + "QuestLoginSettle.class" not in retained:
raise ValueError("Expected the three provenance classes and retained Wild Update login hooks")
result = write_archive(retained | overlay)
with args.output.open("xb") as target:
target.write(result)
print(digest(result))
if __name__ == "__main__":
main()