51 lines
2.0 KiB
Python
51 lines
2.0 KiB
Python
"Reuse pinned byte texts and identity objects without changing previous evidence."
|
|
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
|
|
REF = Path(__file__).resolve().parent.parent / "zimage-qwen-reference"
|
|
|
|
|
|
def main():
|
|
# fetch_sources owns acquisition.json; this makes repeated assembly deterministic.
|
|
acquired = REF / "acquisition.json"
|
|
if not acquired.exists():
|
|
acquired.write_bytes((REF / "sources.json").read_bytes())
|
|
rows = json.loads(acquired.read_bytes())["sources"]
|
|
for e in rows:
|
|
e.update(identity_root=".", identity_key=e["id"])
|
|
if e["id"] == "cr":
|
|
e["license_file"] = "cr____init__.py"
|
|
if not (REF / e["license_file"]).exists():
|
|
e["license_file"] = "未知:固定完整树无许可原文"
|
|
for directory, ids in [
|
|
("zimage-dual-reference", ["load", "frontend", "core"]),
|
|
("zimage-reference", ["tt", "lora"]),
|
|
]:
|
|
root = REF.parent / directory
|
|
for e in json.loads((root / "sources.json").read_bytes())["sources"]:
|
|
if e["id"] not in ids:
|
|
continue
|
|
e = e.copy()
|
|
raw = (root / e["local_file"]).read_bytes()
|
|
assert hashlib.sha256(raw).hexdigest() == e["sha256"]
|
|
e["local_file"] = "../" + directory + "/" + e["local_file"]
|
|
e["license_file"] = (
|
|
"../" + directory + "/" + e["license_file"]
|
|
if not e["license_file"].startswith("未知")
|
|
else e["license_file"]
|
|
)
|
|
e["identity_root"] = "../" + directory + "/" + e.get("identity_root", ".")
|
|
e["identity_key"] = e.get("identity_key", e["id"])
|
|
rows.append(e)
|
|
rows.extend(json.loads((REF / "package-sources.json").read_bytes())["sources"])
|
|
(REF / "sources.json").write_text(
|
|
json.dumps(dict(sources=rows), ensure_ascii=False, indent=2) + "\n"
|
|
)
|
|
print("PASS source assembly", len(rows))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|