62 lines
2.1 KiB
Python
62 lines
2.1 KiB
Python
"List source texts and their identity/permission evidence, without self hashing."
|
|
|
|
import hashlib
|
|
import json
|
|
|
|
from build_definition import OUT, REF, REPO
|
|
|
|
|
|
def main():
|
|
rows = json.loads((REF / "sources.json").read_bytes())["sources"]
|
|
paths = {p.resolve() for p in REF.iterdir() if p.is_file()}
|
|
for e in rows:
|
|
paths.add((REF / e["local_file"]).resolve())
|
|
if not e["license_file"].startswith("未知"):
|
|
paths.add((REF / e["license_file"]).resolve())
|
|
if e["id"] == "litegraph":
|
|
continue
|
|
if "member_crc32" in e:
|
|
paths.update(
|
|
(REF / e["identity_root"] / (e["identity_key"] + suffix)).resolve()
|
|
for suffix in ["-registry.json", "-members.json", "-range-proof.json"]
|
|
)
|
|
continue
|
|
base = REF / e["identity_root"]
|
|
paths.update(
|
|
(base / (e["identity_key"] + suffix)).resolve()
|
|
for suffix in ["-commit.txt", "-tag.txt", "-tag.json", "-tree.json"]
|
|
)
|
|
paths.update(p.resolve() for p in REF.glob("*registry*.json"))
|
|
result = []
|
|
for p in sorted(paths):
|
|
raw = p.read_bytes()
|
|
result.append(
|
|
dict(
|
|
path=str(p.relative_to(REPO)),
|
|
sha256=hashlib.sha256(raw).hexdigest(),
|
|
purpose="准确来源原文、许可或Git对象绑定;静态读取未执行",
|
|
)
|
|
)
|
|
(OUT / "source-closure.json").write_text(
|
|
json.dumps(
|
|
dict(
|
|
files=result,
|
|
count=len(result),
|
|
upstream_executed=False,
|
|
note=(
|
|
"commit/tag字节和选定blob已重算;tree列表非完整树对象"
|
|
"重哈希。本批为选定Git文本与发布成员Range;成员CRC已核,整包SHA/Git绑定未知,没有整包获取;未安"
|
|
"装。"
|
|
),
|
|
),
|
|
ensure_ascii=False,
|
|
indent=2,
|
|
)
|
|
+ "\n"
|
|
)
|
|
print("PASS source closure", len(result))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|