Files
geminux/scripts/check-rebuild.sh
T

525 lines
23 KiB
Bash
Raw Normal View History

#!/bin/sh
# Comprehensive Geminux verification suite (repo policy, zero-Rust ELF scan,
# Alpine Edge upgrade simulation, aarch64 binaries, image integrity, unit tests).
set -eu
BASE_DIR="$(cd "$(dirname "$0")/.." && pwd)"
ROOTFS_DIR="${ROOTFS_DIR:-$BASE_DIR/rootfs}"
IMAGES_DIR="$BASE_DIR/images"
if [ ! -d "$ROOTFS_DIR/lib/apk/db" ]; then
echo "FAIL: rootfs not bootstrapped at $ROOTFS_DIR" >&2
exit 1
fi
echo "[1/8] Checking APK repositories (pure Alpine Edge + @geminux, zero postmarketOS)..."
grep -q '^@geminux /var/lib/geminux/apk-repo$' "$ROOTFS_DIR/etc/apk/repositories"
grep -q 'alpine/edge/main' "$ROOTFS_DIR/etc/apk/repositories"
grep -q 'alpine/edge/community' "$ROOTFS_DIR/etc/apk/repositories"
grep -q 'alpine/edge/testing' "$ROOTFS_DIR/etc/apk/repositories"
if grep -qi 'postmarketos' "$ROOTFS_DIR/etc/apk/repositories"; then
echo "FAIL: unexpected postmarketos repository in target rootfs" >&2
exit 1
fi
echo "OK"
echo "[2/8] Checking excluded Wayland/Rust/upstream packages..."
for bad_pkg in sway wayfire weston phosh cage xwayland grim slurp wofi \
librsvg libglycin rav1e rav1e-libs libdovi mesa-rusticl gdk-pixbuf adwaita-icon-theme imv-x11 \
gst-libav gst-plugins-bad libnotify \
deno py3-cryptography \
linux-edge linux-lts xorg-server xf86-input-libinput xf86-video-fbdev; do
if grep -Fxq "P:$bad_pkg" "$ROOTFS_DIR/lib/apk/db/installed"; then
echo "FAIL: forbidden package '$bad_pkg' is installed in rootfs" >&2
exit 1
fi
done
echo "OK (zero forbidden packages)"
echo "[3/8] Running full binary ELF Rust scan across $ROOTFS_DIR..."
python3 - "$ROOTFS_DIR" <<'PYEOF'
import os
import re
import subprocess
import sys
root = sys.argv[1]
raw_markers = re.compile(
rb"(core::panicking|rustc_version|libstd-[0-9a-f]{8}|librsvg|libglycin|rav1e|libdovi)"
)
sym_markers = re.compile(
r"(rust_eh_personality|rust_begin_unwind|_ZN4core9panicking|_ZN3std9panicking|libstd-[0-9a-f]{8}|librsvg|libglycin|rav1e|libdovi)"
)
elfs = []
hits = []
for parent, _, names in os.walk(root):
for name in names:
p = os.path.join(parent, name)
if os.path.islink(p) or not os.path.isfile(p):
continue
try:
with open(p, "rb") as f:
if f.read(4) != b"\x7fELF":
continue
f.seek(0)
data = f.read()
except OSError:
continue
elfs.append(p)
m = raw_markers.search(data)
if m:
hits.append((os.path.relpath(p, root), m.group(0).decode("ascii", "replace")))
if elfs:
batch_sz = 200
for i in range(0, len(elfs), batch_sz):
chunk = elfs[i:i + batch_sz]
proc = subprocess.run(
["readelf", "-d", "-Ws"] + chunk,
capture_output=True, text=True, check=False,
)
cur_file = chunk[0]
for line in proc.stdout.splitlines():
if line.startswith("File: "):
cur_file = line[6:].strip()
continue
sm = sym_markers.search(line)
if sm:
hits.append((os.path.relpath(cur_file, root), sm.group(1)))
print(f"Scanned {len(elfs)} ELF binaries/libraries in rootfs -> {len(hits)} Rust marker hit(s)")
if hits:
for path, marker in hits[:20]:
print(f"FAIL: Rust marker '{marker}' in {path}", file=sys.stderr)
sys.exit(1)
PYEOF
echo "[4/8] Simulating Alpine Edge live 'apk upgrade' with locked @geminux packages..."
ROOTFS_HOST="$(realpath "$ROOTFS_DIR")"
docker run --rm --network=host \
-v "$ROOTFS_HOST:/rootfs" \
alpine:3.24 sh -eu -c '
mkdir -p /var/lib/geminux
ln -sfn /rootfs/var/lib/geminux/apk-repo /var/lib/geminux/apk-repo
cp -f /rootfs/etc/apk/keys/*.rsa.pub /etc/apk/keys/ 2>/dev/null || true
apk --root /rootfs --arch aarch64 update
UPG_OUT="$(apk --root /rootfs --arch aarch64 upgrade --simulate 2>&1)"
printf "%s\n" "$UPG_OUT"
for pkg in geminux-kernel-modules geminux-xlibre geminux-suckless \
geminux-dunst geminux-ui geminux-bantam geminux-gsocket geminux-mpv \
geminux-gdk-pixbuf geminux-webarchy geminux-config; do
if ! grep -q "^${pkg}@geminux=" /rootfs/etc/apk/world; then
echo "FAIL: ${pkg} is not exact-version pinned to @geminux in world" >&2
exit 1
fi
if printf "%s\n" "$UPG_OUT" | grep -q -E "(Upgrading|Replacing|Deleting|Downgrading) ${pkg}\b"; then
echo "FAIL: ${pkg} would be modified by upstream upgrade" >&2
exit 1
fi
done
if printf "%s\n" "$UPG_OUT" | grep -q -E "(rust|cargo|librsvg|libglycin|gdk-pixbuf|rav1e|libdovi|deno|py3-cryptography|xorg-server|linux-edge)"; then
echo "FAIL: upgrade simulation tried to pull forbidden Rust or upstream override package" >&2
exit 1
fi
'
echo "OK"
echo "[5/8] Verifying overlay artifact sync..."
"$BASE_DIR/scripts/sync-prebuilt-overlay.sh" --check
echo "[6/8] Verifying aarch64 ELF architecture on all Geminux custom binaries..."
file \
"$BASE_DIR/prebuilt/xlibre/usr/bin/Xorg" \
"$BASE_DIR/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/libglamoregl.so" \
"$BASE_DIR/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/extensions/libglx.so" \
"$BASE_DIR/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/drivers/modesetting_drv.so" \
"$BASE_DIR/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/drivers/fbdev_drv.so" \
"$BASE_DIR/prebuilt/xlibre/usr/lib/xorg/modules/xlibre-25/input/libinput_drv.so" \
"$BASE_DIR/prebuilt/suckless/usr/bin/st" \
"$BASE_DIR/prebuilt/suckless/usr/bin/dwm" \
"$BASE_DIR/prebuilt/suckless/usr/bin/dmenu" \
"$BASE_DIR/prebuilt/suckless/usr/bin/stest" \
"$BASE_DIR/prebuilt/dunst/usr/bin/dunst" \
"$BASE_DIR/prebuilt/dunst/usr/bin/notify-send" \
"$BASE_DIR/prebuilt/geminux/usr/lib/libgemui.so" \
"$BASE_DIR/prebuilt/geminux/usr/bin/"* \
"$BASE_DIR/prebuilt/geminux/usr/sbin/"* \
"$BASE_DIR/prebuilt/bantam/usr/bin/bantam" \
"$BASE_DIR/prebuilt/gsocket/usr/local/bin/gs-netcat" \
"$BASE_DIR/prebuilt/gsocket/usr/local/bin/gsocket_dso.so.0" \
"$BASE_DIR/prebuilt/gsocket/usr/local/bin/gsocket_uchroot_dso.so.0" \
"$BASE_DIR/prebuilt/mpv/usr/bin/mpv" \
"$BASE_DIR/prebuilt/mpv/usr/bin/ffmpeg" \
"$BASE_DIR/prebuilt/mpv/usr/bin/ffprobe" \
"$BASE_DIR/prebuilt/mpv/usr/lib/geminux-mpv/"*.so.*.* \
"$BASE_DIR/prebuilt/mpv/usr/lib/gstreamer-1.0/libgstlibav.so" \
"$BASE_DIR/prebuilt/gdk-pixbuf/usr/bin/gdk-pixbuf-"* \
"$BASE_DIR/prebuilt/gdk-pixbuf/usr/lib/libgdk_pixbuf-2.0.so.0."* \
"$BASE_DIR/prebuilt/webarchy/usr/bin/webarchy" | \
awk '!/ARM aarch64/ { print "FAIL: not aarch64: " $0; bad=1 } END { exit bad }'
echo "OK (all aarch64 ELFs verified)"
echo "[7/8] Verifying partition budgets, ext4 image e2fsck, and SHA256SUMS..."
BOOT_SZ="$(stat -c %s "$IMAGES_DIR/boot-geminux.img")"
REC_SZ="$(stat -c %s "$IMAGES_DIR/recovery-geminux.img")"
DTB_SZ="$(stat -c %s "$BASE_DIR/prebuilt/kernel/boot/mt6797-gemini-pda-geminux.dtb")"
[ "$BOOT_SZ" -le 16777216 ] || { echo "FAIL: boot-geminux.img > 16 MiB ($BOOT_SZ)" >&2; exit 1; }
[ "$REC_SZ" -le 16777216 ] || { echo "FAIL: recovery-geminux.img > 16 MiB ($REC_SZ)" >&2; exit 1; }
[ "$DTB_SZ" -le 524288 ] || { echo "FAIL: DTB > 512 KiB ($DTB_SZ)" >&2; exit 1; }
python3 - "$IMAGES_DIR/boot-geminux.img" "$IMAGES_DIR/recovery-geminux.img" \
"$BASE_DIR/prebuilt/kernel/boot/config-7.3.5-geminux" "$ROOTFS_DIR" \
"$BASE_DIR/src/initramfs/init" "$BASE_DIR/src/initramfs/init-recovery" <<'PYEOF'
import gzip
import os
import re
import struct
import subprocess
import sys
def parse_newc_entries(cpio_bytes):
entries = {}
pos = 0
total = len(cpio_bytes)
while pos + 110 <= total:
hdr = cpio_bytes[pos:pos + 110]
if hdr[:6] not in (b"070701", b"070702"):
raise SystemExit(f"FAIL: invalid cpio newc magic at offset {pos}: {hdr[:6]!r}")
filesize = int(hdr[54:62], 16)
namesize = int(hdr[94:102], 16)
name_start = pos + 110
name_end = name_start + namesize
name = cpio_bytes[name_start:name_end].rstrip(b"\x00").decode("utf-8", "replace")
if name == "TRAILER!!!":
break
data_start = (name_end + 3) & ~3
rel = name[2:] if name.startswith("./") else name
entries[rel] = cpio_bytes[data_start:data_start + filesize]
pos = (data_start + filesize + 3) & ~3
return entries
GEMINI_HW_KEYCODES = (
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 40, 42,
44, 45, 46, 47, 48, 49, 50, 51, 52, 54, 56, 57,
103, 105, 106, 108, 125,
)
for init_script in sys.argv[5:7]:
subprocess.run(["sh", "-n", init_script], check=True)
with open(init_script, "r", encoding="utf-8") as f:
txt = f.read()
if "cryptsetup resize" in txt:
raise SystemExit(f"FAIL: redundant interactive 'cryptsetup resize' found in {init_script}")
for line in txt.splitlines():
if "loadkmap" in line and line.count("<") > 1:
raise SystemExit(f"FAIL: double stdin redirection on loadkmap in {init_script}: {line}")
if init_script == sys.argv[5]:
stripped = line.strip()
if stripped.startswith(("resize2fs ", "e2fsck -p ")) and "</dev/null" not in line:
raise SystemExit(f"FAIL: missing '</dev/null' stdin guard in {init_script}: {stripped}")
for path in sys.argv[1:3]:
with open(path, "rb") as f:
blob = f.read()
hdr = blob[:640]
if hdr[:8] != b"ANDROID!":
raise SystemExit(f"FAIL: invalid boot image magic in {path}")
kernel_size = struct.unpack("<I", hdr[8:12])[0]
kernel_addr = struct.unpack("<I", hdr[12:16])[0]
ramdisk_size = struct.unpack("<I", hdr[16:20])[0]
page_size = struct.unpack("<I", hdr[36:40])[0] or 2048
if kernel_addr != 0x40080000:
raise SystemExit(
f"FAIL: {path} kernel_addr={kernel_addr:#010x}, expected 0x40080000 for Gemini LK"
)
k_pages = (kernel_size + page_size - 1) // page_size
r_off = (1 + k_pages) * page_size
cpio_bytes = gzip.decompress(blob[r_off:r_off + ramdisk_size])
rd_entries = parse_newc_entries(cpio_bytes)
for req_rd in ("init", "sbin/cryptsetup", "etc/gemini-us.kmap", "bin/loadkmap"):
if req_rd not in rd_entries:
raise SystemExit(f"FAIL: {path} ramdisk missing '{req_rd}'")
rd_init_txt = rd_entries["init"].decode("utf-8", "replace")
if "cryptsetup resize" in rd_init_txt:
raise SystemExit(f"FAIL: {path} init still contains 'cryptsetup resize'")
kmap = rd_entries["etc/gemini-us.kmap"]
if len(kmap) < 7 + 256 + 256 or kmap[:7] != b"bkeymap" or kmap[7] != 1:
raise SystemExit(f"FAIL: {path} invalid bkeymap header in etc/gemini-us.kmap")
map0 = struct.unpack_from("<128H", kmap, 7 + 256)
holes = [kc for kc in GEMINI_HW_KEYCODES if map0[kc] == 0x0200]
if holes:
raise SystemExit(f"FAIL: {path} etc/gemini-us.kmap has unbound Gemini keycodes: {holes}")
for kc, exp, label in (
(28, 0x0201, "Return"),
(42, 0x0700, "LShift"),
(54, 0x0700, "RShift"),
(57, 0x0020, "Space"),
(1, 0x001B, "Escape"),
(125, 0x0701, "AltGr/Fn"),
):
if map0[kc] != exp:
raise SystemExit(
f"FAIL: {path} etc/gemini-us.kmap keycode {kc} ({label}) = {map0[kc]:#06x}, expected {exp:#06x}"
)
cmdline = hdr[64:576].split(b"\x00", 1)[0].decode("ascii", "replace")
for req in ("clk_ignore_unused", "maxcpus=8", "noautodetect"):
if req not in cmdline.split():
raise SystemExit(f"FAIL: {path} cmdline missing '{req}': {cmdline}")
with open(sys.argv[3], "r", encoding="utf-8") as f:
kcfg = f.read()
for line in kcfg.splitlines():
if line.startswith("CONFIG_CMDLINE="):
for req in ("clk_ignore_unused", "maxcpus=8", "noautodetect"):
if req not in line:
raise SystemExit(f"FAIL: {sys.argv[3]} {line} missing '{req}'")
break
else:
raise SystemExit(f"FAIL: {sys.argv[3]} missing CONFIG_CMDLINE")
for req_cfg in ("CONFIG_REGULATOR_FIXED_VOLTAGE=y", "CONFIG_BLK_DEV_DM=y", "CONFIG_DM_CRYPT=y"):
if req_cfg not in kcfg.splitlines():
raise SystemExit(f"FAIL: {sys.argv[3]} missing {req_cfg}")
rootfs = sys.argv[4]
for req_rel in ("etc/pam.d/autologin", "etc/init.d/geminux-hwinit",
"usr/lib/dri/simpledrm_dri.so", "etc/runlevels/boot/geminux-usb-gadget",
"usr/share/X11/xkb/types/custom", "usr/sbin/dnsmasq",
"etc/NetworkManager/conf.d/20-geminux-wifi.conf", "etc/shells",
"etc/udev/rules.d/95-geminux-sdcard.rules",
"etc/init.d/geminux-sdcard",
"etc/runlevels/default/geminux-sdcard",
"media/sdcard",
"sbin/fsck.fat",
"sbin/fsck.vfat",
"sbin/mkfs.fat",
"sbin/mkfs.vfat",
"sbin/fatlabel",
"usr/sbin/geminux-sdcard-mount",
"usr/sbin/geminux-wifi-nvram", "usr/sbin/geminux-tzctl",
"usr/sbin/geminux-dnsctl",
"usr/sbin/geminux-cellctl",
"usr/bin/lpac",
"etc/NetworkManager/conf.d/25-geminux-ccmni.conf",
"usr/bin/geminux-datetime",
"usr/bin/bantam",
"usr/bin/lynx",
"usr/bin/webarchy",
"usr/bin/xwebarchy",
"usr/bin/dtach",
"usr/bin/gpg",
"usr/bin/gpg-agent",
"usr/bin/openssl",
"usr/bin/pass",
"usr/bin/pinentry",
"usr/bin/python3",
"usr/bin/pip3",
"usr/bin/mpv",
"usr/bin/ffmpeg",
"usr/bin/ffprobe",
"usr/bin/mpg123",
"usr/bin/openmpt123",
"usr/bin/yt-dlp",
"usr/lib/libgdk_pixbuf-2.0.so.0",
"usr/lib/gstreamer-1.0/libgstlibav.so",
"usr/share/glib-2.0/schemas/gschemas.compiled",
"usr/local/bin/gs-netcat",
"usr/local/bin/gsocket",
"etc/mpv/mpv.conf",
"etc/htoprc",
"etc/keymap/gemini-us.map",
"etc/skel/.gitconfig",
"etc/skel/.config/htop/htoprc",
"etc/skel/.lynx.cfg",
"etc/skel/.apexrc",
"home/user/.gitconfig",
"home/user/.config/htop/htoprc",
"home/user/.lynx.cfg",
"home/user/.apexrc",
"root/.config/htop/htoprc",
"root/.lynx.cfg",
"root/.apexrc",
"etc/NetworkManager/dispatcher.d/30-geminux-chrony",
"etc/polkit-1/rules.d/10-geminux.rules"):
if not os.path.lexists(os.path.join(rootfs, req_rel)):
raise SystemExit(f"FAIL: missing required path {os.path.join(rootfs, req_rel)}")
if not any(os.path.lexists(os.path.join(rootfs, p)) for p in ("sbin/cryptsetup", "usr/sbin/cryptsetup")):
raise SystemExit(f"FAIL: missing cryptsetup binary in {rootfs}")
if os.path.lexists(os.path.join(rootfs, "etc/runlevels/sysinit/hwdrivers")):
raise SystemExit("FAIL: hwdrivers must not be enabled in sysinit")
if os.path.lexists(os.path.join(rootfs, "etc/runlevels/default/wpa_supplicant")):
raise SystemExit("FAIL: wpa_supplicant must not be enabled in default runlevel")
with open(os.path.join(rootfs, "etc/inittab"), "r", encoding="utf-8") as f:
for line in f:
if line.startswith("tty1::respawn:"):
raise SystemExit("FAIL: rootfs/etc/inittab must not run getty on tty1 (reserved for tinydm/XLibre)")
for rel, needle in (
("etc/X11/xorg.conf.d/10-geminux-gpu.conf", 'Option "AccelMethod" "none"'),
("etc/X11/xorg.conf.d/10-geminux-gpu.conf", 'Option "ShadowFB" "true"'),
("etc/X11/xorg.conf.d/30-geminux-keyboard.conf", "custom:types"),
("etc/X11/xorg.conf.d/20-geminux-touch.conf", "0 -1 1 1 0 0 0 0 1"),
("etc/conf.d/geminux-hwinit", 'GEMINUX_ENABLE_MEDIATEK_DRM="yes"'),
("etc/NetworkManager/conf.d/20-geminux-wifi.conf", "wifi.scan-rand-mac-address = no"),
("etc/NetworkManager/conf.d/20-geminux-wifi.conf", "wifi-sec.pmf = 1"),
("etc/shells", "/bin/bash"),
("usr/bin/geminux-launcher", "Webarchy Browser"),
("usr/bin/geminux-launcher", "Bantam AI agent"),
):
p = os.path.join(rootfs, rel)
with open(p, "r", encoding="utf-8") as f:
if needle not in f.read():
raise SystemExit(f"FAIL: {p} missing '{needle}'")
xorg_mode = os.stat(os.path.join(rootfs, "usr/bin/Xorg")).st_mode & 0o7777
if xorg_mode != 0o4755:
raise SystemExit(f"FAIL: rootfs/usr/bin/Xorg mode is {oct(xorg_mode)}, expected 0o4755")
with open(os.path.join(rootfs, "usr/bin/bantam"), "rb") as f:
bantam_bin = f.read()
if b"kilo-auto/free" not in bantam_bin or b"openrouter/free" in bantam_bin:
raise SystemExit("FAIL: rootfs/usr/bin/bantam does not default to 'kilo-auto/free'")
repo_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[5]))))
with open(os.path.join(repo_dir, "src/dwm/dwm.c"), "r", encoding="utf-8") as f:
dwm_src = f.read()
if "PropertyChangeMask |\n FocusChangeMask;" not in dwm_src or "NotifyWhileGrabbed" not in dwm_src:
raise SystemExit("FAIL: src/dwm/dwm.c missing root FocusChangeMask or NotifyWhileGrabbed guard")
with open(os.path.join(repo_dir, "src/st/x.c"), "r", encoding="utf-8") as f:
stx_src = f.read()
if 'ttywrite("\\033[I", 3, 0);\n\t\tredraw();' not in stx_src or 'ttywrite("\\033[O", 3, 0);\n\t\tredraw();' not in stx_src:
raise SystemExit("FAIL: src/st/x.c focus() missing immediate redraw()")
awk_path = os.path.join(rootfs, "usr", "bin", "awk")
if not os.path.lexists(awk_path):
raise SystemExit(f"FAIL: missing BusyBox applet {awk_path}")
bb_path = os.path.join(rootfs, "bin", "busybox")
with open(bb_path, "rb") as f:
bb_data = f.read()
idx = bb_data.find(b"[\x00[[\x00")
if idx < 0:
raise SystemExit(f"FAIL: unable to locate applet table in {bb_path}")
end = bb_data.find(b"\x00\x00", idx)
names = [s.decode("ascii") for s in bb_data[idx:end].split(b"\x00") if s]
missing = [
n for n in names
if not any(os.path.lexists(os.path.join(rootfs, d, n))
for d in ("bin", "sbin", "usr/bin", "usr/sbin"))
]
if missing:
raise SystemExit(f"FAIL: {len(missing)} missing BusyBox applet(s): {' '.join(missing)}")
print(f"OK (kernel_addr=0x40080000, noautodetect, {len(names)} BusyBox applets linked)")
PYEOF
docker run --rm -i -v "$IMAGES_DIR:/images:ro" -v "$BASE_DIR/prebuilt/kernel/boot:/kboot:ro" alpine:3.24 sh -eu <<'SH_EOF'
apk add --no-cache e2fsprogs e2fsprogs-extra dtc >/dev/null
e2fsck -fn /images/geminux-rootfs.img
debugfs -R "stat /usr/bin/Xorg" /images/geminux-rootfs.img | grep -qE "Mode:[[:space:]]*04755\b" || {
echo "FAIL: geminux-rootfs.img /usr/bin/Xorg is not mode 04755" >&2; exit 1;
}
debugfs -R "stat /usr/bin/Xorg" /images/geminux-rootfs.img | grep -qE "User:[[:space:]]*0\b" || {
echo "FAIL: geminux-rootfs.img /usr/bin/Xorg is not UID 0" >&2; exit 1;
}
debugfs -R "stat /usr/bin/doas" /images/geminux-rootfs.img | grep -qE "Mode:[[:space:]]*04755\b" || {
echo "FAIL: geminux-rootfs.img /usr/bin/doas is not mode 04755" >&2; exit 1;
}
debugfs -R "stat /usr/libexec/dbus-daemon-launch-helper" /images/geminux-rootfs.img | grep -qE "Mode:[[:space:]]*04750\b" || {
echo "FAIL: geminux-rootfs.img /usr/libexec/dbus-daemon-launch-helper is not mode 04750" >&2; exit 1;
}
debugfs -R "stat /usr/libexec/dbus-daemon-launch-helper" /images/geminux-rootfs.img | grep -qE "User:[[:space:]]*0\b" || {
echo "FAIL: geminux-rootfs.img /usr/libexec/dbus-daemon-launch-helper is not UID 0" >&2; exit 1;
}
debugfs -R "stat /usr/libexec/dbus-daemon-launch-helper" /images/geminux-rootfs.img | grep -qE "Group:[[:space:]]*103\b" || {
echo "FAIL: geminux-rootfs.img /usr/libexec/dbus-daemon-launch-helper is not GID 103" >&2; exit 1;
}
debugfs -R "stat /etc/polkit-1/rules.d" /images/geminux-rootfs.img | grep -qE "Mode:[[:space:]]*0?4?0750\b" || {
echo "FAIL: geminux-rootfs.img /etc/polkit-1/rules.d is not mode 0750" >&2; exit 1;
}
debugfs -R "stat /etc/polkit-1/rules.d" /images/geminux-rootfs.img | grep -qE "Group:[[:space:]]*110\b" || {
echo "FAIL: geminux-rootfs.img /etc/polkit-1/rules.d is not GID 110" >&2; exit 1;
}
debugfs -R "stat /home/user" /images/geminux-rootfs.img | grep -qE "User:[[:space:]]*10000\b" || {
echo "FAIL: geminux-rootfs.img /home/user is not UID 10000" >&2; exit 1;
}
DTS_OUT="$(dtc -I dtb -O dts /kboot/mt6797-gemini-pda-geminux.dtb 2>/dev/null)"
printf "%s\n" "$DTS_OUT" | grep -qE "^\tmemory \{$" || { echo "FAIL: DTB missing /memory node" >&2; exit 1; }
if printf "%s\n" "$DTS_OUT" | grep -qE "^\tmemory@40000000 \{$"; then
echo "FAIL: DTB still contains root /memory@40000000" >&2
exit 1
fi
if printf "%s\n" "$DTS_OUT" | grep -q "memory@7df00000"; then
echo "FAIL: DTB contains static memory@7df00000 that triggers LK reserved_memory_conflict_check" >&2
exit 1
fi
printf "%s\n" "$DTS_OUT" | grep -q 'compatible = "pwm-backlight";' || {
echo "FAIL: DTB missing pwm-backlight node" >&2
exit 1
}
printf "%s\n" "$DTS_OUT" | awk '
/^\ti2c@11007000 \{/ { in_i2c=1; depth=1; next }
in_i2c {
if ($0 ~ /\{/) depth++
if ($0 ~ /\}/) { depth--; if (depth == 0) in_i2c=0 }
if (in_i2c && depth == 1 && $0 ~ /status = "okay";/) found_ok=1
if (in_i2c && depth == 1 && $0 ~ /status = "disabled";/) found_dis=1
}
/^\tpwm@1100f000 \{/ { in_pwm=1; depth_p=1; next }
in_pwm {
if ($0 ~ /\{/) depth_p++
if ($0 ~ /\}/) { depth_p--; if (depth_p == 0) in_pwm=0 }
if (in_pwm && depth_p == 1 && $0 ~ /status = "okay";/) pwm_ok=1
if (in_pwm && depth_p == 1 && $0 ~ /status = "disabled";/) pwm_dis=1
if (in_pwm && depth_p == 1 && $0 ~ /power-domains[[:space:]]*=/) pwm_pd=1
}
/^\tusb@11271000 \{/ { in_usb=1; depth_u=1; next }
in_usb {
if ($0 ~ /\{/) depth_u++
if ($0 ~ /\}/) { depth_u--; if (depth_u == 0) in_usb=0 }
if (in_usb && depth_u == 1 && $0 ~ /dr_mode = "peripheral";/) usb_periph=1
if (in_usb && depth_u == 1 && $0 ~ /usb-role-switch/) usb_rolesw=1
}
/ldo-vusb33 \{/ { in_vusb=1; next }
in_vusb && /\};/ { in_vusb=0 }
in_vusb && /regulator-always-on;/ { found_vusb=1 }
END {
if (!found_ok || found_dis) {
print "FAIL: DTB i2c@11007000 (&i2c0) must have status = \"okay\"" > "/dev/stderr"
exit 1
}
if (!found_vusb) {
print "FAIL: DTB ldo-vusb33 must have regulator-always-on" > "/dev/stderr"
exit 1
}
if (!pwm_ok || pwm_dis || pwm_pd) {
print "FAIL: DTB pwm@1100f000 (&disp_pwm) must be okay without power-domains" > "/dev/stderr"
exit 1
}
if (!usb_periph || usb_rolesw) {
print "FAIL: DTB usb@11271000 (&ssusb) must have dr_mode = \"peripheral\" and no usb-role-switch" > "/dev/stderr"
exit 1
}
}
'
SH_EOF
if readelf -Ws "$ROOTFS_DIR/usr/bin/Xorg" | grep -q systemd_logind_take_fd; then
echo "FAIL: rootfs/usr/bin/Xorg was still built with systemd_logind support" >&2
exit 1
fi
(cd "$IMAGES_DIR" && sha256sum -c SHA256SUMS)
echo "[8/8] Running all 8 Python unit/verification suites..."
python3 "$BASE_DIR/scripts/test-flash-mtk-gpt.py"
python3 "$BASE_DIR/scripts/test-xkb-keymap.py"
python3 "$BASE_DIR/scripts/test-theme-dunst-sync.py"
python3 "$BASE_DIR/scripts/test-ccci-protocol.py"
python3 "$BASE_DIR/scripts/test-power-policy.py"
python3 "$BASE_DIR/scripts/test-webarchy-renderer.py"
python3 "$BASE_DIR/scripts/test-webkit-gsettings.py"
python3 "$BASE_DIR/scripts/test-sdcard-automount.py"
echo "============================================================"
echo "ALL GEMINUX CHECKS PASSED CLEANLY"
echo "============================================================"