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:
|
||||
|
||||
Reference in new issue
Block a user