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

+1 -1
View File
@@ -53,4 +53,4 @@ Target `$ROOTFS` installs only pure **Alpine Edge** (`main`, `community`, `testi
- **BROM/DA Flasher**: [flash-mtk.py](flash-mtk.py) uses vendored `mtkclient` + `MTK_DA_V5_MT6797.bin`, write-blocking protected factory partitions (`LBA 0..0x6FFFF` / `0x0E000000`, verified in [scripts/test-flash-mtk-gpt.py](scripts/test-flash-mtk-gpt.py)). - **BROM/DA Flasher**: [flash-mtk.py](flash-mtk.py) uses vendored `mtkclient` + `MTK_DA_V5_MT6797.bin`, write-blocking protected factory partitions (`LBA 0..0x6FFFF` / `0x0E000000`, verified in [scripts/test-flash-mtk-gpt.py](scripts/test-flash-mtk-gpt.py)).
- **Staged ext4 Customization**: On temporary ext4 copies, [scripts/extract-vendor-fw.py](scripts/extract-vendor-fw.py) injects MT6797 firmware blobs via `debugfs`/`e2fsck`, [scripts/geminux_accounts.py](scripts/geminux_accounts.py) provisions SHA-512 `/etc/{passwd,group,shadow}` + `/home/<user>`, and [scripts/geminux_luks.py](scripts/geminux_luks.py) optionally applies offline LUKS2 encryption (`cryptsetup reencrypt`). - **Staged ext4 Customization**: On temporary ext4 copies, [scripts/extract-vendor-fw.py](scripts/extract-vendor-fw.py) injects MT6797 firmware blobs via `debugfs`/`e2fsck`, [scripts/geminux_accounts.py](scripts/geminux_accounts.py) provisions SHA-512 `/etc/{passwd,group,shadow}` + `/home/<user>`, and [scripts/geminux_luks.py](scripts/geminux_luks.py) optionally applies offline LUKS2 encryption (`cryptsetup reencrypt`).
- **Release ZIP Packager**: [package-image.sh](package-image.sh) ([scripts/package-release-zip.py](scripts/package-release-zip.py)) clones and sanitizes `geminux-rootfs.img` (stripping SSH keys and proprietary MT6797 blobs by default), runs `e2fsck -fn`, generates `SHA256SUMS.txt` + `FLASH-INSTRUCTIONS.txt`, and writes a verified ZIP64 release archive + `.sha256`. - **Release ZIP Packager**: [package-image.sh](package-image.sh) ([scripts/package-release-zip.py](scripts/package-release-zip.py)) clones and stages `geminux-rootfs.img` (stripping SSH keys while keeping `/lib/firmware/mediatek/mt6797/` blobs by default; `--strip-firmware` strips blobs, `--keep-ssh-keys` preserves SSH keys), runs `e2fsck -fn`, generates `SHA256SUMS.txt` + `FLASH-INSTRUCTIONS.txt`, and writes a verified ZIP64 release archive + `.sha256`.
+1 -1
View File
@@ -42,7 +42,7 @@ Create a self-contained ZIP archive under `releases/` containing the images, `SH
./package-image.sh # or ./rebuild-image.sh --package ./package-image.sh # or ./rebuild-image.sh --package
``` ```
By default, [scripts/package-release-zip.py](scripts/package-release-zip.py) stages a copy of `geminux-rootfs.img`, strips SSH host/authorized keys and proprietary `/lib/firmware/mediatek/mt6797/` blobs so the archive can be shared safely, verifies `e2fsck -fn` and ZIP CRCs, and writes `<archive>.zip.sha256` (`--include-firmware` / `--keep-ssh-keys` keep them for single-device personal archives). By default, [scripts/package-release-zip.py](scripts/package-release-zip.py) stages a copy of `geminux-rootfs.img`, strips SSH host/authorized keys while keeping `/lib/firmware/mediatek/mt6797/` blobs (`--include-firmware` default), verifies `e2fsck -fn` and ZIP CRCs, and writes `<archive>.zip.sha256` (`--strip-firmware` omits proprietary blobs for clean redistribution; `--keep-ssh-keys` keeps SSH keys).
## Flashing to the Gemini PDA ## Flashing to the Gemini PDA
+8 -6
View File
@@ -96,7 +96,7 @@ def _debugfs_ls_details(abs_img, internal_dir):
return out 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.""" """Remove SSH keys and/or proprietary MT6797 firmware blobs from a staged ext4 image."""
fw_mod = _load_fw_mod() fw_mod = _load_fw_mod()
abs_img = os.path.abspath(img_path) abs_img = os.path.abspath(img_path)
@@ -170,10 +170,10 @@ e2fsck -fn "$IMG" >/dev/null
return ["(sanitized via docker e2fsprogs)"] 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.""" """Generate plain-text FLASH-INSTRUCTIONS.txt shipped inside the release ZIP."""
fw_mode = ( fw_mode = (
"INCLUDED (for personal single-device backup images)" "INCLUDED (bundled in rootfs)"
if include_firmware else if include_firmware else
"CLEAN / STRIPPED (auto-extracted from your PDA during flashing)" "CLEAN / STRIPPED (auto-extracted from your PDA during flashing)"
) )
@@ -351,7 +351,7 @@ def package_release_zip(
output_zip=None, output_zip=None,
version=None, version=None,
codename=None, codename=None,
include_firmware=False, include_firmware=True,
keep_ssh_keys=False, keep_ssh_keys=False,
compress_level=6, compress_level=6,
verify=True, verify=True,
@@ -472,8 +472,10 @@ def build_arg_parser():
help="Directory containing boot-geminux.img, recovery-geminux.img, geminux-rootfs.img") help="Directory containing boot-geminux.img, recovery-geminux.img, geminux-rootfs.img")
p.add_argument("--version", help="Override Geminux version string") p.add_argument("--version", help="Override Geminux version string")
p.add_argument("--codename", help="Override Geminux codename") p.add_argument("--codename", help="Override Geminux codename")
p.add_argument("--include-firmware", action="store_true", p.add_argument("--include-firmware", dest="include_firmware", action="store_true", default=True,
help="Keep /lib/firmware/mediatek/mt6797 blobs inside packaged rootfs (not for redistribution)") 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", p.add_argument("--keep-ssh-keys", action="store_true",
help="Keep SSH authorized_keys and ssh_host_* keys in packaged rootfs") 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", 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") sanitized_img = os.path.join(rel_dir, "images", "geminux-rootfs.img")
assert subprocess.run(["e2fsck", "-fn", sanitized_img], capture_output=True).returncode == 0 assert subprocess.run(["e2fsck", "-fn", sanitized_img], capture_output=True).returncode == 0
fw_mod = flash_mtk.load_firmware_module() 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 [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 "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, "/root/.ssh/authorized_keys")
assert not fw_mod._debugfs_path_exists(sanitized_img, "/home/user/.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") print("[PASS] Release ZIP packager (sanitized rootfs, FLASH-INSTRUCTIONS.txt, SHA256SUMS, runnable flasher) verified")