Package release ZIPs, streamline docs, and backport X11 DPMS/lock fixes
- Streamline README, INSTALL, MANUAL, ARCHITECTURE, and POWER-OPTIMIZATION docs - Add release ZIP packager (package-image.sh, scripts/package-release-zip.py, rebuild-image.sh --package) with sanitized rootfs, SHA256SUMS, and FLASH-INSTRUCTIONS.txt - Add automatic offline MT6797 firmware ext4 injection in flash-mtk.py and scripts/extract-vendor-fw.py - Backport X11 DPMS wake + XResetScreenSaver in geminux-powerd and _GEMINUX_LOCK_READY + grab-first sync in geminux-lock, rebuild aarch64 prebuilts, and expand tests
This commit is contained in:
1 parent
5472d4273a
commit
180d0a91e6
18 files changed
+1242
-480
No files matched your search
+101
-10
@@ -33,6 +33,46 @@ SEARCH_SUBDIRS = (
|
||||
SPARSE_MAGIC = b"\x3a\xff\x26\xed"
|
||||
|
||||
|
||||
def is_firmware_blob_name(name):
|
||||
"""Return True if filename is a required MT6797 blob or optional SPM binary."""
|
||||
return name in REQUIRED_BLOBS or (
|
||||
name.startswith(OPTIONAL_SPM_GLOB_PREFIX) and name.endswith(".bin")
|
||||
)
|
||||
|
||||
|
||||
def list_firmware_blobs(fw_dir):
|
||||
"""Return sorted (filename, abs_path) pairs for MT6797 firmware blobs in fw_dir."""
|
||||
if not fw_dir or not os.path.isdir(fw_dir):
|
||||
return []
|
||||
abs_fw = os.path.abspath(fw_dir)
|
||||
blobs = []
|
||||
for name in sorted(os.listdir(abs_fw)):
|
||||
if not is_firmware_blob_name(name):
|
||||
continue
|
||||
path = os.path.join(abs_fw, name)
|
||||
if os.path.isfile(path) and not os.path.islink(path):
|
||||
blobs.append((name, path))
|
||||
return blobs
|
||||
|
||||
|
||||
def _have_host_e2fs():
|
||||
return shutil.which("debugfs") is not None and shutil.which("e2fsck") is not None
|
||||
|
||||
|
||||
def _run_docker_e2fs(img_dir, extra_mounts, shell_cmd, input_text=None):
|
||||
docker_bin = shutil.which("docker")
|
||||
if not docker_bin:
|
||||
raise RuntimeError("Need host debugfs/e2fsck (e2fsprogs) or docker to modify ext4 image")
|
||||
cmd = [docker_bin, "run", "--rm", "-i", "-v", f"{img_dir}:/img"]
|
||||
for host_path, container_path in extra_mounts:
|
||||
cmd += ["-v", f"{host_path}:{container_path}:ro"]
|
||||
cmd += [
|
||||
"alpine:3.24", "sh", "-eu", "-c",
|
||||
f"apk add --no-cache e2fsprogs >/dev/null && {shell_cmd}",
|
||||
]
|
||||
return subprocess.run(cmd, input=input_text, text=True, check=True, capture_output=True)
|
||||
|
||||
|
||||
def sha256_file(path):
|
||||
h = hashlib.sha256()
|
||||
with open(path, "rb") as f:
|
||||
@@ -81,11 +121,7 @@ def extract_from_ext4(image_path, out_dir):
|
||||
if not entries:
|
||||
continue
|
||||
for name in entries:
|
||||
is_req = name in REQUIRED_BLOBS
|
||||
is_spm = name.startswith(OPTIONAL_SPM_GLOB_PREFIX) and name.endswith(".bin")
|
||||
if not (is_req or is_spm):
|
||||
continue
|
||||
if name in found:
|
||||
if not is_firmware_blob_name(name) or name in found:
|
||||
continue
|
||||
dest = os.path.join(out_dir, name)
|
||||
if debugfs_dump(image_path, f"{subdir}/{name}", dest):
|
||||
@@ -102,11 +138,7 @@ def extract_from_dir(src_dir, out_dir):
|
||||
if not os.path.isdir(base):
|
||||
continue
|
||||
for name in os.listdir(base):
|
||||
is_req = name in REQUIRED_BLOBS
|
||||
is_spm = name.startswith(OPTIONAL_SPM_GLOB_PREFIX) and name.endswith(".bin")
|
||||
if not (is_req or is_spm):
|
||||
continue
|
||||
if name in found:
|
||||
if not is_firmware_blob_name(name) or name in found:
|
||||
continue
|
||||
src = os.path.join(base, name)
|
||||
if os.path.isfile(src):
|
||||
@@ -116,6 +148,65 @@ def extract_from_dir(src_dir, out_dir):
|
||||
return found
|
||||
|
||||
|
||||
def _debugfs_path_exists(abs_img, internal_path):
|
||||
res = subprocess.run(
|
||||
["debugfs", "-R", f"stat {internal_path}", abs_img],
|
||||
capture_output=True, text=True, check=False,
|
||||
)
|
||||
return res.returncode == 0 and "Type:" in res.stdout
|
||||
|
||||
|
||||
def inject_firmware_into_ext4(ext4_img_path, fw_dir):
|
||||
"""Inject extracted MT6797 firmware blobs into /lib/firmware/mediatek/mt6797 of an ext4 image."""
|
||||
blobs = list_firmware_blobs(fw_dir)
|
||||
if not blobs:
|
||||
return []
|
||||
|
||||
abs_img = os.path.abspath(ext4_img_path)
|
||||
if not os.path.isfile(abs_img):
|
||||
raise FileNotFoundError(f"ext4 image not found: {abs_img}")
|
||||
abs_fw = os.path.abspath(fw_dir)
|
||||
img_dir = os.path.dirname(abs_img)
|
||||
img_name = os.path.basename(abs_img)
|
||||
use_host = _have_host_e2fs()
|
||||
|
||||
target_dirs = ("/lib", "/lib/firmware", "/lib/firmware/mediatek", "/lib/firmware/mediatek/mt6797")
|
||||
existing_files = set(debugfs_ls(abs_img, "lib/firmware/mediatek/mt6797")) if use_host else set()
|
||||
|
||||
def build_cmds(fw_prefix, check_exists):
|
||||
cmds = []
|
||||
for d in target_dirs:
|
||||
if not check_exists or not _debugfs_path_exists(abs_img, d):
|
||||
cmds.append(f"mkdir {d}")
|
||||
cmds.append(f"set_inode_field {d} uid 0")
|
||||
cmds.append(f"set_inode_field {d} gid 0")
|
||||
cmds.append(f"set_inode_field {d} mode 040755")
|
||||
for name, _host_p in blobs:
|
||||
dst = f"/lib/firmware/mediatek/mt6797/{name}"
|
||||
if not check_exists or name in existing_files:
|
||||
cmds.append(f"rm {dst}")
|
||||
cmds.append(f"write {fw_prefix}/{name} {dst}")
|
||||
cmds.append(f"set_inode_field {dst} uid 0")
|
||||
cmds.append(f"set_inode_field {dst} gid 0")
|
||||
cmds.append(f"set_inode_field {dst} mode 0100644")
|
||||
return "\n".join(cmds) + "\n"
|
||||
|
||||
if use_host:
|
||||
subprocess.run(
|
||||
["debugfs", "-w", abs_img],
|
||||
input=build_cmds(abs_fw, True), text=True, check=True, stdout=subprocess.DEVNULL,
|
||||
)
|
||||
subprocess.run(["e2fsck", "-fn", abs_img], check=True, stdout=subprocess.DEVNULL)
|
||||
else:
|
||||
_run_docker_e2fs(
|
||||
img_dir,
|
||||
[(abs_fw, "/fw")],
|
||||
f"debugfs -w '/img/{img_name}' >/dev/null 2>&1 && e2fsck -fn '/img/{img_name}' >/dev/null",
|
||||
input_text=build_cmds("/fw", False),
|
||||
)
|
||||
return [name for name, _p in blobs]
|
||||
|
||||
|
||||
def write_manifest(out_dir, found):
|
||||
manifest = os.path.join(out_dir, "MANIFEST.sha256")
|
||||
with open(manifest, "w") as f:
|
||||
|
||||
Executable
+501
@@ -0,0 +1,501 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Package Geminux flash images, pure-Linux MTK flasher, and TXT guide into a ZIP release."""
|
||||
|
||||
import argparse
|
||||
import datetime
|
||||
import hashlib
|
||||
import importlib.util
|
||||
import os
|
||||
import shutil
|
||||
import stat
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
import zipfile
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
SCRIPTS_DIR = os.path.join(BASE_DIR, "scripts")
|
||||
|
||||
SPARSE_MAGIC = b"\x3a\xff\x26\xed"
|
||||
|
||||
FLASH_SCRIPTS = (
|
||||
("scripts/bootstrap-flash-deps.sh", True),
|
||||
("scripts/extract-vendor-fw.py", True),
|
||||
("scripts/geminux_accounts.py", False),
|
||||
("scripts/geminux_gpt.py", True),
|
||||
("scripts/geminux_luks.py", False),
|
||||
)
|
||||
|
||||
SKIP_VENDOR_DIRS = frozenset({"__pycache__"})
|
||||
SKIP_VENDOR_FILES = frozenset({".DS_Store", ".state"})
|
||||
SKIP_VENDOR_SUFFIXES = (".pyc", ".pyo")
|
||||
|
||||
|
||||
def _load_fw_mod():
|
||||
fw_path = os.path.join(SCRIPTS_DIR, "extract-vendor-fw.py")
|
||||
spec = importlib.util.spec_from_file_location("extract_vendor_fw", fw_path)
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(mod)
|
||||
return mod
|
||||
|
||||
|
||||
def _query_version_field(flag, fallback):
|
||||
ver_sh = os.path.join(SCRIPTS_DIR, "version.sh")
|
||||
if not os.path.isfile(ver_sh):
|
||||
return fallback
|
||||
res = subprocess.run([ver_sh, flag], capture_output=True, text=True, check=False)
|
||||
val = res.stdout.strip()
|
||||
return val if res.returncode == 0 and val else fallback
|
||||
|
||||
|
||||
def sha256_file(path):
|
||||
"""Compute streaming SHA-256 hex digest for a file."""
|
||||
h = hashlib.sha256()
|
||||
with open(path, "rb") as f:
|
||||
while True:
|
||||
chunk = f.read(1048576)
|
||||
if not chunk:
|
||||
break
|
||||
h.update(chunk)
|
||||
return h.hexdigest()
|
||||
|
||||
|
||||
def copy_sparse_raw_image(src, dst):
|
||||
"""Unsparse src if needed, otherwise copy sparsely into dst."""
|
||||
with open(src, "rb") as f:
|
||||
is_sparse = f.read(4) == SPARSE_MAGIC
|
||||
if is_sparse:
|
||||
simg = shutil.which("simg2img")
|
||||
if not simg:
|
||||
raise RuntimeError("simg2img is required to unpack sparse geminux-rootfs.img")
|
||||
subprocess.run([simg, src, dst], check=True)
|
||||
return
|
||||
if shutil.which("cp"):
|
||||
subprocess.run(["cp", "--reflink=auto", "--sparse=always", src, dst], check=True)
|
||||
else:
|
||||
shutil.copyfile(src, dst)
|
||||
|
||||
|
||||
def _debugfs_ls_details(abs_img, internal_dir):
|
||||
"""Return list of (name, mode_str) entries inside internal_dir of an ext4 image."""
|
||||
res = subprocess.run(
|
||||
["debugfs", "-R", f"ls -p /{internal_dir}", abs_img],
|
||||
capture_output=True, text=True, check=False,
|
||||
)
|
||||
if res.returncode != 0:
|
||||
return []
|
||||
out = []
|
||||
for line in res.stdout.splitlines():
|
||||
parts = line.split("/")
|
||||
if len(parts) >= 6:
|
||||
mode_str = parts[2]
|
||||
name = parts[5]
|
||||
if name and name not in (".", ".."):
|
||||
out.append((name, mode_str))
|
||||
return out
|
||||
|
||||
|
||||
def sanitize_ext4_for_release(img_path, strip_firmware=True, 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)
|
||||
if not os.path.isfile(abs_img):
|
||||
raise FileNotFoundError(f"ext4 image not found: {abs_img}")
|
||||
|
||||
if fw_mod._have_host_e2fs():
|
||||
rm_paths = []
|
||||
if strip_ssh_keys:
|
||||
if fw_mod._debugfs_path_exists(abs_img, "/root/.ssh/authorized_keys"):
|
||||
rm_paths.append("/root/.ssh/authorized_keys")
|
||||
for hname, hmode in _debugfs_ls_details(abs_img, "home"):
|
||||
if hmode.startswith("04"):
|
||||
ak = f"/home/{hname}/.ssh/authorized_keys"
|
||||
if fw_mod._debugfs_path_exists(abs_img, ak):
|
||||
rm_paths.append(ak)
|
||||
for ename, emode in _debugfs_ls_details(abs_img, "etc/ssh"):
|
||||
if not emode.startswith("04") and ename.startswith("ssh_host_"):
|
||||
rm_paths.append(f"/etc/ssh/{ename}")
|
||||
|
||||
if strip_firmware:
|
||||
for fname, fmode in _debugfs_ls_details(abs_img, "lib/firmware/mediatek/mt6797"):
|
||||
if not fmode.startswith("04"):
|
||||
rm_paths.append(f"/lib/firmware/mediatek/mt6797/{fname}")
|
||||
|
||||
if rm_paths:
|
||||
script = "\n".join(f"rm {p}" for p in rm_paths) + "\n"
|
||||
subprocess.run(
|
||||
["debugfs", "-w", abs_img],
|
||||
input=script, text=True, check=True, stdout=subprocess.DEVNULL,
|
||||
)
|
||||
subprocess.run(["e2fsck", "-fn", abs_img], check=True, stdout=subprocess.DEVNULL)
|
||||
return rm_paths
|
||||
|
||||
# Docker fallback when host lacks e2fsprogs
|
||||
img_dir = os.path.dirname(abs_img)
|
||||
img_name = os.path.basename(abs_img)
|
||||
sf_flag = "1" if strip_firmware else "0"
|
||||
sk_flag = "1" if strip_ssh_keys else "0"
|
||||
docker_sh = f"""
|
||||
IMG="/img/{img_name}"
|
||||
RM_CMDS=""
|
||||
if [ "{sk_flag}" = "1" ]; then
|
||||
if debugfs -R "stat /root/.ssh/authorized_keys" "$IMG" 2>/dev/null | grep -q "Type:"; then
|
||||
RM_CMDS="$RM_CMDS
|
||||
rm /root/.ssh/authorized_keys"
|
||||
fi
|
||||
for u in $(debugfs -R "ls -p /home" "$IMG" 2>/dev/null | awk -F/ '$3 ~ /^04/ && $6 != "" && $6 != "." && $6 != ".." {{print $6}}'); do
|
||||
if debugfs -R "stat /home/$u/.ssh/authorized_keys" "$IMG" 2>/dev/null | grep -q "Type:"; then
|
||||
RM_CMDS="$RM_CMDS
|
||||
rm /home/$u/.ssh/authorized_keys"
|
||||
fi
|
||||
done
|
||||
for k in $(debugfs -R "ls -p /etc/ssh" "$IMG" 2>/dev/null | awk -F/ '$3 !~ /^04/ && $6 ~ /^ssh_host_/ {{print $6}}'); do
|
||||
RM_CMDS="$RM_CMDS
|
||||
rm /etc/ssh/$k"
|
||||
done
|
||||
fi
|
||||
if [ "{sf_flag}" = "1" ]; then
|
||||
for fw in $(debugfs -R "ls -p /lib/firmware/mediatek/mt6797" "$IMG" 2>/dev/null | awk -F/ '$3 !~ /^04/ && $6 != "" && $6 != "." && $6 != ".." {{print $6}}'); do
|
||||
RM_CMDS="$RM_CMDS
|
||||
rm /lib/firmware/mediatek/mt6797/$fw"
|
||||
done
|
||||
fi
|
||||
if [ -n "$RM_CMDS" ]; then
|
||||
printf '%s\n' "$RM_CMDS" | debugfs -w "$IMG" >/dev/null
|
||||
fi
|
||||
e2fsck -fn "$IMG" >/dev/null
|
||||
"""
|
||||
fw_mod._run_docker_e2fs(img_dir, [], docker_sh)
|
||||
return ["(sanitized via docker e2fsprogs)"]
|
||||
|
||||
|
||||
def render_flash_instructions(version, codename, build_date, top_dir, include_firmware=False):
|
||||
"""Generate plain-text FLASH-INSTRUCTIONS.txt shipped inside the release ZIP."""
|
||||
fw_mode = (
|
||||
"INCLUDED (for personal single-device backup images)"
|
||||
if include_firmware else
|
||||
"CLEAN / STRIPPED (auto-extracted from your PDA during flashing)"
|
||||
)
|
||||
return f"""========================================================================
|
||||
Geminux Linux for Planet Computers Gemini PDA (x27 Wi-Fi + 4G)
|
||||
Release: {version} ({codename}) Built: {build_date}
|
||||
Firmware: {fw_mode}
|
||||
========================================================================
|
||||
|
||||
Archive Directory : {top_dir}/
|
||||
|
||||
1. ARCHIVE CONTENTS
|
||||
-------------------
|
||||
FLASH-INSTRUCTIONS.txt This guide
|
||||
SHA256SUMS.txt SHA-256 checksums for all disk images
|
||||
flash-mtk.sh / flash-mtk.py Pure-Linux MediaTek BROM/DA flasher
|
||||
images/boot-geminux.img Linux 7.3.5-geminux kernel + DTB + initramfs
|
||||
images/recovery-geminux.img USB NCM recovery shell image (172.16.42.1/24)
|
||||
images/geminux-rootfs.img Alpine Edge aarch64 desktop ext4 rootfs
|
||||
scripts/ Account, GPT, LUKS2, firmware & pip helpers
|
||||
vendor/mtkclient/ Vendored GPLv3 mtkclient + MT6797 DA binary
|
||||
|
||||
2. LINUX HOST PREREQUISITES
|
||||
---------------------------
|
||||
Docker is NOT required to flash this release archive.
|
||||
|
||||
Required on the Linux PC:
|
||||
- python3, python3-pip, libusb-1.0, and sudo (raw USB BROM/DA access)
|
||||
- e2fsprogs (debugfs, e2fsck) for account & firmware rootfs staging
|
||||
|
||||
Optional:
|
||||
- cryptsetup Needed only if you choose --encrypt (LUKS2 disk encryption)
|
||||
- simg2img Needed only if extracting firmware from a sparse stock
|
||||
Android system.img (--extract-firmware --system-img)
|
||||
|
||||
Note: On first run, ./flash-mtk.sh automatically installs its Python USB
|
||||
helpers (pyusb, pyserial, pycryptodome, colorama) locally into .flash-deps/
|
||||
and temporarily pauses host ModemManager so /dev/ttyACM* is not interrupted.
|
||||
|
||||
3. SAFETY & HARDWARE PREPARATION
|
||||
--------------------------------
|
||||
* Protected partitions (preloader, nvram, proinfo, lk, tee1, md1img, etc.
|
||||
in LBA 0..0x6FFFF) hold device calibration and baseband data. Geminux
|
||||
backs them up first and write-blocks them during normal flashing.
|
||||
* ALWAYS use the LEFT USB-C port on the Gemini PDA (closest to Esc),
|
||||
connected directly to the PC (avoid unpowered USB hubs).
|
||||
* Geminux claims all user-writable eMMC after 0x0E000000 (replacing Android
|
||||
system, cache, and userdata with boot, recovery, boot2, and ~58 GiB linux).
|
||||
|
||||
4. FLASHING STEPS
|
||||
-----------------
|
||||
Extract this ZIP and change into {top_dir}/:
|
||||
|
||||
unzip {top_dir}.zip
|
||||
cd {top_dir}
|
||||
|
||||
Step A - Verify image checksums:
|
||||
|
||||
sha256sum -c SHA256SUMS.txt
|
||||
|
||||
Step B - Optional: backup factory partitions only (without modifying eMMC):
|
||||
|
||||
# Keep Gemini powered off and unplugged, start the command, then plug into
|
||||
# the LEFT USB-C port:
|
||||
./flash-mtk.sh --only-backup
|
||||
|
||||
Step C - Full Geminux installation:
|
||||
|
||||
# Interactive (prompts for username, passwords, and optional LUKS2 before
|
||||
# waiting for USB; automatically backs up factory partitions, extracts MT6797
|
||||
# Wi-Fi/BT/SPM blobs from stock Android 'system', injects them into the
|
||||
# staged rootfs, repartitions eMMC, verifies readbacks, and reboots):
|
||||
./flash-mtk.sh --flash-full
|
||||
|
||||
# Example with explicit username, prompted passwords, and LUKS2 encryption:
|
||||
./flash-mtk.sh --flash-full --username alice --ask-user-password \\
|
||||
--ask-root-password --encrypt
|
||||
|
||||
# Non-interactive with image defaults (unencrypted, user / geminux):
|
||||
./flash-mtk.sh --flash-full --use-default-credentials
|
||||
|
||||
# Already flashed Linux previously (no stock Android system partition left)?
|
||||
# Extract blobs once from your stock Android system.img beforehand:
|
||||
./flash-mtk.sh --extract-firmware --system-img /path/to/stock-system.img
|
||||
./flash-mtk.sh --flash-full
|
||||
|
||||
5. OTHER FLASHER COMMANDS
|
||||
-------------------------
|
||||
# Re-flash kernel + recovery slots only (preserves GPT and linux rootfs):
|
||||
./flash-mtk.sh --flash-kernel-only
|
||||
|
||||
# Update only the linux rootfs partition:
|
||||
./flash-mtk.sh --flash-rootfs-only --username alice --ask-user-password
|
||||
|
||||
# Restore an earlier MediaTek partition backup (keep backup/ safe!):
|
||||
./flash-mtk.sh --restore-backup backup/<timestamp>
|
||||
|
||||
6. FIRST BOOT & QUICK REFERENCE
|
||||
-------------------------------
|
||||
* After flashing finishes, unplug USB-C if needed and hold Esc to boot.
|
||||
* If booted on USB power, charging pauses briefly (~15 s) while VSYS stays
|
||||
powered so the fuel gauge reads true open-circuit battery voltage.
|
||||
* With --encrypt, unlock at the console prompt using the Gemini keyboard.
|
||||
* First boot automatically expands ext4 across the ~58 GiB linux partition.
|
||||
* Default login (unless customized): user / geminux (default theme: Anodized,
|
||||
default wallpaper: /usr/share/geminux/wallpapers/geminux-dark.png).
|
||||
* Rescue SSH: plug USB-C into a Linux host -> USB NCM usb0 at 172.16.42.1.
|
||||
|
||||
Essential shortcuts (Fn+Alt = Mod4):
|
||||
Mod4 + Space App launcher Mod4 + t Themes & Wallpaper
|
||||
Mod4 + Return st terminal Mod4 + n Network, eSIM & DNS
|
||||
Mod4 + c Control Center Fn + F Airplane Mode
|
||||
Mod4 + Shift + l Lock screen Mod4 + Shift+c Close window
|
||||
|
||||
7. TROUBLESHOOTING
|
||||
------------------
|
||||
* Device boots Android/screen instead of flashing: Unplug USB-C, power off
|
||||
completely, run ./flash-mtk.sh first, then plug into the LEFT USB-C port.
|
||||
* Device hung before connecting: Hold Esc + side Power for ~12 s while plugged
|
||||
into the LEFT USB-C port to force hardware reset into BROM/Preloader.
|
||||
* Missing debugfs/e2fsck or cryptsetup: Install e2fsprogs (and cryptsetup
|
||||
if using --encrypt) from your Linux distribution's package manager.
|
||||
"""
|
||||
|
||||
|
||||
def _write_zip_entry(zf, src_path, arcname, is_exec, compress_level):
|
||||
st = os.stat(src_path)
|
||||
dt = time.localtime(st.st_mtime)[:6]
|
||||
if dt[0] < 1980:
|
||||
dt = (1980, 1, 1, 0, 0, 0)
|
||||
zinfo = zipfile.ZipInfo(arcname, date_time=dt)
|
||||
zinfo.compress_type = zipfile.ZIP_STORED if compress_level == 0 else zipfile.ZIP_DEFLATED
|
||||
zinfo.create_system = 3
|
||||
mode = stat.S_IFREG | (0o755 if is_exec else 0o644)
|
||||
zinfo.external_attr = (mode & 0xFFFF) << 16
|
||||
zinfo.file_size = st.st_size
|
||||
force64 = st.st_size >= 0xF0000000
|
||||
with open(src_path, "rb") as sf, zf.open(zinfo, "w", force_zip64=force64) as df:
|
||||
shutil.copyfileobj(sf, df, length=4 * 1024 * 1024)
|
||||
|
||||
|
||||
def _write_zip_bytes(zf, raw_bytes, arcname, is_exec, compress_level):
|
||||
dt = time.gmtime()[:6]
|
||||
zinfo = zipfile.ZipInfo(arcname, date_time=dt)
|
||||
zinfo.compress_type = zipfile.ZIP_STORED if compress_level == 0 else zipfile.ZIP_DEFLATED
|
||||
zinfo.create_system = 3
|
||||
mode = stat.S_IFREG | (0o755 if is_exec else 0o644)
|
||||
zinfo.external_attr = (mode & 0xFFFF) << 16
|
||||
zinfo.file_size = len(raw_bytes)
|
||||
with zf.open(zinfo, "w") as df:
|
||||
df.write(raw_bytes)
|
||||
|
||||
|
||||
def _collect_vendor_entries():
|
||||
vendor_root = os.path.join(BASE_DIR, "vendor", "mtkclient")
|
||||
if not os.path.isdir(vendor_root):
|
||||
raise FileNotFoundError(f"Missing vendored mtkclient directory: {vendor_root}")
|
||||
entries = []
|
||||
for root, dirs, files in os.walk(vendor_root):
|
||||
dirs[:] = sorted(d for d in dirs if d not in SKIP_VENDOR_DIRS)
|
||||
for fn in sorted(files):
|
||||
if fn in SKIP_VENDOR_FILES or fn.endswith(SKIP_VENDOR_SUFFIXES):
|
||||
continue
|
||||
src = os.path.join(root, fn)
|
||||
if not os.path.isfile(src) or os.path.islink(src):
|
||||
continue
|
||||
rel = os.path.relpath(src, BASE_DIR).replace(os.sep, "/")
|
||||
is_exec = bool(os.stat(src).st_mode & 0o111)
|
||||
entries.append((src, rel, is_exec))
|
||||
return entries
|
||||
|
||||
|
||||
def package_release_zip(
|
||||
images_dir,
|
||||
output_zip=None,
|
||||
version=None,
|
||||
codename=None,
|
||||
include_firmware=False,
|
||||
keep_ssh_keys=False,
|
||||
compress_level=6,
|
||||
verify=True,
|
||||
):
|
||||
"""Create a redistributable Geminux release ZIP archive with TXT flashing guide."""
|
||||
ver = version or _query_version_field("--print", "0.1.0")
|
||||
cname = codename or _query_version_field("--print-codename", "helio")
|
||||
top_dir = f"geminux-{ver}-{cname}-gemini-x27"
|
||||
if not output_zip:
|
||||
output_zip = os.path.join(BASE_DIR, "releases", f"{top_dir}.zip")
|
||||
|
||||
abs_images = os.path.abspath(images_dir)
|
||||
abs_out = os.path.abspath(output_zip)
|
||||
out_dir = os.path.dirname(abs_out) or "."
|
||||
os.makedirs(out_dir, exist_ok=True)
|
||||
|
||||
boot_img = os.path.join(abs_images, "boot-geminux.img")
|
||||
rec_img = os.path.join(abs_images, "recovery-geminux.img")
|
||||
root_img = os.path.join(abs_images, "geminux-rootfs.img")
|
||||
for req in (boot_img, rec_img, root_img):
|
||||
if not os.path.isfile(req):
|
||||
raise FileNotFoundError(f"Required build artifact not found: {req}")
|
||||
|
||||
for top_tool in ("flash-mtk.sh", "flash-mtk.py"):
|
||||
if not os.path.isfile(os.path.join(BASE_DIR, top_tool)):
|
||||
raise FileNotFoundError(f"Missing flasher file: {top_tool}")
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=out_dir, prefix=".geminux-pkg-") as tmp:
|
||||
staged_root = os.path.join(tmp, "geminux-rootfs.img")
|
||||
print(f"[*] Staging rootfs image for release packaging ({root_img})...")
|
||||
copy_sparse_raw_image(root_img, staged_root)
|
||||
removed = sanitize_ext4_for_release(
|
||||
staged_root,
|
||||
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)."
|
||||
)
|
||||
|
||||
sums_lines = [
|
||||
f"{sha256_file(boot_img)} images/boot-geminux.img",
|
||||
f"{sha256_file(staged_root)} images/geminux-rootfs.img",
|
||||
f"{sha256_file(rec_img)} images/recovery-geminux.img",
|
||||
]
|
||||
sums_bytes = ("\n".join(sums_lines) + "\n").encode("utf-8")
|
||||
|
||||
build_date = datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d %H:%M UTC")
|
||||
guide_text = render_flash_instructions(
|
||||
ver, cname, build_date, top_dir, include_firmware=include_firmware
|
||||
).encode("utf-8")
|
||||
|
||||
tmp_zip = abs_out + ".tmp"
|
||||
if os.path.exists(tmp_zip):
|
||||
os.unlink(tmp_zip)
|
||||
|
||||
print(f"[*] Writing ZIP archive -> {abs_out} (deflate level {compress_level})...")
|
||||
try:
|
||||
with zipfile.ZipFile(
|
||||
tmp_zip,
|
||||
"w",
|
||||
compression=zipfile.ZIP_STORED if compress_level == 0 else zipfile.ZIP_DEFLATED,
|
||||
compresslevel=compress_level,
|
||||
allowZip64=True,
|
||||
) as zf:
|
||||
_write_zip_bytes(zf, guide_text, f"{top_dir}/FLASH-INSTRUCTIONS.txt", False, compress_level)
|
||||
_write_zip_bytes(zf, sums_bytes, f"{top_dir}/SHA256SUMS.txt", False, compress_level)
|
||||
|
||||
_write_zip_entry(zf, os.path.join(BASE_DIR, "flash-mtk.sh"), f"{top_dir}/flash-mtk.sh", True, compress_level)
|
||||
_write_zip_entry(zf, os.path.join(BASE_DIR, "flash-mtk.py"), f"{top_dir}/flash-mtk.py", True, compress_level)
|
||||
|
||||
for rel_script, is_exec in FLASH_SCRIPTS:
|
||||
src_s = os.path.join(BASE_DIR, rel_script)
|
||||
if not os.path.isfile(src_s):
|
||||
raise FileNotFoundError(f"Missing flasher helper script: {src_s}")
|
||||
_write_zip_entry(zf, src_s, f"{top_dir}/{rel_script}", is_exec, compress_level)
|
||||
|
||||
for src_v, rel_v, is_exec in _collect_vendor_entries():
|
||||
_write_zip_entry(zf, src_v, f"{top_dir}/{rel_v}", is_exec, compress_level)
|
||||
|
||||
_write_zip_entry(zf, boot_img, f"{top_dir}/images/boot-geminux.img", False, compress_level)
|
||||
_write_zip_entry(zf, rec_img, f"{top_dir}/images/recovery-geminux.img", False, compress_level)
|
||||
_write_zip_entry(zf, staged_root, f"{top_dir}/images/geminux-rootfs.img", False, compress_level)
|
||||
|
||||
if verify:
|
||||
print("[*] Verifying ZIP CRC32 integrity...")
|
||||
with zipfile.ZipFile(tmp_zip, "r") as zf:
|
||||
bad = zf.testzip()
|
||||
if bad is not None:
|
||||
raise RuntimeError(f"ZIP integrity verification failed at member: {bad}")
|
||||
|
||||
os.replace(tmp_zip, abs_out)
|
||||
finally:
|
||||
if os.path.exists(tmp_zip):
|
||||
try:
|
||||
os.unlink(tmp_zip)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
zip_sha = sha256_file(abs_out)
|
||||
sha_path = abs_out + ".sha256"
|
||||
with open(sha_path, "w", encoding="utf-8") as sf:
|
||||
sf.write(f"{zip_sha} {os.path.basename(abs_out)}\n")
|
||||
|
||||
zip_mb = os.path.getsize(abs_out) / (1024.0 * 1024.0)
|
||||
print(f"[+] Packaged release ZIP: {abs_out} ({zip_mb:.1f} MiB)")
|
||||
print(f"[+] ZIP SHA-256: {zip_sha} ({sha_path})")
|
||||
return abs_out, sha_path
|
||||
|
||||
|
||||
def build_arg_parser():
|
||||
p = argparse.ArgumentParser(
|
||||
description="Package Geminux images, pure-Linux MTK flasher, and TXT guide into a ZIP release."
|
||||
)
|
||||
p.add_argument("-o", "--output", help="Output ZIP file path (default: releases/geminux-<ver>-<codename>-gemini-x27.zip)")
|
||||
p.add_argument("--images-dir", default=os.path.join(BASE_DIR, "images"),
|
||||
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("--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",
|
||||
help="ZIP deflate compression level (default: 6)")
|
||||
p.add_argument("--no-verify", action="store_true", help="Skip ZIP CRC verification pass")
|
||||
return p
|
||||
|
||||
|
||||
def main():
|
||||
args = build_arg_parser().parse_args()
|
||||
package_release_zip(
|
||||
images_dir=args.images_dir,
|
||||
output_zip=args.output,
|
||||
version=args.version,
|
||||
codename=args.codename,
|
||||
include_firmware=args.include_firmware,
|
||||
keep_ssh_keys=args.keep_ssh_keys,
|
||||
compress_level=args.compress_level,
|
||||
verify=not args.no_verify,
|
||||
)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -731,6 +731,210 @@ def test_luks2_encryption_offline():
|
||||
print("[PASS] Offline LUKS2 encryption, PTY passphrase unlock, and XTS-256 ext4 decryption verified")
|
||||
|
||||
|
||||
def test_firmware_injection_ext4():
|
||||
if not all(shutil.which(cmd) for cmd in ("mke2fs", "debugfs", "e2fsck")):
|
||||
print("[SKIP] mke2fs/debugfs/e2fsck not available for firmware injection test")
|
||||
return
|
||||
|
||||
fw_mod = flash_mtk.load_firmware_module()
|
||||
with tempfile.TemporaryDirectory(prefix="geminux-fwinj-test-") as tmp:
|
||||
sysroot = os.path.join(tmp, "sysroot")
|
||||
os.makedirs(os.path.join(sysroot, "etc"), exist_ok=True)
|
||||
os.makedirs(os.path.join(sysroot, "home", "user"), exist_ok=True)
|
||||
with open(os.path.join(sysroot, "etc", "passwd"), "w", encoding="utf-8") as f:
|
||||
f.write("root:x:0:0:root:/root:/bin/bash\nuser:x:10000:10000::/home/user:/bin/bash\n")
|
||||
with open(os.path.join(sysroot, "etc", "group"), "w", encoding="utf-8") as f:
|
||||
f.write("root:x:0:root\nuser:x:10000:\n")
|
||||
with open(os.path.join(sysroot, "etc", "shadow"), "w", encoding="utf-8") as f:
|
||||
f.write("root:*:::::::\nuser:*:::::::\n")
|
||||
|
||||
fw_dir = os.path.join(tmp, "fw")
|
||||
os.makedirs(fw_dir, exist_ok=True)
|
||||
expected_blobs = {
|
||||
"WIFI_RAM_CODE_6797": b"WIFI_FW_HDR" * 100,
|
||||
"WMT_SOC.cfg": b"cfg=1\n",
|
||||
"ROMv3_patch_1_0_hdr.bin": b"ROM10",
|
||||
"pcm_suspend.bin": b"PCM_SUSPEND",
|
||||
}
|
||||
for name, data in expected_blobs.items():
|
||||
with open(os.path.join(fw_dir, name), "wb") as bf:
|
||||
bf.write(data)
|
||||
with open(os.path.join(fw_dir, "ignored.txt"), "w", encoding="utf-8") as uf:
|
||||
uf.write("ignore-me\n")
|
||||
|
||||
img_dir = os.path.join(tmp, "images")
|
||||
os.makedirs(img_dir, exist_ok=True)
|
||||
orig_img = os.path.join(img_dir, "geminux-rootfs.img")
|
||||
out_img = os.path.join(tmp, "out-rootfs.img")
|
||||
subprocess.run(
|
||||
["mke2fs", "-t", "ext4", "-F", "-q", "-d", sysroot, orig_img, "8M"],
|
||||
check=True,
|
||||
)
|
||||
orig_sha = flash_mtk.sha256_file(orig_img)
|
||||
|
||||
res = subprocess.run(
|
||||
[
|
||||
os.path.join(BASE_DIR, "flash-mtk.sh"),
|
||||
"--customize-rootfs", out_img,
|
||||
"--images-dir", img_dir,
|
||||
"--firmware-dir", fw_dir,
|
||||
"--use-default-credentials",
|
||||
],
|
||||
capture_output=True, text=True, check=False,
|
||||
)
|
||||
assert res.returncode == 0, f"customize-rootfs fw inject failed: {res.stdout}\n{res.stderr}"
|
||||
assert flash_mtk.sha256_file(orig_img) == orig_sha, "Source rootfs image was mutated!"
|
||||
|
||||
e2 = subprocess.run(["e2fsck", "-fn", out_img], capture_output=True, text=True)
|
||||
assert e2.returncode == 0, f"e2fsck failed after fw inject: {e2.stdout}\n{e2.stderr}"
|
||||
|
||||
ls_entries = fw_mod.debugfs_ls(out_img, "lib/firmware/mediatek/mt6797")
|
||||
assert set(ls_entries) == set(expected_blobs.keys()), ls_entries
|
||||
for name, expected in expected_blobs.items():
|
||||
dump_p = os.path.join(tmp, f"dump-{name}")
|
||||
assert fw_mod.debugfs_dump(out_img, f"lib/firmware/mediatek/mt6797/{name}", dump_p)
|
||||
with open(dump_p, "rb") as df:
|
||||
assert df.read() == expected
|
||||
st = subprocess.run(
|
||||
["debugfs", "-R", f"stat /lib/firmware/mediatek/mt6797/{name}", out_img],
|
||||
capture_output=True, text=True, check=True,
|
||||
)
|
||||
assert re.search(r"Mode:\s*0644\b", st.stdout), st.stdout
|
||||
|
||||
# Verify --skip-firmware-inject skips injection
|
||||
out_skip = os.path.join(tmp, "out-skip.img")
|
||||
res_skip = subprocess.run(
|
||||
[
|
||||
os.path.join(BASE_DIR, "flash-mtk.sh"),
|
||||
"--customize-rootfs", out_skip,
|
||||
"--images-dir", img_dir,
|
||||
"--firmware-dir", fw_dir,
|
||||
"--skip-firmware-inject",
|
||||
"--use-default-credentials",
|
||||
],
|
||||
capture_output=True, text=True, check=False,
|
||||
)
|
||||
assert res_skip.returncode == 0, res_skip.stderr
|
||||
assert fw_mod.debugfs_ls(out_skip, "lib/firmware/mediatek/mt6797") == []
|
||||
print("[PASS] Offline MT6797 firmware ext4 injection verified")
|
||||
|
||||
|
||||
def test_release_zip_packager():
|
||||
import zipfile
|
||||
|
||||
if not all(shutil.which(cmd) for cmd in ("mke2fs", "debugfs", "e2fsck")):
|
||||
print("[SKIP] mke2fs/debugfs/e2fsck not available for release ZIP packager test")
|
||||
return
|
||||
|
||||
pkg_mod = _load_mod(
|
||||
"package_release_zip", os.path.join(SCRIPTS_DIR, "package-release-zip.py")
|
||||
)
|
||||
with tempfile.TemporaryDirectory(prefix="geminux-zip-test-") as tmp:
|
||||
sysroot = os.path.join(tmp, "sysroot")
|
||||
os.makedirs(os.path.join(sysroot, "etc", "ssh"), exist_ok=True)
|
||||
os.makedirs(os.path.join(sysroot, "root", ".ssh"), exist_ok=True)
|
||||
os.makedirs(os.path.join(sysroot, "home", "user", ".ssh"), exist_ok=True)
|
||||
os.makedirs(os.path.join(sysroot, "lib", "firmware", "mediatek", "mt6797"), exist_ok=True)
|
||||
|
||||
with open(os.path.join(sysroot, "etc", "passwd"), "w", encoding="utf-8") as f:
|
||||
f.write("root:x:0:0:root:/root:/bin/bash\nuser:x:10000:10000::/home/user:/bin/bash\n")
|
||||
with open(os.path.join(sysroot, "etc", "ssh", "sshd_config"), "w", encoding="utf-8") as f:
|
||||
f.write("Port 22\n")
|
||||
with open(os.path.join(sysroot, "etc", "ssh", "ssh_host_ed25519_key"), "w", encoding="utf-8") as f:
|
||||
f.write("PRIVATE HOST KEY\n")
|
||||
with open(os.path.join(sysroot, "etc", "ssh", "ssh_host_ed25519_key.pub"), "w", encoding="utf-8") as f:
|
||||
f.write("ssh-ed25519 AAAAC3...\n")
|
||||
with open(os.path.join(sysroot, "root", ".ssh", "authorized_keys"), "w", encoding="utf-8") as f:
|
||||
f.write("ssh-ed25519 AAAA_USER_KEY\n")
|
||||
with open(os.path.join(sysroot, "home", "user", ".ssh", "authorized_keys"), "w", encoding="utf-8") as f:
|
||||
f.write("ssh-ed25519 AAAA_USER_KEY\n")
|
||||
with open(os.path.join(sysroot, "lib", "firmware", "mediatek", "mt6797", "WIFI_RAM_CODE_6797"), "wb") as f:
|
||||
f.write(b"PROPRIETARY_WIFI_BLOB")
|
||||
with open(os.path.join(sysroot, "lib", "firmware", "mediatek", "mt6797", "MANIFEST.sha256"), "w", encoding="utf-8") as f:
|
||||
f.write("abc WIFI_RAM_CODE_6797\n")
|
||||
|
||||
img_dir = os.path.join(tmp, "images")
|
||||
os.makedirs(img_dir, exist_ok=True)
|
||||
with open(os.path.join(img_dir, "boot-geminux.img"), "wb") as f:
|
||||
f.write(b"ANDROID!" + b"\x00" * 4088)
|
||||
with open(os.path.join(img_dir, "recovery-geminux.img"), "wb") as f:
|
||||
f.write(b"ANDROID!" + b"\x11" * 4088)
|
||||
root_img = os.path.join(img_dir, "geminux-rootfs.img")
|
||||
subprocess.run(
|
||||
["mke2fs", "-t", "ext4", "-F", "-q", "-d", sysroot, root_img, "8M"],
|
||||
check=True,
|
||||
)
|
||||
orig_root_sha = flash_mtk.sha256_file(root_img)
|
||||
|
||||
out_zip = os.path.join(tmp, "geminux-0.1.0-helio-gemini-x27.zip")
|
||||
res = subprocess.run(
|
||||
[
|
||||
os.path.join(BASE_DIR, "package-image.sh"),
|
||||
"--images-dir", img_dir,
|
||||
"--output", out_zip,
|
||||
"--version", "0.1.0",
|
||||
"--codename", "helio",
|
||||
],
|
||||
capture_output=True, text=True, check=False,
|
||||
)
|
||||
assert res.returncode == 0, f"package-image.sh failed:\n{res.stdout}\n{res.stderr}"
|
||||
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")
|
||||
|
||||
top = "geminux-0.1.0-helio-gemini-x27"
|
||||
with zipfile.ZipFile(out_zip, "r") as zf:
|
||||
assert zf.testzip() is None
|
||||
names = set(zf.namelist())
|
||||
for req in (
|
||||
f"{top}/FLASH-INSTRUCTIONS.txt",
|
||||
f"{top}/SHA256SUMS.txt",
|
||||
f"{top}/flash-mtk.sh",
|
||||
f"{top}/flash-mtk.py",
|
||||
f"{top}/images/boot-geminux.img",
|
||||
f"{top}/images/recovery-geminux.img",
|
||||
f"{top}/images/geminux-rootfs.img",
|
||||
f"{top}/scripts/bootstrap-flash-deps.sh",
|
||||
f"{top}/scripts/extract-vendor-fw.py",
|
||||
f"{top}/scripts/geminux_accounts.py",
|
||||
f"{top}/scripts/geminux_gpt.py",
|
||||
f"{top}/scripts/geminux_luks.py",
|
||||
f"{top}/vendor/mtkclient/mtkclient/Loader/MTK_DA_V5_MT6797.bin",
|
||||
):
|
||||
assert req in names, f"ZIP missing {req}"
|
||||
assert not any("__pycache__" in n or n.endswith((".pyc", ".pyo")) for n in names), "Found bytecode in ZIP"
|
||||
sh_info = zf.getinfo(f"{top}/flash-mtk.sh")
|
||||
assert ((sh_info.external_attr >> 16) & 0o111) == 0o111, "flash-mtk.sh missing +x attr"
|
||||
txt = zf.read(f"{top}/FLASH-INSTRUCTIONS.txt").decode("utf-8")
|
||||
for needle in ("./flash-mtk.sh --flash-full", "sha256sum -c SHA256SUMS.txt", "LEFT USB-C port", "Docker is NOT required"):
|
||||
assert needle in txt, f"FLASH-INSTRUCTIONS.txt missing {needle!r}"
|
||||
|
||||
# Extract with unzip to verify preserved executable bits, SHA256SUMS, and flasher launch
|
||||
ext_dir = os.path.join(tmp, "extracted")
|
||||
os.makedirs(ext_dir, exist_ok=True)
|
||||
subprocess.run(["unzip", "-q", out_zip, "-d", ext_dir], check=True)
|
||||
rel_dir = os.path.join(ext_dir, top)
|
||||
subprocess.run(["sha256sum", "-c", "SHA256SUMS.txt"], cwd=rel_dir, check=True, stdout=subprocess.DEVNULL)
|
||||
|
||||
ext_env = dict(os.environ)
|
||||
if os.path.isdir(FLASH_DEPS):
|
||||
ext_env["PYTHONPATH"] = FLASH_DEPS
|
||||
hres = subprocess.run(
|
||||
["./flash-mtk.sh", "--help"],
|
||||
cwd=rel_dir, env=ext_env, capture_output=True, text=True, check=False,
|
||||
)
|
||||
assert hres.returncode == 0, f"Extracted flash-mtk.sh --help failed:\n{hres.stdout}\n{hres.stderr}"
|
||||
|
||||
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") == []
|
||||
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")
|
||||
print("[PASS] Release ZIP packager (sanitized rootfs, FLASH-INSTRUCTIONS.txt, SHA256SUMS, runnable flasher) verified")
|
||||
|
||||
|
||||
def test_cli_help():
|
||||
res = subprocess.run(
|
||||
[os.path.join(BASE_DIR, "flash-mtk.sh"), "--help"],
|
||||
@@ -744,6 +948,7 @@ def test_cli_help():
|
||||
"--flash-full",
|
||||
"--flash-rootfs-only",
|
||||
"--customize-rootfs",
|
||||
"--skip-firmware-inject",
|
||||
"--username",
|
||||
"--user-password",
|
||||
"--ask-user-password",
|
||||
@@ -773,6 +978,8 @@ def main():
|
||||
test_sha512_crypt_and_username_validation()
|
||||
test_account_customization_ext4()
|
||||
test_luks2_encryption_offline()
|
||||
test_firmware_injection_ext4()
|
||||
test_release_zip_packager()
|
||||
test_cli_help()
|
||||
|
||||
|
||||
|
||||
@@ -723,6 +723,40 @@ def main():
|
||||
if '"/sys/power/state", "freeze"' in trig_src:
|
||||
raise AssertionError("trigger_suspend must not fall back to s2idle freeze")
|
||||
|
||||
powerd_path = os.path.join(
|
||||
os.path.dirname(APPS_DIR), "geminux-daemons", "geminux-powerd.c"
|
||||
)
|
||||
with open(powerd_path, "r", encoding="utf-8") as handle:
|
||||
powerd_dpms_src = handle.read()
|
||||
for needle in (
|
||||
"wake_x11_display_dpms",
|
||||
"DPMSForceLevel",
|
||||
"DPMSModeOn",
|
||||
"XResetScreenSaver",
|
||||
"poll(&pf, 1, 1800)",
|
||||
):
|
||||
if needle not in powerd_dpms_src:
|
||||
raise AssertionError(f"geminux-powerd.c missing expected DPMS/lock sync token: {needle}")
|
||||
tb_start = powerd_dpms_src.find("static void toggle_backlight")
|
||||
tb_end = powerd_dpms_src.find("\nstatic ", tb_start + 1)
|
||||
tb_src = powerd_dpms_src[tb_start:tb_end]
|
||||
if "wake_x11_display_dpms()" not in tb_src:
|
||||
raise AssertionError("toggle_backlight must invoke wake_x11_display_dpms() when waking display")
|
||||
|
||||
lock_path = os.path.join(APPS_DIR, "geminux-lock.c")
|
||||
with open(lock_path, "r", encoding="utf-8") as handle:
|
||||
lock_src = handle.read()
|
||||
for needle in ("publish_lock_ready", "_GEMINUX_LOCK_READY", "XSync"):
|
||||
if needle not in lock_src:
|
||||
raise AssertionError(f"geminux-lock.c missing expected readiness token: {needle}")
|
||||
ot_start = lock_src.find("static void on_timer")
|
||||
ot_end = lock_src.find("\nstatic ", ot_start + 1)
|
||||
ot_src = lock_src[ot_start:ot_end]
|
||||
grab_idx = ot_src.find("gemui_grab_input")
|
||||
pub_idx = ot_src.find("publish_lock_ready")
|
||||
if grab_idx < 0 or pub_idx < 0 or grab_idx > pub_idx:
|
||||
raise AssertionError("geminux-lock.c on_timer must attempt gemui_grab_input before publish_lock_ready")
|
||||
|
||||
with open(os.path.join(APPS_DIR, "geminux-control.c"), "r", encoding="utf-8") as handle:
|
||||
ctrl_src = handle.read()
|
||||
if "st->bl_path" not in ctrl_src or "flush_vol_helper(" not in ctrl_src:
|
||||
|
||||
Reference in new issue
Block a user