package-image: clarify SSH key vs firmware sanitization log

This commit is contained in:
Luxferre committed 2026-11-28 12:31:11 +02:00
1 parent 775baef460
commit 2c3278024e
2 files changed
+18 -4

No files matched your search

+15 -4
View File
@@ -208,6 +208,19 @@ e2fsck -fn "$IMG" >/dev/null
return ["(sanitized via docker e2fsprogs)"]
def _format_sanitize_summary(removed, include_firmware, keep_ssh_keys):
"""Format a clear rootfs sanitization summary distinguishing SSH keys vs firmware."""
if removed == ["(sanitized via docker e2fsprogs)"]:
ssh_part = "SSH keys kept" if keep_ssh_keys else "SSH keys stripped"
fw_part = "firmware kept" if include_firmware else "firmware stripped"
return f"sanitized via docker e2fsprogs; {ssh_part}; {fw_part}; e2fsck clean"
fw_removed = sum(1 for p in removed if p.startswith("/lib/firmware/"))
key_removed = len(removed) - fw_removed
ssh_part = "SSH keys kept" if keep_ssh_keys else f"stripped {key_removed} SSH key file(s)"
fw_part = "firmware kept" if include_firmware else f"stripped {fw_removed} firmware file(s)"
return f"{ssh_part}; {fw_part}; e2fsck clean"
def render_flash_instructions(version, codename, build_date, top_dir, include_firmware=True):
"""Generate plain-text FLASH-INSTRUCTIONS.txt shipped inside the release ZIP."""
fw_mode = (
@@ -426,10 +439,8 @@ def package_release_zip(
strip_firmware=not include_firmware,
strip_ssh_keys=not keep_ssh_keys,
)
print(
f"[+] Sanitized staged ext4 rootfs (stripped {len(removed)} "
"firmware/key file(s); e2fsck clean)."
)
summary = _format_sanitize_summary(removed, include_firmware, keep_ssh_keys)
print(f"[+] Sanitized staged ext4 rootfs ({summary}).")
sums_lines = [
f"{sha256_file(boot_img)} images/boot-geminux.img",
+3
View File
@@ -913,6 +913,8 @@ def test_release_zip_packager():
env=pkg_env, capture_output=True, text=True, check=False,
)
assert res.returncode == 0, f"package-image.sh failed:\n{res.stdout}\n{res.stderr}"
assert "stripped 4 SSH key file(s); firmware kept; e2fsck clean" in res.stdout, res.stdout
assert "firmware/key" not in res.stdout, res.stdout
assert flash_mtk.sha256_file(root_img) == orig_root_sha, "Source rootfs image was mutated!"
assert os.path.isfile(out_zip) and os.path.isfile(out_zip + ".sha256")
@@ -992,6 +994,7 @@ def test_release_zip_packager():
env=pkg_env, capture_output=True, text=True, check=False,
)
assert sres.returncode == 0, f"package-image.sh --strip-firmware failed:\n{sres.stdout}\n{sres.stderr}"
assert "stripped 4 SSH key file(s); stripped 2 firmware file(s); e2fsck clean" in sres.stdout, sres.stdout
strip_dir = os.path.join(tmp, "extracted-stripped")
os.makedirs(strip_dir, exist_ok=True)
subprocess.run(["unzip", "-q", stripped_zip, "-d", strip_dir], check=True)