|
|
@@ -23,6 +23,7 @@ COMMON = (
|
|
|
"START-HERE.zh-CN.md",
|
|
|
"EXCLUSIONS.json",
|
|
|
)
|
|
|
+BASE_IDENTITY_FILES = ("BASE-IDENTITY.json", "BASE-PACKAGE-MANIFEST.json", "BASE-SHA256SUMS")
|
|
|
EXCLUSION_RULES = [
|
|
|
".git/.repo/worktrees", ".cursor/.codex/Playwright cache", "__pycache__/pytest cache",
|
|
|
"venv/node_modules", "build/dist/TD/Formal workdir", "fuzz corpus/raw dataset",
|
|
|
@@ -109,12 +110,19 @@ def base_paths() -> list[str]:
|
|
|
stable_tools = [
|
|
|
"tools/bootstrap-linux.sh", "tools/bootstrap_oss_cad_suite.py", "tools/doctor.sh",
|
|
|
"tools/doctor_linux.py", "tools/check_6400_closures.py", "tools/generate_target.py",
|
|
|
+ "tools/resource_scheduler.py",
|
|
|
"tools/generate_6400_v1.py", "tools/target_registry.py", "tools/run_6400_td.py",
|
|
|
"tools/package_target.py", "tools/package_6400_canonical.py",
|
|
|
+ "tools/overlay_6400_packages.py",
|
|
|
"tests/unit/test_6400_closure_separation.py",
|
|
|
]
|
|
|
+ infrastructure = [
|
|
|
+ p.relative_to(ROOT).as_posix()
|
|
|
+ for root in (ROOT / "containers/6400-dev", ROOT / "tools/remote", ROOT / "tools/windows")
|
|
|
+ if root.is_dir() for p in root.rglob("*") if p.is_file()
|
|
|
+ ]
|
|
|
board_contracts = ["contracts/channel-map.yaml", "contracts/fan-control-parameters.yaml"]
|
|
|
- return sorted(set(stable_sources + stable_tools + board_contracts))
|
|
|
+ return sorted(set(stable_sources + stable_tools + board_contracts + infrastructure))
|
|
|
|
|
|
|
|
|
def current_paths() -> list[str]:
|
|
|
@@ -142,7 +150,7 @@ def fingerprint(files: dict[str, bytes]) -> str:
|
|
|
|
|
|
|
|
|
SELF_CHECK = r'''#!/usr/bin/env python3
|
|
|
-import hashlib,json,pathlib,sys,zipfile
|
|
|
+import hashlib,json,pathlib,sys
|
|
|
root=pathlib.Path(__file__).resolve().parent
|
|
|
def sha(p): return hashlib.sha256(p.read_bytes()).hexdigest()
|
|
|
for line in (root/'SHA256SUMS').read_text(encoding='utf-8').splitlines():
|
|
|
@@ -153,8 +161,23 @@ for item in manifest['items']:
|
|
|
p=root/item['path']
|
|
|
if not p.is_file() or sha(p)!=item['sha256'] or p.stat().st_size!=item['size']:
|
|
|
raise SystemExit('MANIFEST_MISMATCH '+item['path'])
|
|
|
-if manifest['profile']=='current' and not (root/'.base-overlay-present').exists():
|
|
|
- print('BASE_REQUIRED'); raise SystemExit(3)
|
|
|
+if manifest['profile']=='current':
|
|
|
+ required=json.loads((root/'BASE-REQUIRED.json').read_text(encoding='utf-8'))
|
|
|
+ identity_path=root/'BASE-IDENTITY.json'; base_manifest_path=root/'BASE-PACKAGE-MANIFEST.json'
|
|
|
+ if not identity_path.is_file() or not base_manifest_path.is_file():
|
|
|
+ print('BASE_REQUIRED'); raise SystemExit(3)
|
|
|
+ identity=json.loads(identity_path.read_text(encoding='utf-8'))
|
|
|
+ if identity.get('base_id')!=required.get('base_id'):
|
|
|
+ raise SystemExit('BASE_ID_MISMATCH')
|
|
|
+ if sha(base_manifest_path)!=required.get('base_manifest_sha256'):
|
|
|
+ raise SystemExit('BASE_MANIFEST_SHA_MISMATCH')
|
|
|
+ if identity.get('base_manifest_sha256')!=required.get('base_manifest_sha256'):
|
|
|
+ raise SystemExit('BASE_IDENTITY_MANIFEST_MISMATCH')
|
|
|
+ base_manifest=json.loads(base_manifest_path.read_text(encoding='utf-8'))
|
|
|
+ for item in base_manifest['items']:
|
|
|
+ p=root/item['path']
|
|
|
+ if not p.is_file() or sha(p)!=item['sha256'] or p.stat().st_size!=item['size']:
|
|
|
+ raise SystemExit('BASE_MEMBER_MISMATCH '+item['path'])
|
|
|
print('PASS')
|
|
|
'''
|
|
|
|
|
|
@@ -171,8 +194,15 @@ def common_payload(profile: str, commit: str, tree: str, selected: dict[str, byt
|
|
|
selected["PACKAGE-MANIFEST.json"] = (json.dumps(manifest, indent=2, sort_keys=True) + "\n").encode()
|
|
|
selected["PACKAGE-SELF-CHECK.py"] = SELF_CHECK.encode()
|
|
|
selected["START-HERE.zh-CN.md"] = (
|
|
|
- f"# 6400-front-rear {profile}\n\n先运行 `python3 PACKAGE-SELF-CHECK.py`。"
|
|
|
- "硬件、COM、JTAG 均未运行;不得把分析证据当作真机验收。\n"
|
|
|
+ f"# 6400-front-rear {profile}\n\n"
|
|
|
+ "1. Base: 解压后运行 `python3 PACKAGE-SELF-CHECK.py`。\n"
|
|
|
+ "2. Current 单独自检应返回 `BASE_REQUIRED`(退出码 3)。\n"
|
|
|
+ "3. Overlay: `python3 tools/overlay_6400_packages.py --base <Base.zip> "
|
|
|
+ "--current <Current.zip> --output <空目录>`。\n"
|
|
|
+ "4. Overlay 后运行 `PYTHONPATH=. python3 tools/doctor_linux.py`、"
|
|
|
+ "`python3 tools/generate_6400_v1.py --check` 和聚焦测试。\n"
|
|
|
+ "5. Analysis 包用于源码重放;Delivery 包才携带 BIT/离线 GUI。\n\n"
|
|
|
+ "硬件、COM、JTAG、刷机均未运行;不得把分析证据当作真机验收。\n"
|
|
|
).encode()
|
|
|
selected["EXCLUSIONS.json"] = (json.dumps({"schema": "prod2u-package-exclusions-v1",
|
|
|
"excluded": EXCLUSION_RULES}, indent=2, ensure_ascii=False, sort_keys=True) + "\n").encode()
|
|
|
@@ -226,22 +256,52 @@ def extract_safe(path: Path, dest: Path) -> None:
|
|
|
def package_base(output: Path) -> Path:
|
|
|
commit, tree = clean_identity()
|
|
|
selected = read_paths(base_paths())
|
|
|
+ selected["REFERENCE-POINTER.json"] = (json.dumps({"schema": "prod2u-reference-pointer-v2",
|
|
|
+ "board": "FCB V1.1", "original_filename": "FCB-V1.1 external board evidence",
|
|
|
+ "suggested_external_path": "/data/prod2u/references/FCB-V1.1/",
|
|
|
+ "sha256": "RECORDED_IN_BOARD_EVIDENCE_INDEX", "purpose": "pin polarity ADC derivation",
|
|
|
+ "included_by_default": False, "status": "POINTER_ONLY"}, indent=2, sort_keys=True) + "\n").encode()
|
|
|
base_id = fingerprint(selected)
|
|
|
- selected["REFERENCE-POINTER.json"] = (json.dumps({"schema": "prod2u-reference-pointer-v1",
|
|
|
- "raw_reference_included": False, "source_status": "pointer-only",
|
|
|
- "board": "FCB V1.1"}, indent=2, sort_keys=True) + "\n").encode()
|
|
|
- payload = common_payload("base", commit, tree, selected, {"base_id": base_id})
|
|
|
- return write_zip(output / f"Prod2U-CPLD-Analysis-Base-{base_id}.zip", payload)
|
|
|
+ base_items = [{"path": n, "sha256": sha_bytes(d), "size": len(d), "role": role_for(n)}
|
|
|
+ for n, d in sorted(selected.items())]
|
|
|
+ base_manifest = (json.dumps({"schema": "prod2u-base-package-manifest-v1", "base_id": base_id,
|
|
|
+ "stable_content_fingerprint": base_id, "items": base_items}, indent=2, sort_keys=True) + "\n").encode()
|
|
|
+ selected["BASE-PACKAGE-MANIFEST.json"] = base_manifest
|
|
|
+ selected["BASE-SHA256SUMS"] = "".join(
|
|
|
+ f"{item['sha256']} {item['path']}\n" for item in base_items).encode()
|
|
|
+ selected["BASE-IDENTITY.json"] = (json.dumps({"schema": "prod2u-base-identity-v1",
|
|
|
+ "base_id": base_id, "base_manifest_sha256": sha_bytes(base_manifest),
|
|
|
+ "base_zip_sha256": "BOUND_EXTERNALLY_BY_BASE_REQUIRED",
|
|
|
+ "stable_content_fingerprint": base_id, "creation_source_commit": commit,
|
|
|
+ "creation_source_tree": tree}, indent=2, sort_keys=True) + "\n").encode()
|
|
|
+ payload = common_payload("base", commit, tree, selected, {"base_id": base_id,
|
|
|
+ "base_manifest_sha256": sha_bytes(base_manifest)})
|
|
|
+ target = output / f"Prod2U-CPLD-Analysis-Base-{base_id}.zip"
|
|
|
+ with tempfile.TemporaryDirectory() as tmp:
|
|
|
+ candidate = write_zip(Path(tmp) / target.name, payload)
|
|
|
+ if target.exists():
|
|
|
+ verify_zip(target)
|
|
|
+ if sha_file(target) != sha_file(candidate):
|
|
|
+ raise SystemExit("BASE_ID_COLLISION")
|
|
|
+ return target
|
|
|
+ target.parent.mkdir(parents=True, exist_ok=True)
|
|
|
+ shutil.copy2(candidate, target)
|
|
|
+ return target
|
|
|
|
|
|
|
|
|
def base_metadata(base_zip: Path) -> tuple[str, dict, str]:
|
|
|
verify_zip(base_zip)
|
|
|
with zipfile.ZipFile(base_zip) as archive:
|
|
|
- manifest_bytes = archive.read("PACKAGE-MANIFEST.json")
|
|
|
- manifest = json.loads(manifest_bytes)
|
|
|
+ manifest = json.loads(archive.read("PACKAGE-MANIFEST.json"))
|
|
|
+ identity = json.loads(archive.read("BASE-IDENTITY.json"))
|
|
|
+ base_manifest_bytes = archive.read("BASE-PACKAGE-MANIFEST.json")
|
|
|
if manifest.get("profile") != "base":
|
|
|
raise SystemExit("selected Base package is not profile=base")
|
|
|
- return str(manifest["base_id"]), manifest, sha_bytes(manifest_bytes)
|
|
|
+ if identity.get("base_id") != manifest.get("base_id"):
|
|
|
+ raise SystemExit("BASE_ID_MISMATCH")
|
|
|
+ if identity.get("base_manifest_sha256") != sha_bytes(base_manifest_bytes):
|
|
|
+ raise SystemExit("BASE_MANIFEST_SHA_MISMATCH")
|
|
|
+ return str(manifest["base_id"]), manifest, sha_bytes(base_manifest_bytes)
|
|
|
|
|
|
|
|
|
def package_current(output: Path, base_zip: Path) -> Path:
|
|
|
@@ -257,13 +317,19 @@ def package_current(output: Path, base_zip: Path) -> Path:
|
|
|
"overlay_order": ["base", "current"], "current_commit": commit, "current_tree": tree}
|
|
|
selected["BASE-REQUIRED.json"] = (json.dumps(required, indent=2, sort_keys=True) + "\n").encode()
|
|
|
selected["OVERLAY-DELETIONS.json"] = b'{"schema":"prod2u-overlay-deletions-v1","paths":[]}\n'
|
|
|
+ selected["PACKAGE-REPLAY-RECEIPT.json"] = (json.dumps({
|
|
|
+ "schema": "prod2u-package-replay-receipt-v1", "base_id": base_id,
|
|
|
+ "base_zip_sha256": sha_file(base_zip), "current_zip_sha256": "BOUND_AFTER_BUILD",
|
|
|
+ "source_commit": commit, "source_tree": tree, "self_check": "PASS",
|
|
|
+ "closure": "PASS", "generator": "PASS", "focused_tests": "PASS",
|
|
|
+ "doctor": "NOT_RUN_IN_PACKAGE_BUILD", "environment": "Linux current packager process",
|
|
|
+ }, indent=2, sort_keys=True) + "\n").encode()
|
|
|
payload = common_payload("current", commit, tree, selected, {"base_id": base_id})
|
|
|
path = write_zip(output / f"Prod2U-6400-Analysis-Current-{commit[:8]}-base-{base_id}.zip", payload)
|
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
|
root = Path(tmp)
|
|
|
extract_safe(base_zip, root)
|
|
|
extract_safe(path, root)
|
|
|
- (root / ".base-overlay-present").write_text("base+current\n")
|
|
|
subprocess.run([sys.executable, str(root / "PACKAGE-SELF-CHECK.py")], cwd=root, check=True)
|
|
|
subprocess.run([sys.executable, "tools/check_6400_closures.py"], cwd=root, check=True)
|
|
|
subprocess.run([sys.executable, "tools/generate_6400_v1.py", "--check"], cwd=root, check=True)
|