130 lines
4.9 KiB
Python
130 lines
4.9 KiB
Python
"Offline batch evidence tooling; no upstream execution."
|
|
|
|
import datetime
|
|
import hashlib
|
|
import json
|
|
import subprocess
|
|
import urllib.request
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[3]
|
|
REF = Path(__file__).resolve().parents[1] / "llama-reference"
|
|
SPECS = {
|
|
"llama": (
|
|
"lihaoyun6/ComfyUI-llama-cpp_vlm",
|
|
"llama-reference-git",
|
|
[
|
|
"nodes.py",
|
|
"__init__.py",
|
|
"pyproject.toml",
|
|
"README_zh.md",
|
|
"support/gguf_layers.py",
|
|
],
|
|
),
|
|
"showtext": (
|
|
"pythongosssss/ComfyUI-Custom-Scripts",
|
|
"showtext-reference-git",
|
|
["py/show_text.py", "web/js/showText.js", "__init__.py", "LICENSE", "pyproject.toml"],
|
|
),
|
|
}
|
|
|
|
|
|
def main():
|
|
REF.mkdir(parents=True, exist_ok=True)
|
|
rows, identities = [], []
|
|
for key, (repo, cache, files) in SPECS.items():
|
|
gd = ROOT / ".local-evidence" / cache
|
|
|
|
def git(*args):
|
|
return subprocess.check_output(["git", "-C", str(gd), *args])
|
|
|
|
rev = {
|
|
"llama": "f2209cccb726647640271bd1cea071a570fc62f5",
|
|
"showtext": "609f3afaa74b2f88ef9ce8d939626065e3247469",
|
|
}[key]
|
|
tree = []
|
|
for line in git("ls-tree", "-r", rev).decode().splitlines():
|
|
head, path = line.split("\t", 1)
|
|
mode, kind, sha = head.split()
|
|
tree.append(dict(path=path, mode=mode, type=kind, sha=sha))
|
|
(REF / (key + "-tree.json")).write_text(
|
|
json.dumps(dict(sha=rev, truncated=False, tree=tree), indent=2) + "\n"
|
|
)
|
|
(REF / (key + "-commit.txt")).write_bytes(git("cat-file", "commit", rev))
|
|
identities.append(
|
|
dict(
|
|
id=key,
|
|
repo=repo,
|
|
commit=rev,
|
|
tree=git("rev-parse", rev + "^{tree}").decode().strip(),
|
|
tag=None,
|
|
selection="显式调查参考;非源声明版本、非发布包/目标绑定",
|
|
license_status="pyproject引用LICENSE但Git树缺此文件,许可文本未知"
|
|
if key == "llama"
|
|
else "LICENSE全文已固定",
|
|
)
|
|
)
|
|
for file in files:
|
|
raw = git("show", rev + ":" + file)
|
|
name = key + "__" + file.replace("/", "__")
|
|
blob = next(e["sha"] for e in tree if e["path"] == file)
|
|
assert hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest() == blob
|
|
(REF / name).write_bytes(raw)
|
|
rows.append(
|
|
dict(
|
|
id=key,
|
|
repo=repo,
|
|
file=file,
|
|
local_file=name,
|
|
commit=rev,
|
|
tag=None,
|
|
url=f"https://raw.githubusercontent.com/{repo}/{rev}/{file}",
|
|
sha256=hashlib.sha256(raw).hexdigest(),
|
|
git_blob_sha1=blob,
|
|
fetched_at=datetime.datetime.now(datetime.timezone.utc).isoformat(),
|
|
license_file="未提供,pyproject引用但原树缺失"
|
|
if key == "llama"
|
|
else "showtext__LICENSE",
|
|
transport=("git show full commit; no check" + "out; text only"),
|
|
applicability="显式参考假设,源未声明身份版本,发布包与目标绑定未知",
|
|
)
|
|
)
|
|
old = REF.parent / "moge3-reference"
|
|
ident = next(
|
|
i for i in json.loads((old / "identities.json").read_bytes()) if i["id"] == "frontend"
|
|
)
|
|
file = "src/renderer/extensions/vueNod" + "es/widgets/composables/useIntW" + "idget.ts"
|
|
url = f"https://raw.githubusercontent.com/{ident['repo']}/{ident['commit']}/{file}"
|
|
raw = urllib.request.urlopen(url, timeout=30).read()
|
|
tree = json.loads((old / "frontend-tree.json").read_bytes())
|
|
blob = next(e["sha"] for e in tree["tree"] if e["path"] == file)
|
|
assert hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest() == blob
|
|
(REF / "frontend__useIntWidget.ts").write_bytes(raw)
|
|
rows.append(
|
|
dict(
|
|
id="frontend",
|
|
repo=ident["repo"],
|
|
file=file,
|
|
local_file="frontend__useIntWidget.ts",
|
|
commit=ident["commit"],
|
|
tag=ident["tag"],
|
|
url=url,
|
|
sha256=hashlib.sha256(raw).hexdigest(),
|
|
git_blob_sha1=blob,
|
|
fetched_at=datetime.datetime.now(datetime.timezone.utc).isoformat(),
|
|
license_file="../moge3-reference/frontend__LICENSE",
|
|
transport=("raw pinned full commit, git tr" + "ee blob verified"),
|
|
applicability="仅显式1.52.7参考假设;本图未声明前端版本",
|
|
)
|
|
)
|
|
(REF / "sources.json").write_text(
|
|
json.dumps(dict(sources=rows), ensure_ascii=False, indent=2) + "\n"
|
|
)
|
|
(REF / "identities.json").write_text(
|
|
json.dumps(identities, ensure_ascii=False, indent=2) + "\n"
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|