Просмотр исходного кода

Add evidence-dir support to build_firmware_package.py.

Allows final firmware packages to include offline verification matrix
receipts and logs without hard-coding evidence paths.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Codex Resource Selftest 4 месяцев назад
Родитель
Сommit
a5037551ce
1 измененных файлов с 10 добавлено и 0 удалено
  1. 10 0
      tools/build_firmware_package.py

+ 10 - 0
tools/build_firmware_package.py

@@ -69,6 +69,7 @@ def build_firmware_package(
     source_closure_unchanged: bool,
     bitstream_path: Path = BITSTREAM,
     td_report_path: Path = TD_REPORT,
+    evidence_dir: Path | None = None,
 ) -> Path:
     if not bitstream_path.is_file():
         raise FileNotFoundError(f"bitstream not found: {bitstream_path}")
@@ -164,6 +165,13 @@ def build_firmware_package(
         # Source closure manifest
         add_and_hash(ROOT / "config" / "source_closure.json", "config/source_closure.json")
 
+        # Optional verification/matrix evidence
+        if evidence_dir is not None and evidence_dir.is_dir():
+            for ev_file in evidence_dir.rglob("*"):
+                if ev_file.is_file():
+                    arcname = "evidence/" + "/".join(ev_file.relative_to(evidence_dir).parts)
+                    add_and_hash(ev_file, arcname)
+
         # Manifest and SHA256SUMS
         manifest_text = json.dumps(manifest, indent=2, sort_keys=True) + "\n"
         add_text_and_hash(manifest_text, "PACKAGE-MANIFEST.json")
@@ -181,6 +189,7 @@ def main(argv: list[str] | None = None) -> int:
     parser.add_argument("--source-closure-unchanged", action="store_true")
     parser.add_argument("--bitstream", type=Path, default=BITSTREAM)
     parser.add_argument("--td-report", type=Path, default=TD_REPORT)
+    parser.add_argument("--evidence-dir", type=Path, default=None)
     args = parser.parse_args(argv)
 
     try:
@@ -192,6 +201,7 @@ def main(argv: list[str] | None = None) -> int:
             source_closure_unchanged=args.source_closure_unchanged,
             bitstream_path=args.bitstream,
             td_report_path=args.td_report,
+            evidence_dir=args.evidence_dir,
         )
     except FileNotFoundError as exc:
         print(f"blocked: {exc}", file=sys.stderr)