180 lines
6.3 KiB
Python
180 lines
6.3 KiB
Python
"""Bounded exact upstream text acquisition, never checkout or execute upstream."""
|
|
|
|
import datetime
|
|
import hashlib
|
|
import json
|
|
import subprocess
|
|
import urllib.request
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[3]
|
|
OUT = Path(__file__).resolve().parent
|
|
REF = OUT.parent / "flux2-real-reference"
|
|
|
|
|
|
def main():
|
|
rows = []
|
|
for key, repo, tag, files in [
|
|
(
|
|
"lora",
|
|
"Comfy-Org/ComfyUI",
|
|
"v0.15.1",
|
|
["nodes.py", "folder_paths.py", "LICENSE"],
|
|
),
|
|
(
|
|
"frontend",
|
|
"Comfy-Org/ComfyUI_frontend",
|
|
"v1.40.0",
|
|
[
|
|
"package.json",
|
|
"pnpm-lock.yaml",
|
|
"src/scripts/widgets.ts",
|
|
"src/scripts/app.ts",
|
|
"src/extensions/core/uploadImage.ts",
|
|
"src/lib/litegraph/src/LGraphNode.ts",
|
|
"src/lib/litegraph/LICENSE",
|
|
"LICENSE",
|
|
],
|
|
),
|
|
]:
|
|
cache = ROOT / ".local-evidence" / ("flux2-real-" + key + "-git")
|
|
if not cache.exists():
|
|
cache.mkdir(parents=True)
|
|
subprocess.run(
|
|
["git", "init", "--bare", str(cache)],
|
|
check=True,
|
|
stdout=subprocess.DEVNULL,
|
|
)
|
|
subprocess.run(
|
|
[
|
|
"git",
|
|
"-C",
|
|
str(cache),
|
|
"fetch",
|
|
"--depth=1",
|
|
"https://github.com/" + repo + ".git",
|
|
"refs/tags/" + tag,
|
|
],
|
|
check=True,
|
|
)
|
|
|
|
def git(*args, cache=cache):
|
|
return subprocess.check_output(["git", "-C", str(cache), *args])
|
|
|
|
rev = git("rev-parse", "FETCH_HEAD^{commit}").decode().strip()
|
|
tree_sha = git("rev-parse", rev + "^{tree}").decode().strip()
|
|
commit = git("cat-file", "commit", rev)
|
|
(REF / (key + "-commit.txt")).write_bytes(commit)
|
|
tag_raw = git("cat-file", "-p", "FETCH_HEAD")
|
|
(REF / (key + "-tag.txt")).write_bytes(tag_raw)
|
|
(REF / (key + "-tag.json")).write_text(
|
|
json.dumps(
|
|
{
|
|
"ref": "refs/tags/" + tag,
|
|
"commit": rev,
|
|
"object": git("rev-parse", "FETCH_HEAD").decode().strip(),
|
|
},
|
|
indent=2,
|
|
)
|
|
+ "\n"
|
|
)
|
|
tree = []
|
|
for line in git("ls-tree", "-r", rev).decode().splitlines():
|
|
head, path = line.split("\t", 1)
|
|
mode, kind, sha = head.split()
|
|
tree.append({"path": path, "mode": mode, "type": kind, "sha": sha})
|
|
(REF / (key + "-tree.json")).write_text(
|
|
json.dumps({"sha": tree_sha, "truncated": False, "tree": tree}, indent=2)
|
|
+ "\n"
|
|
)
|
|
# Discover relevant exact filenames before selecting any necessary helper.
|
|
print(
|
|
key,
|
|
rev,
|
|
"\n".join(
|
|
e["path"]
|
|
for e in tree
|
|
if any(
|
|
s in e["path"].lower()
|
|
for s in ["minimax", "logic", "subgraphnode", "seednode"]
|
|
)
|
|
),
|
|
flush=True,
|
|
)
|
|
missing = []
|
|
for file in files:
|
|
e = next((e for e in tree if e["path"] == file), None)
|
|
if e is None:
|
|
missing.append(file)
|
|
continue
|
|
raw = git("show", rev + ":" + file)
|
|
name = key + "__" + file.replace("/", "__")
|
|
(REF / name).write_bytes(raw)
|
|
rows.append(
|
|
{
|
|
"id": key,
|
|
"repo": repo,
|
|
"file": file,
|
|
"local_file": name,
|
|
"commit": rev,
|
|
"tree": tree_sha,
|
|
"tag": tag,
|
|
"url": f"https://raw.githubusercontent.com/{repo}/{rev}/{file}",
|
|
"sha256": hashlib.sha256(raw).hexdigest(),
|
|
"git_blob_sha1": e["sha"],
|
|
"acquisition_time": datetime.datetime.now(
|
|
datetime.timezone.utc
|
|
).isoformat(),
|
|
"license_file": key + "__LICENSE",
|
|
"transport": "git exact tag text; no execution",
|
|
"applicability": "本图准确声明版本;目标安装与UE恢复未知",
|
|
}
|
|
)
|
|
(REF / (key + "-absent.json")).write_text(json.dumps(missing, indent=2) + "\n")
|
|
# Rebind the already checked 0.8.2 bytes, not another graph's node mappings.
|
|
common = json.loads((REF.parent / "flux2-img-reference/sources.json").read_bytes())
|
|
for original in common["sources"]:
|
|
if original["id"] != "core":
|
|
continue
|
|
e = dict(original)
|
|
e["local_file"] = "../flux2-img-reference/" + e["local_file"]
|
|
e["applicability"] = "本图独立comfy-core0.8.2声明;同字节重新绑定;目标安装未知"
|
|
rows.append(e)
|
|
base = next(e for e in rows if e["id"] == "core")
|
|
for file in [
|
|
"comfy_extras/nodes_images.py",
|
|
"comfy_extras/nodes_post_processing.py",
|
|
]:
|
|
url = (
|
|
f"https://raw.githubusercontent.com/{base['repo']}/{base['commit']}/{file}"
|
|
)
|
|
with urllib.request.urlopen(url, timeout=30) as response:
|
|
raw = response.read()
|
|
name = "core__" + file.replace("/", "__")
|
|
(REF / name).write_bytes(raw)
|
|
rows.append(
|
|
dict(
|
|
base,
|
|
file=file,
|
|
local_file=name,
|
|
url=url,
|
|
sha256=hashlib.sha256(raw).hexdigest(),
|
|
git_blob_sha1=hashlib.sha1(
|
|
b"blob " + str(len(raw)).encode() + b"\0" + raw
|
|
).hexdigest(),
|
|
)
|
|
)
|
|
url = "https://api.comfy.org/nodes/rgthree-comfy/versions/1.0.2512112053"
|
|
with urllib.request.urlopen(url, timeout=30) as response:
|
|
metadata = response.read()
|
|
assert json.loads(metadata)["version"] == "1.0.2512112053"
|
|
(REF / "rgthree-registry.json").write_bytes(metadata)
|
|
# Follow with fetch_packages.py; it reads only selected necessary text members.
|
|
(REF / "sources.json").write_text(
|
|
json.dumps({"sources": rows}, ensure_ascii=False, indent=2) + "\n"
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|