35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
"""Bind exact original source texts; never import upstream."""
|
|
|
|
import hashlib
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
|
|
REF = Path(__file__).resolve().parent.parent / "flux2-action-reference"
|
|
|
|
|
|
def main():
|
|
rows = json.loads((REF / "new-sources.json").read_bytes())["sources"]
|
|
for stem, keys in [("flux2-person", {"layer", "frontend", "frontsub"})]:
|
|
origin = REF.parent / (stem + "-reference")
|
|
for old in json.loads((origin / "sources.json").read_bytes())["sources"]:
|
|
if old["id"] not in keys:
|
|
continue
|
|
e = dict(old)
|
|
for key in ["local_file", "identity_root", "license_file"]:
|
|
e[key] = os.path.relpath((origin / e[key]).resolve(), REF)
|
|
rows.append(e)
|
|
for e in rows:
|
|
e.setdefault("identity_root", ".")
|
|
e.setdefault("identity_key", e["id"])
|
|
e["applicability"] = "仅本动作迁移图的准确声明;目标安装/恢复/许可适用未知。"
|
|
assert hashlib.sha256((REF / e["local_file"]).read_bytes()).hexdigest() == e["sha256"]
|
|
(REF / "sources.json").write_text(
|
|
json.dumps({"sources": rows, "upstream_executed": False}, ensure_ascii=False, indent=2)
|
|
+ "\n"
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|