package-image: keep MT6797 firmware blobs by default

This commit is contained in:
Luxferre committed 2026-11-28 11:19:38 +02:00
1 parent 29314ca9e6
commit 561dc2633b
4 files changed
+34 -9

No files matched your search

+8 -6
View File
@@ -96,7 +96,7 @@ def _debugfs_ls_details(abs_img, internal_dir):
return out
def sanitize_ext4_for_release(img_path, strip_firmware=True, strip_ssh_keys=True):
def sanitize_ext4_for_release(img_path, strip_firmware=False, strip_ssh_keys=True):
"""Remove SSH keys and/or proprietary MT6797 firmware blobs from a staged ext4 image."""
fw_mod = _load_fw_mod()
abs_img = os.path.abspath(img_path)
@@ -170,10 +170,10 @@ e2fsck -fn "$IMG" >/dev/null
return ["(sanitized via docker e2fsprogs)"]
def render_flash_instructions(version, codename, build_date, top_dir, include_firmware=False):
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 = (
"INCLUDED (for personal single-device backup images)"
"INCLUDED (bundled in rootfs)"
if include_firmware else
"CLEAN / STRIPPED (auto-extracted from your PDA during flashing)"
)
@@ -351,7 +351,7 @@ def package_release_zip(
output_zip=None,
version=None,
codename=None,
include_firmware=False,
include_firmware=True,
keep_ssh_keys=False,
compress_level=6,
verify=True,
@@ -472,8 +472,10 @@ def build_arg_parser():
help="Directory containing boot-geminux.img, recovery-geminux.img, geminux-rootfs.img")
p.add_argument("--version", help="Override Geminux version string")
p.add_argument("--codename", help="Override Geminux codename")
p.add_argument("--include-firmware", action="store_true",
help="Keep /lib/firmware/mediatek/mt6797 blobs inside packaged rootfs (not for redistribution)")
p.add_argument("--include-firmware", dest="include_firmware", action="store_true", default=True,
help="Keep /lib/firmware/mediatek/mt6797 blobs inside packaged rootfs (default)")
p.add_argument("--strip-firmware", dest="include_firmware", action="store_false",
help="Strip /lib/firmware/mediatek/mt6797 blobs for clean redistribution")
p.add_argument("--keep-ssh-keys", action="store_true",
help="Keep SSH authorized_keys and ssh_host_* keys in packaged rootfs")
p.add_argument("--compress-level", type=int, default=6, choices=range(0, 10), metavar="0..9",
+24 -1
View File
@@ -927,11 +927,34 @@ def test_release_zip_packager():
sanitized_img = os.path.join(rel_dir, "images", "geminux-rootfs.img")
assert subprocess.run(["e2fsck", "-fn", sanitized_img], capture_output=True).returncode == 0
fw_mod = flash_mtk.load_firmware_module()
assert fw_mod.debugfs_ls(sanitized_img, "lib/firmware/mediatek/mt6797") == []
fw_entries = set(fw_mod.debugfs_ls(sanitized_img, "lib/firmware/mediatek/mt6797"))
assert {"WIFI_RAM_CODE_6797", "MANIFEST.sha256"}.issubset(fw_entries), (
f"Default package-image.sh must keep MT6797 firmware blobs; got {sorted(fw_entries)}"
)
assert [n for n, _m in pkg_mod._debugfs_ls_details(sanitized_img, "etc/ssh") if n.startswith("ssh_host_")] == []
assert "sshd_config" in fw_mod.debugfs_ls(sanitized_img, "etc/ssh")
assert not fw_mod._debugfs_path_exists(sanitized_img, "/root/.ssh/authorized_keys")
assert not fw_mod._debugfs_path_exists(sanitized_img, "/home/user/.ssh/authorized_keys")
stripped_zip = os.path.join(tmp, "geminux-0.1.0-helio-gemini-x27-stripped.zip")
sres = subprocess.run(
[
os.path.join(BASE_DIR, "package-image.sh"),
"--images-dir", img_dir,
"--output", stripped_zip,
"--version", "0.1.0",
"--codename", "helio",
"--strip-firmware",
],
capture_output=True, text=True, check=False,
)
assert sres.returncode == 0, f"package-image.sh --strip-firmware failed:\n{sres.stdout}\n{sres.stderr}"
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)
stripped_img = os.path.join(strip_dir, top, "images", "geminux-rootfs.img")
assert subprocess.run(["e2fsck", "-fn", stripped_img], capture_output=True).returncode == 0
assert fw_mod.debugfs_ls(stripped_img, "lib/firmware/mediatek/mt6797") == []
print("[PASS] Release ZIP packager (sanitized rootfs, FLASH-INSTRUCTIONS.txt, SHA256SUMS, runnable flasher) verified")