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
+45
-9
@@ -266,13 +266,17 @@ def write_partition_checked(da_handler, part_name, img_path, verify=True, allow_
|
||||
verify_written_partition(da_handler, part_name, img_path)
|
||||
|
||||
|
||||
def load_extract_firmware():
|
||||
def load_firmware_module():
|
||||
import importlib.util
|
||||
fw_path = os.path.join(SCRIPTS_DIR, "extract-vendor-fw.py")
|
||||
sp = importlib.util.spec_from_file_location("extract_vendor_fw", fw_path)
|
||||
mod = importlib.util.module_from_spec(sp)
|
||||
sp.loader.exec_module(mod)
|
||||
return mod.extract_firmware
|
||||
return mod
|
||||
|
||||
|
||||
def load_extract_firmware():
|
||||
return load_firmware_module().extract_firmware
|
||||
|
||||
|
||||
def extract_fw_from_device(da_handler, fw_out_dir):
|
||||
@@ -399,16 +403,29 @@ def copy_raw_image(src, dst):
|
||||
shutil.copyfile(src, dst)
|
||||
|
||||
|
||||
def stage_rootfs_image(root_img, account_cfg, tmp_dir, always_copy=False, luks_cfg=None):
|
||||
"""Unsparse if needed and apply offline account/LUKS2 provisioning in tmp_dir."""
|
||||
def stage_rootfs_image(
|
||||
root_img,
|
||||
account_cfg,
|
||||
tmp_dir,
|
||||
always_copy=False,
|
||||
luks_cfg=None,
|
||||
firmware_dir=None,
|
||||
):
|
||||
"""Unsparse if needed and apply firmware/account/LUKS2 provisioning in tmp_dir."""
|
||||
if not os.path.isfile(root_img):
|
||||
raise FileNotFoundError(f"Rootfs image not found: {root_img}")
|
||||
with open(root_img, "rb") as rf:
|
||||
is_sparse = rf.read(4) == SPARSE_MAGIC
|
||||
|
||||
fw_mod = None
|
||||
has_firmware = False
|
||||
if firmware_dir and os.path.isdir(firmware_dir):
|
||||
fw_mod = load_firmware_module()
|
||||
has_firmware = bool(fw_mod.list_firmware_blobs(firmware_dir))
|
||||
|
||||
has_changes = bool(account_cfg and account_cfg.has_changes)
|
||||
has_luks = bool(luks_cfg and luks_cfg.enabled)
|
||||
if not is_sparse and not has_changes and not has_luks and not always_copy:
|
||||
if not is_sparse and not has_changes and not has_luks and not has_firmware and not always_copy:
|
||||
return root_img
|
||||
|
||||
staged = os.path.join(tmp_dir, "linux.raw.img")
|
||||
@@ -419,6 +436,13 @@ def stage_rootfs_image(root_img, account_cfg, tmp_dir, always_copy=False, luks_c
|
||||
else:
|
||||
copy_raw_image(root_img, staged)
|
||||
|
||||
if has_firmware:
|
||||
injected = fw_mod.inject_firmware_into_ext4(staged, firmware_dir)
|
||||
print(
|
||||
f"[+] Injected {len(injected)} MT6797 firmware blob(s) into staged rootfs "
|
||||
"(/lib/firmware/mediatek/mt6797)."
|
||||
)
|
||||
|
||||
if has_changes:
|
||||
customize_ext4_accounts(
|
||||
staged,
|
||||
@@ -450,9 +474,10 @@ def customize_rootfs_offline(args, account_cfg, luks_cfg=None):
|
||||
out_dir = os.path.dirname(out_img) or "."
|
||||
os.makedirs(out_dir, exist_ok=True)
|
||||
has_luks = bool(luks_cfg and luks_cfg.enabled)
|
||||
fw_dir = None if getattr(args, "skip_firmware_inject", False) else args.firmware_dir
|
||||
with tempfile.TemporaryDirectory(dir=out_dir, prefix=".geminux-cust-") as tmp:
|
||||
staged = stage_rootfs_image(
|
||||
root_img, account_cfg, tmp, always_copy=True, luks_cfg=luks_cfg
|
||||
root_img, account_cfg, tmp, always_copy=True, luks_cfg=luks_cfg, firmware_dir=fw_dir
|
||||
)
|
||||
if not has_luks and (not account_cfg or not account_cfg.has_changes) and shutil.which("e2fsck"):
|
||||
subprocess.run(["e2fsck", "-fn", staged], check=True, stdout=subprocess.DEVNULL)
|
||||
@@ -472,7 +497,10 @@ def flash_full(mtk, da_handler, args, account_cfg=None, luks_cfg=None):
|
||||
req_check = os.path.join(args.firmware_dir, "WIFI_RAM_CODE_6797")
|
||||
if not os.path.isfile(req_check):
|
||||
extract_fw_from_device(da_handler, args.firmware_dir)
|
||||
print("[*] Note: Rebuild rootfs image if extracted firmware was not yet bundled in images/geminux-rootfs.img.")
|
||||
if getattr(args, "skip_firmware_inject", False):
|
||||
print("[*] Note: Rebuild or flash without --skip-firmware-inject so extracted firmware is bundled.")
|
||||
else:
|
||||
print("[*] Extracted firmware will be injected into staged rootfs automatically before flashing.")
|
||||
|
||||
total_sectors = get_emmc_total_sectors(mtk)
|
||||
pgpt_raw = da_handler.da_rs(0, 2 + GPT_ARRAY_SECTORS, "", "user", display=False)
|
||||
@@ -526,8 +554,11 @@ def flash_full(mtk, da_handler, args, account_cfg=None, luks_cfg=None):
|
||||
write_partition_checked(da_handler, "recovery", rec_img, verify=True)
|
||||
write_partition_checked(da_handler, "boot2", boot_img, verify=True)
|
||||
|
||||
fw_dir = None if getattr(args, "skip_firmware_inject", False) else args.firmware_dir
|
||||
with tempfile.TemporaryDirectory(prefix="geminux-stage-") as tmp:
|
||||
staged_root = stage_rootfs_image(root_img, account_cfg, tmp, luks_cfg=luks_cfg)
|
||||
staged_root = stage_rootfs_image(
|
||||
root_img, account_cfg, tmp, luks_cfg=luks_cfg, firmware_dir=fw_dir
|
||||
)
|
||||
write_partition_checked(da_handler, "linux", staged_root, verify=False)
|
||||
|
||||
print("[+] Full Geminux installation complete!")
|
||||
@@ -535,8 +566,11 @@ def flash_full(mtk, da_handler, args, account_cfg=None, luks_cfg=None):
|
||||
|
||||
def flash_rootfs_only(da_handler, args, account_cfg=None, luks_cfg=None):
|
||||
root_img = os.path.join(args.images_dir, "geminux-rootfs.img")
|
||||
fw_dir = None if getattr(args, "skip_firmware_inject", False) else args.firmware_dir
|
||||
with tempfile.TemporaryDirectory(prefix="geminux-stage-") as tmp:
|
||||
staged_root = stage_rootfs_image(root_img, account_cfg, tmp, luks_cfg=luks_cfg)
|
||||
staged_root = stage_rootfs_image(
|
||||
root_img, account_cfg, tmp, luks_cfg=luks_cfg, firmware_dir=fw_dir
|
||||
)
|
||||
write_partition_checked(da_handler, "linux", staged_root, verify=False)
|
||||
print("[+] Geminux rootfs update complete!")
|
||||
|
||||
@@ -649,6 +683,8 @@ def build_arg_parser():
|
||||
p.add_argument("--preloader", help="Optional preloader binary path for DRAM init")
|
||||
p.add_argument("--skip-backup", action="store_true", help="Skip backup if already taken in --backup-dir")
|
||||
p.add_argument("--skip-firmware-extract", action="store_true", help="Skip automatic firmware extraction")
|
||||
p.add_argument("--skip-firmware-inject", action="store_true",
|
||||
help="Skip injecting blobs from --firmware-dir into the staged rootfs")
|
||||
p.add_argument("--force-gpt", action="store_true", help="Allow repartitioning unrecognized GPT layouts")
|
||||
p.add_argument("--no-reboot", action="store_true",
|
||||
help="Power off instead of auto-rebooting after flashing")
|
||||
|
||||
Reference in new issue
Block a user