Add flasher credential provisioning, LUKS2 FDE, LED fixes, and docs
This commit is contained in:
1 parent
2706b9a901
commit
b7dca4f15f
49 files changed
+1500
-159
No files matched your search
@@ -21,3 +21,4 @@ __pycache__/
|
||||
!/keys/geminux-local.rsa.pub
|
||||
/prebuilt/apk-repo/
|
||||
.DS_Store
|
||||
local-reflash.sh
|
||||
+18
-11
@@ -4,44 +4,51 @@ Geminux combines a custom-patched Linux `7.3.5` kernel, pure-Linux MTK flasher,
|
||||
|
||||
## Kernel and MediaTek MT6797X support
|
||||
|
||||
- **Kernel tree**: Vanilla Linux `7.3.5` patched via [patches/kernel/](file:///home/lux/proj/geminux/patches/kernel) (`0001-ixoo-gemini-pda-mainline-7.3.5.patch`, `0002-mt6797-ccci-cldma-and-md1-domain.patch`, `0003-arm64-dts-mediatek-geminux-gemini-pda.patch`).
|
||||
- **Graphics & display**: MediaTek DRM (`mediatek-drm`), Novatek DSI panel (`panel-novatek-nt36672e`), Mali-T880 `panfrost` GPU driver, and `sii902x` Slimport/HDMI bridge.
|
||||
- **Kernel tree**: Vanilla Linux `7.3.5` patched via [patches/kernel/](file:///home/lux/proj/geminux/patches/kernel) (`0001-ixoo-gemini-pda-mainline-7.3.5.patch`, `0002-mt6797-ccci-cldma-and-md1-domain.patch`, `0003-arm64-dts-mediatek-geminux-gemini-pda.patch`, `0004-gemini-ssd2092-display-and-touch.patch`, `0005-mt6797-consys-wifi-factory-firmware.patch`, `0006-mt6797-boot-cleanups.patch`).
|
||||
- **Graphics & display**: MediaTek DRM (`mediatek-drm`), Solomon Systech `SSD2092` DSI FHD+ panel & touchscreen, early-boot `simpledrm` (`DRM_SIMPLEDRM=y` + rotated `TER16x32` console), Mali-T880 `panfrost` GPU driver, and `sii902x` Slimport/HDMI bridge.
|
||||
- **Wi-Fi / Bluetooth CONSYS**: Staged `mt6797_wlan_core` and `btmt6797` drivers backed by NVRAM/factory firmware provisioning (`geminux-wifi-nvram` and `firmware-cache/mt6797/`).
|
||||
- **Modem / Telephony**: Staged `mt6797-ccci-cldma` driver exposing `/dev/ccci_md_ctl`, `/dev/ccci_fs`, `/dev/ccci_rpc`, `/dev/ttyC0..3`, and `ccmni*` network interfaces with the 16-byte `struct mt6797_ccci_header` UAPI ([mt6797_ccci.h](file:///home/lux/proj/geminux/prebuilt/kernel/include/linux/mt6797_ccci.h)).
|
||||
- **Boot & recovery**: Packed LK-compatible Android boot images (`images/boot-geminux.img`, `images/recovery-geminux.img`) built with `mkbootimg-osm0sis` (`16 MiB` boot slot ceiling, `512 KiB` DTB ceiling). On first boot, [src/initramfs/init](file:///home/lux/proj/geminux/src/initramfs/init) checks ext4 via `e2fsck -p` and grows the root filesystem via `resize2fs`.
|
||||
- **Boot, LUKS2 FDE & recovery**: Packed LK-compatible Android boot images (`images/boot-geminux.img`, `images/recovery-geminux.img`) built with `mkbootimg-osm0sis` (`16 MiB` boot slot ceiling, `512 KiB` DTB ceiling). The kernel includes built-in `BLK_DEV_DM=y`, `DM_CRYPT=y`, and ARMv8 AES-CE (`CRYPTO_AES_ARM64_CE_BLK=y`), and the initramfs bundles `cryptsetup` plus a standalone binary Gemini US keymap (`/etc/gemini-us.kmap`). With `DM_DISABLE_UDEV=1`, [src/initramfs/init](file:///home/lux/proj/geminux/src/initramfs/init) runs the off-mode charger guard, optionally unlocks LUKS2 `PARTLABEL=linux` into `/dev/mapper/geminux_root` (whole-device dynamic segment), checks ext4 non-interactively (`e2fsck -p </dev/null`), and expands the root filesystem via `resize2fs -f </dev/null` on first boot. [src/initramfs/init-recovery](file:///home/lux/proj/geminux/src/initramfs/init-recovery) exposes a USB NCM/RNDIS gadget shell (`172.16.42.1/24`) with LUKS2-aware `unlock-root`, `check-fs`, and `mount-root`.
|
||||
|
||||
## Graphics, window management, and theming
|
||||
|
||||
- **XLibre (`25.x`)**: Cross-compiled against pure Alpine Edge `aarch64` sysroots with Panfrost Glamor EGL (`libglamoregl.so`), `modesetting_drv.so`, `fbdev_drv.so`, and `libinput_drv.so` ([scripts/build-xlibre.sh](file:///home/lux/proj/geminux/scripts/build-xlibre.sh)). Zero Wayland compositors (`sway`, `weston`, `phosh`, `xwayland`, etc.) are installed.
|
||||
- **Patched suckless desktop**:
|
||||
- `st` with HarfBuzz font shaping (`hb.c`) supporting Fira Code programming ligatures, Nerd Font fallback, and `SIGUSR1` live `.Xresources` reload.
|
||||
- `dwm` with Pango/HarfBuzz multi-font bar (`drw.c`), EWMH/XEmbed system tray, touch-friendly `>= 44px` status bar, `Mod4 = Fn+Alt` + one-shot `Super_L` tap-latch, and `SIGUSR1` `.Xresources` reload.
|
||||
- `dmenu` with Pango/HarfBuzz, `48px` touch rows, and mouse/touch click selection.
|
||||
- `st` with HarfBuzz font shaping (`hb.c`) supporting Fira Code programming ligatures, Nerd Font fallback, mouse/two-finger wheel scrollback, and `SIGUSR1` live `.Xresources` reload.
|
||||
- `dwm` with Pango/HarfBuzz multi-font bar (`drw.c`), EWMH/XEmbed system tray, touch-friendly `>= 68px` status bar, `Mod4 = Fn+Alt` + one-shot `Super_L` tap-latch, and `SIGUSR1` `.Xresources` reload.
|
||||
- `dmenu` with Pango/HarfBuzz, dynamic full-screen-height item rows (`68px` touch rows), and mouse/touch click selection.
|
||||
- **Zero-Rust notifications**: `dunst v1.12.2` compiled with `WAYLAND=0 DUNSTIFY=0` and custom pure-C PNG (`libpng` + Cairo) / JPEG (`libjpeg-turbo`) icon loader replacing `gdk-pixbuf` ([src/dunst-notify/](file:///home/lux/proj/geminux/src/dunst-notify/)), paired with a lightweight GDBus `notify-send` / `dunstify`.
|
||||
|
||||
## Custom UI toolkit and zero-poll C11 daemons
|
||||
|
||||
- **`libgemui.so`** ([src/libgemui/](file:///home/lux/proj/geminux/src/libgemui)): Double-buffered Cairo + Pango/HarfBuzz Xlib toolkit polling X11 events, `SIGUSR1` self-pipe for instant `.Xresources` reloads, dynamic timers, and non-blocking extra FDs (such as V4L2 or `inotify`).
|
||||
- **`libgemui.so`** ([src/libgemui/](file:///home/lux/proj/geminux/src/libgemui)): Double-buffered Cairo + Pango/HarfBuzz Xlib toolkit polling X11 events, `SIGUSR1` self-pipe for instant `.Xresources` reloads, dynamic timers, `MSG_NOSIGNAL`/drained Unix socket IPC (`gemui_unix_cmd`), and non-blocking extra FDs (such as V4L2 or `inotify`).
|
||||
- **11 landscape HiDPI applications** ([src/geminux-apps/](file:///home/lux/proj/geminux/src/geminux-apps)): `geminux-control`, `geminux-audio`, `geminux-datetime`, `geminux-net`, `geminux-dialer`, `geminux-callscreen`, `geminux-sms`, `geminux-contacts`, `geminux-camera` (MT6797 Media Controller pipeline + 10-bit Bayer demosaic/AWB software ISP), `geminux-themes`, and `geminux-lock`.
|
||||
- **Zero-poll C11 daemons** ([src/geminux-daemons/](file:///home/lux/proj/geminux/src/geminux-daemons)):
|
||||
- `geminux-powerd` — `epoll` over `/dev/input/event*` (`SW_LID`, `KEY_POWER`), `KOBJECT_UEVENT`, `/run/geminux/powerd.sock`, and on-demand `timerfd`.
|
||||
- `geminux-powerd` — `epoll` over `/dev/input/event*` (`SW_LID`, `KEY_POWER`), `KOBJECT_UEVENT`, `/run/geminux/powerd.sock`, and on-demand `timerfd`; resolves the active desktop user dynamically from UID `10000`.
|
||||
- `geminux-statusd` — `epoll` over `signalfd` (`SIGUSR1`), `RTMGRP_LINK`/`RTMGRP_IPV4_IFADDR`, `KOBJECT_UEVENT`, `inotify`, and minute-aligned `timerfd`; updates root `WM_NAME` with zero child shell forks.
|
||||
- `geminux-touchd` — XInput 2.2 multi-touch gesture daemon (2-finger tap/hold right-click, 3-finger middle-click, 2-finger scroll).
|
||||
- `geminux-leds` — AW9120 back cover RGB controller driving `rgb:indicator-1..5` (default off when idle/full; `rgb:indicator-6` amber while charging; persistent manual override; `SIGPIPE`-safe socket server at `/run/geminux/leds.sock`).
|
||||
- `geminux-ccci-daemon` — `epoll` over `/dev/ccci_*`, uevents, and `/run/geminux/ccci.sock`; idles cleanly if MD firmware is absent.
|
||||
- `geminux-modem-ctl`, `geminux-bt-obex` (GLib `GMainLoop`/GDBus), `geminux-leds`, `geminux-power-audit`, and `geminux-checkpw`.
|
||||
- `geminux-modem-ctl`, `geminux-bt-obex` (GLib `GMainLoop`/GDBus), `geminux-power-ctl`, `geminux-power-audit`, `geminux-tzctl`, `geminux-wifi-nvram`, and `geminux-checkpw`.
|
||||
|
||||
## APK package pinning and zero-Rust enforcement
|
||||
|
||||
To keep Alpine Edge `aarch64` userspace freely updatable while locking all hardware-tuned components:
|
||||
|
||||
1. Build-time host Docker containers use `postmarketos/v26.06` solely for `gcc-aarch64`, `binutils-aarch64`, and `mkbootimg-osm0sis`. All `$SYSROOT` trees and the target `$ROOTFS` use only pure **Alpine Edge** (`main`, `community`, `testing`) plus the RSA-4096 signed local `@geminux` repository (`/var/lib/geminux/apk-repo`).
|
||||
2. [scripts/package-local-apks.sh](file:///home/lux/proj/geminux/scripts/package-local-apks.sh) builds six `.apk` packages via `apk mkpkg` and indexes them into `APKINDEX.tar.gz` via `apk mkndx`:
|
||||
2. [scripts/package-local-apks.sh](file:///home/lux/proj/geminux/scripts/package-local-apks.sh) builds seven `.apk` packages via `apk mkpkg` and indexes them into `APKINDEX.tar.gz` via `apk mkndx`:
|
||||
- `geminux-kernel-modules`
|
||||
- `geminux-xlibre`
|
||||
- `geminux-suckless`
|
||||
- `geminux-dunst`
|
||||
- `geminux-ui`
|
||||
- `geminux-bantam` (`bantam` minimalist C++20 CLI AI agent built via [scripts/build-bantam.sh](file:///home/lux/proj/geminux/scripts/build-bantam.sh))
|
||||
- `geminux-config`
|
||||
3. `/etc/apk/world` pins all six with `name@geminux=version` and locks out Rust/Wayland/upstream overrides via `!` constraints from [scripts/rootfs-prune-packages.txt](file:///home/lux/proj/geminux/scripts/rootfs-prune-packages.txt).
|
||||
3. `/etc/apk/world` pins all seven with `name@geminux=version` and locks out Rust/Wayland/upstream overrides via `!` constraints from [scripts/rootfs-prune-packages.txt](file:///home/lux/proj/geminux/scripts/rootfs-prune-packages.txt).
|
||||
4. `/etc/apk/protected_paths.d/geminux.list` shields Geminux configuration directories across upgrades.
|
||||
|
||||
## Pure-Linux flasher and eMMC layout
|
||||
|
||||
[flash-mtk.py](file:///home/lux/proj/geminux/flash-mtk.py) uses vendored GPLv3 `mtkclient` + single-chip `MTK_DA_V5_MT6797.bin` to communicate directly over USB BROM/DA without MediaTek's proprietary GUI. Protected partitions in `LBA 0..0x6FFFF` (`preloader`, `nvram`, `proinfo`, `lk`, `tee1`, `md1img`, etc.) are backed up and write-blocked by default (`0x0E000000` protected boundary verified in [scripts/test-flash-mtk-gpt.py](file:///home/lux/proj/geminux/scripts/test-flash-mtk-gpt.py)).
|
||||
|
||||
On staged copies of `geminux-rootfs.img` (without mutating the build output), [scripts/geminux_accounts.py](file:///home/lux/proj/geminux/scripts/geminux_accounts.py) performs pure-Python `$6$` SHA-512 password hashing and offline `debugfs`/`e2fsck` `/etc/{passwd,group,shadow}` + `/home/<username>` provisioning, and [scripts/geminux_luks.py](file:///home/lux/proj/geminux/scripts/geminux_luks.py) optionally wraps the staged ext4 image in an encrypted LUKS2 container via unprivileged host `cryptsetup reencrypt --encrypt --disable-locks`.
|
||||
+33
-13
@@ -60,41 +60,61 @@ Extracted blobs are placed in `firmware-cache/mt6797/` and automatically injecte
|
||||
Geminux claims the entire user-writable eMMC past the protected MediaTek region (`LBA 0x70000`, byte offset `0x0E000000`, `SYS0..SYS27`), removing Android `system`, `cache`, and `userdata` in favor of `boot`, `recovery`, `boot2`, and a single full-disk `linux` ext4 partition:
|
||||
|
||||
```sh
|
||||
# Interactive: prompts for desktop username, desktop password, root password,
|
||||
# and optional LUKS2 full-disk encryption before waiting for USB BROM/Preloader:
|
||||
./flash-mtk.sh --flash-full
|
||||
|
||||
# Non-interactive with explicit credentials and interactive LUKS2 passphrase:
|
||||
./flash-mtk.sh --flash-full --username alice --ask-user-password --ask-root-password --encrypt
|
||||
|
||||
# Non-interactive using image defaults (unencrypted):
|
||||
./flash-mtk.sh --flash-full --use-default-credentials
|
||||
```
|
||||
|
||||
What `--flash-full` does automatically (implemented in [flash-mtk.py](file:///home/lux/proj/geminux/flash-mtk.py) and [scripts/geminux_gpt.py](file:///home/lux/proj/geminux/scripts/geminux_gpt.py)):
|
||||
What `--flash-full` does automatically (implemented in [flash-mtk.py](file:///home/lux/proj/geminux/flash-mtk.py), [scripts/geminux_accounts.py](file:///home/lux/proj/geminux/scripts/geminux_accounts.py), [scripts/geminux_luks.py](file:///home/lux/proj/geminux/scripts/geminux_luks.py), and [scripts/geminux_gpt.py](file:///home/lux/proj/geminux/scripts/geminux_gpt.py)):
|
||||
|
||||
1. Takes an initial backup into `backup/<timestamp>/` (or pass `--skip-backup --backup-dir backup/<timestamp>` on subsequent reflashes to reuse an existing backup).
|
||||
2. Verifies the protected factory partition layout before `0x0E000000` (`pass --force-gpt` only if intentionally converting a non-standard partition table).
|
||||
3. Writes updated Primary GPT (`LBA 0..33`) and Backup GPT with a mandatory readback verification check.
|
||||
4. Writes `boot-geminux.img` to `boot` and `boot2`, `recovery-geminux.img` to `recovery` (with readback verification), and `geminux-rootfs.img` to `linux`, then sends the DA reboot handshake (`--reboot` default, `--poweroff` to stay powered off, or `--no-reboot` to remain in DA mode).
|
||||
1. Resolves desktop `username`, desktop `password`, `root` `password`, and optional `--encrypt` LUKS2 passphrase before waiting for USB BROM/Preloader. Flags available: `--username`, `--user-password`, `--ask-user-password`, `--root-password`, `--ask-root-password`, `--use-default-credentials`, `--encrypt`, `--luks-password`, and `--ask-luks-password`. The LUKS2 disk passphrase is independent of the desktop and `root` login passwords (though you may enter the same passphrase if desired).
|
||||
2. Takes an initial backup into `backup/<timestamp>/` (or pass `--skip-backup --backup-dir backup/<timestamp>` on subsequent reflashes to reuse an existing backup).
|
||||
3. Verifies the protected factory partition layout before `0x0E000000` (`pass --force-gpt` only if intentionally converting a non-standard partition table).
|
||||
4. Writes updated Primary GPT (`LBA 0..33`) and Backup GPT with a mandatory readback verification check.
|
||||
5. Stages a temporary copy of `geminux-rootfs.img` (leaving `images/geminux-rootfs.img` unmodified), provisions `/etc/passwd`, `/etc/group`, `/etc/shadow`, and `/home/<username>` via `debugfs`/`e2fsck`, optionally wraps it inside a LUKS2 container (`aes-xts-plain64`, Argon2id), writes `boot-geminux.img` to `boot` and `boot2`, `recovery-geminux.img` to `recovery` (with readback verification), and the staged rootfs to `linux`, then sends the DA reboot handshake (`--reboot` default, `--poweroff` to stay powered off, or `--no-reboot` to remain in DA mode).
|
||||
|
||||
To update only the kernel and initramfs later without touching GPT or the root filesystem:
|
||||
Additional flashing and offline image utilities:
|
||||
|
||||
```sh
|
||||
# Update only boot, boot2, and recovery without touching GPT or linux:
|
||||
./flash-mtk.sh --flash-kernel-only
|
||||
```
|
||||
|
||||
To restore a previous backup:
|
||||
# Update only the linux rootfs partition (with optional credentials and --encrypt):
|
||||
./flash-mtk.sh --flash-rootfs-only --username alice --ask-user-password --encrypt
|
||||
|
||||
```sh
|
||||
# Create an offline customized (and optionally LUKS2-encrypted) ext4 rootfs image:
|
||||
./flash-mtk.sh --customize-rootfs /tmp/custom-rootfs.img --username alice --ask-user-password --ask-root-password --encrypt
|
||||
|
||||
# Restore a previous backup:
|
||||
./flash-mtk.sh --restore-backup backup/<timestamp>
|
||||
```
|
||||
|
||||
## First boot and recovery notes
|
||||
|
||||
- Disconnect the USB-C cable and hold the **Esc** (power) button until the unit boots.
|
||||
- On first boot, the initramfs automatically expands the ext4 filesystem (`resize2fs`) to fill the entire `linux` partition before pivoting to OpenRC.
|
||||
- TinyDM automatically logs into XLibre + DWM as `user` (UID `10000`, default password `geminux`, SSH authorized key installed from `keys/geminux_id_ed25519.pub` if generated). Change the `user` and `root` passwords immediately with `passwd`.
|
||||
- Connecting a host PC over USB-C starts the `usb0` NCM Ethernet gadget on `172.16.42.1/24` for rescue SSH access.
|
||||
- If flashed with `--encrypt`, the initramfs loads the standalone binary Gemini US keyboard map (`/etc/gemini-us.kmap`) on `tty1` and prompts for the LUKS2 passphrase before mounting `PARTLABEL=linux` via `cryptsetup open --allow-discards` as `/dev/mapper/geminux_root` (off-mode battery charging still runs before the unlock prompt). Because LUKS2 data segment 0 uses dynamic whole-device length, unlocking immediately maps the full `linux` partition.
|
||||
- On first boot, the initramfs runs non-interactive `e2fsck -p` and `resize2fs -f` (`</dev/null`) to expand the ext4 filesystem across the full ~58 GiB `linux` partition, writes `/var/lib/geminux/.rootfs-resized` so future boots skip first-boot resizing, and pivots to OpenRC.
|
||||
- TinyDM automatically logs into XLibre + DWM as UID `10000` (either your provisioned `--username` or the default `user`; default password `geminux` unless set during flashing). SSH authorized key is installed from `keys/geminux_id_ed25519.pub` if generated. Change passwords at any time with `passwd`.
|
||||
- Connecting a host PC over USB-C starts the `usb0` NCM Ethernet gadget on `172.16.42.1/24` for rescue SSH access. In recovery mode, `unlock-root`, `check-fs`, and `mount-root` automatically handle LUKS2 unlock when needed.
|
||||
|
||||
## Full-disk encryption (LUKS2) details
|
||||
|
||||
- **Kernel & Hardware**: Built-in `BLK_DEV_DM=y`, `DM_CRYPT=y`, `CRYPTO_ESSIV=y`, ARMv8 AES-CE (`CRYPTO_AES_ARM64_CE_BLK=y`, `CRYPTO_XTS=y`, `CRYPTO_SHA256=y`), `DRM_SIMPLEDRM=y` + rotated `TER16x32` console, and `KEYBOARD_MATRIX=y` + `PINCTRL_AW9523=y`.
|
||||
- **Format & Expansion**: Host-side `cryptsetup reencrypt --encrypt --disable-locks` wraps the staged rootfs with a 32 MiB LUKS2 header pad (`16 MiB` payload offset, dynamic whole-device segment length, `aes-xts-plain64` 512-bit, Argon2id 128 MiB / 4 threads) so no plaintext rootfs touches eMMC; `cryptsetup open --allow-discards` maps the full partition upon unlock and first boot runs `resize2fs -f` to grow the inner ext4 filesystem to ~58 GiB.
|
||||
- **Security Scope**: Protects data at rest against device theft or physical eMMC extraction. Because MediaTek's stock `lk` bootloader does not enforce AVB verified boot on `boot`/`recovery`/`boot2`, FDE does not defend against offline tampering of the `boot` partition.
|
||||
|
||||
## Live Gemini PDA x27 hardware validation checklist
|
||||
|
||||
Perform these checks on physical hardware after the first boot:
|
||||
|
||||
- [ ] Confirm `uname -r` reports `7.3.5-geminux` and `lsmod` shows `mediatek_drm`, `panfrost`, `mt6797_ccci_cldma`, `mt6797_wlan_core`, and `btmt6797`.
|
||||
- [ ] Verify touch input (`novatek-nt36xxx`) and physical keyboard mappings (`Fn+1..0 = F1..F10`, `Fn+Alt = Mod4`, Planet key).
|
||||
- [ ] Verify `ssd2092` touchscreen input, multi-touch gestures (`geminux-touchd`), and physical keyboard mappings (`Fn+1..0 = F1..F10`, `Fn+Alt = Mod4`, Planet key).
|
||||
- [ ] Confirm Glamor 3D acceleration via `glxinfo | grep -i renderer`.
|
||||
- [ ] Test Wi-Fi connectivity via `geminux-net` or `nmcli`, Bluetooth via `geminux-net`, and audio playback/recording (speaker, 3.5mm jack, internal mic).
|
||||
- [ ] With MD1 firmware extracted, verify `/dev/ccci_md_ctl`, `/dev/ttyC0`, and `ccmni*` registration for LTE data, voice calls (`geminux-dialer`), and SMS (`geminux-sms`).
|
||||
|
||||
@@ -30,7 +30,7 @@ In [src/dwm/config.h](file:///home/lux/proj/geminux/src/dwm/config.h), `MODKEY`
|
||||
| `Mod4 + 1..5` | Switch workspace tags (`Mod4 + Shift + 1..5` moves window to tag) |
|
||||
| `Mod4 + Shift + c` | Close focused window |
|
||||
|
||||
Touchscreen input is supported directly across XLibre (`libinput`), DWM tag/layout/close buttons (`>= 68px` top bar), `dmenu` items (`68px` rows), `st`, and all nine `libgemui` applications (scaled for `180 DPI` / `>= 1.85x`).
|
||||
Touchscreen input is supported directly across XLibre (`libinput`), DWM tag/layout/close buttons (`>= 68px` top bar), full-screen-height `dmenu` items (`68px` rows), `st`, and all 11 `libgemui` applications (scaled for `180 DPI` / `>= 1.85x`).
|
||||
|
||||
### Touchscreen multi-touch gestures
|
||||
|
||||
@@ -58,9 +58,11 @@ geminux-apply-theme TokyoNight
|
||||
## Applications and daemons
|
||||
|
||||
- **Telephony & messaging**: `geminux-dialer`, `geminux-callscreen`, `geminux-sms`, `geminux-contacts` backed by `geminux-modem-ctl` and `geminux-ccci-daemon` (using `alsaucm` UCM2 `VoiceCall` / `HiFi` switching and call suspend inhibitors).
|
||||
- **Audio & date/time**: `geminux-audio` manages PipeWire sink/source routing, mute state, and per-stream volume via `wpctl`/`pactl`. `geminux-datetime` manages the system timezone (`geminux-tzctl`) and shows live Chrony NTP sync status.
|
||||
- **Connectivity**: `geminux-net` manages Wi-Fi (`nmcli`), 4G/CCCI state (`mmcli` + `/run/geminux/ccci.sock`), Bluetooth (`bluetoothctl` / `rfkill`), and SiI9024 external HDMI output (`xrandr`).
|
||||
- **Camera**: `geminux-camera` streams from `/dev/video*` via V4L2 `mmap` and writes native `libjpeg-turbo` stills to `~/Pictures/` and native MJPEG-AVI video clips to `~/Videos/`.
|
||||
- **System control & lock**: `geminux-control` adjusts display backlight, PipeWire audio volume, MT6797X power profile (`eco`, `balanced`, `performance`), and AW9120 LEDs (`/run/geminux/leds.sock`). `geminux-lock` secures the X session using `doas -n /usr/sbin/geminux-checkpw`.
|
||||
- **Camera**: `geminux-camera` configures the MT6797 Media Controller pipeline (`ov5670`/`s5k4e6` -> `seninf` -> `camsv`), captures 10-bit Bayer (`SBGGR10`/`SGRBG10`) frames over V4L2 `mmap` with a pure-C demosaic + AWB software ISP, and writes native `libjpeg-turbo` stills to `~/Pictures/` and MJPEG-AVI clips to `~/Videos/`.
|
||||
- **System control, LEDs & lock**: `geminux-control` adjusts display backlight, PipeWire audio volume, MT6797X power profile (`eco`, `balanced`, `performance`), and AW9120 LEDs (`/run/geminux/leds.sock`). `geminux-leds` drives the 5-LED RGB back strip (`rgb:indicator-1..5`, defaulting to off when idle or 100% charged) plus `rgb:indicator-6` (amber while charging), supports calibrated presets including `rgb 160 16 0` ("Amber Warn"), and preserves manual `off` / `rgb` overrides across battery uevents. `geminux-lock` secures the X session using `doas -n /usr/sbin/geminux-checkpw`, while `geminux-lock` / `geminux-powerd` resolve the desktop account dynamically from UID `10000` (`--username` or default `user`).
|
||||
- **CLI developer tools**: `bantam` (`geminux-bantam`, minimalist C++20 OpenAI-compatible terminal AI agent; see [src/bantam/README.md](file:///home/lux/proj/geminux/src/bantam/README.md)) and a preconfigured `/etc/skel/.gitconfig` are preinstalled.
|
||||
|
||||
## Maintaining Alpine Edge packages safely
|
||||
|
||||
@@ -71,4 +73,4 @@ doas apk update
|
||||
doas apk upgrade
|
||||
```
|
||||
|
||||
Because custom Geminux components (`geminux-kernel-modules`, `geminux-xlibre`, `geminux-suckless`, `geminux-dunst`, `geminux-ui`, `geminux-config`) are exact-version pinned (`name@geminux=version`) in `/etc/apk/world` and Rust/upstream overrides (`!rust`, `!cargo`, `!librsvg`, `!libglycin`, `!gdk-pixbuf`, `!xorg-server`, `!linux-edge`, etc.) are negated in `/etc/apk/world`, normal Alpine Edge upgrades update upstream libraries, CLI tools, NetworkManager, ModemManager, PipeWire, and Mesa without overwriting custom patched binaries or pulling Rust packages.
|
||||
Because custom Geminux components (`geminux-kernel-modules`, `geminux-xlibre`, `geminux-suckless`, `geminux-dunst`, `geminux-ui`, `geminux-bantam`, `geminux-config`) are exact-version pinned (`name@geminux=version`) in `/etc/apk/world` and Rust/upstream overrides (`!rust`, `!cargo`, `!librsvg`, `!libglycin`, `!gdk-pixbuf`, `!xorg-server`, `!linux-edge`, etc.) are negated in `/etc/apk/world`, normal Alpine Edge upgrades update upstream libraries, CLI tools, NetworkManager, ModemManager, PipeWire, and Mesa without overwriting custom patched binaries or pulling Rust packages.
|
||||
@@ -11,6 +11,7 @@ Configured in [kernel/configs/geminux-mt6797x.config](file:///home/lux/proj/gemi
|
||||
- **`CONFIG_SUSPEND=y`**: Enables deep Suspend-to-RAM (`mem` / `deep`) triggered on Gemini PDA lid close (`SW_LID`) or power button press.
|
||||
- **`CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL=y`**: Uses scheduler utilization feedback (`schedutil`) across the MT6797X tri-cluster (Cortex-A53 + Cortex-A72) topology instead of static `performance` governors.
|
||||
- **`CONFIG_ZRAM_DEF_COMP_LZ4=y`** with `2 GiB` LZ4 `zram` swap (`etc/conf.d/zram-init`) and `vm.swappiness=100` (`etc/sysctl.d/99-geminux-power.conf`): avoids slow, power-hungry flash swap I/O on eMMC and pairs with `commit=60,noatime` mount options (`etc/fstab`).
|
||||
- **`CONFIG_CRYPTO_AES_ARM64_CE_BLK=y`** paired with `--allow-discards` in initramfs: runs optional LUKS2 `dm-crypt` (`aes-xts-plain64`) encryption using ARMv8 hardware AES Cryptography Extensions with negligible battery overhead.
|
||||
|
||||
## Zero-poll userspace daemons
|
||||
|
||||
@@ -18,8 +19,9 @@ All background system services avoid wake-up timers and polling loops:
|
||||
|
||||
- **`geminux-powerd`**: Sleeps indefinitely in `epoll_wait()` over `/dev/input/event*` (`SW_LID`, `KEY_POWER`), `KOBJECT_UEVENT` netlink (AC charger/HDMI hotplug), `/run/geminux/powerd.sock`, and an on-demand `timerfd`.
|
||||
- **`geminux-statusd`**: Uses `signalfd` (`SIGUSR1`), `RTMGRP_LINK` netlink, `inotify`, and a minute-aligned `timerfd` so the DWM status bar wakes only on actual network/power/modem changes or minute boundaries with zero child shell forks.
|
||||
- **`geminux-touchd`**: Event-driven XInput 2.2 multi-touch gesture recognizer with zero polling loops.
|
||||
- **`geminux-ccci-daemon` & `geminux-modem-ctl`**: Event-driven `epoll_wait()` over `/dev/ccci_*`, AT port, and netlink; enter completely idle sleep when no modem activity is pending.
|
||||
- **`geminux-bt-obex` & `geminux-leds`**: Event-driven GLib/GDBus and `epoll_wait()` + `KOBJECT_UEVENT` control without periodic polling.
|
||||
- **`geminux-bt-obex` & `geminux-leds`**: Event-driven GLib/GDBus and `epoll_wait()` + `KOBJECT_UEVENT` control without periodic polling. `geminux-leds` keeps the back AW9120 cover strip (`rgb:indicator-1..5`) off (`0 mA`) when idle or at 100% charge, lighting only `rgb:indicator-6` during active battery charging unless manually overridden.
|
||||
|
||||
## Cluster gating and profiles
|
||||
|
||||
|
||||
@@ -1,41 +1,42 @@
|
||||
# Geminux
|
||||
|
||||
Geminux is an Alpine Linux (`aarch64`, musl, OpenRC) distribution built specifically for the Planet Computers Gemini PDA (Wi-Fi + 4G, MediaTek MT6797X / Helio X27). It runs a patched Linux `7.3.5-geminux` kernel, XLibre Xorg with Panfrost Glamor 3D acceleration, a custom Pango/HarfBuzz-enabled DWM/st/dmenu desktop with Fira Code ligatures and Noto fonts, zero-poll C11 system daemons, nine landscape HiDPI applications (`libgemui.so`), and a pure-Linux MediaTek flasher.
|
||||
Geminux is an Alpine Linux (`aarch64`, musl, OpenRC) distribution built specifically for the Planet Computers Gemini PDA (Wi-Fi + 4G, MediaTek MT6797X / Helio X27). It runs a patched Linux `7.3.5-geminux` kernel, XLibre Xorg with Panfrost Glamor 3D acceleration, a custom Pango/HarfBuzz-enabled DWM/st/dmenu desktop with Fira Code ligatures and Noto fonts, zero-poll C11 system daemons, 11 landscape HiDPI applications (`libgemui.so`), the preinstalled `bantam` CLI AI agent (`geminux-bantam`), and a pure-Linux MediaTek flasher with account provisioning and optional LUKS2 full-disk encryption.
|
||||
|
||||
## Key design goals
|
||||
|
||||
- Pure Alpine Edge userspace updatable via `apk update && apk upgrade`
|
||||
- Pinned kernel, modules, XLibre, suckless desktop, custom UI, and device configs in local signed `@geminux` APK packages (`name@geminux=version`)
|
||||
- Pinned kernel, modules, XLibre, suckless desktop, custom UI, `bantam`, and device configs in local signed `@geminux` APK packages (`name@geminux=version`)
|
||||
- Zero Rust-dependent packages preinstalled (verified across installed ELF binaries and blocked via `!` pins in `/etc/apk/world`)
|
||||
- Full eMMC occupancy for Linux (`geminux-root`) without Android dual-boot sharing, while strictly preserving the MediaTek protected region (`LBA 0..0x6FFFF`)
|
||||
- Aggressive battery optimization from kernel (`HZ_100`, `RCU_LAZY`, `SUSPEND`, LZ4 `zram`, `SCHEDUTIL`) up to userspace (`epoll`-based zero-poll daemons, A72 big-cluster gating, WirePlumber idle suspend, Wi-Fi `powersave = 3`, Bluetooth disabled at boot, lid-close S3 suspend)
|
||||
- Optional LUKS2 + `dm-crypt` full-disk encryption (`--encrypt`, `aes-xts-plain64` with ARMv8 AES-CE, Argon2id) with early-boot `simpledrm` + Gemini matrix keyboard unlock and automatic first-boot ext4 expansion, alongside offline desktop/`root` credential provisioning during flashing
|
||||
- Aggressive battery optimization from kernel (`HZ_100`, `RCU_LAZY`, `SUSPEND`, LZ4 `zram`, `SCHEDUTIL`) up to userspace (`epoll`-based zero-poll daemons, A72 big-cluster gating, WirePlumber idle suspend, Wi-Fi `powersave = 3`, Bluetooth disabled at boot, default-off cover LEDs, lid-close S3 suspend)
|
||||
|
||||
## Component stack
|
||||
|
||||
| Subsystem | Implementation | Source / Script |
|
||||
| --- | --- | --- |
|
||||
| Kernel & boot | Linux `7.3.5-geminux` + Gemini x27 patches + CCCI/CLDMA + `sii902x` | [scripts/build-kernel.sh](file:///home/lux/proj/geminux/scripts/build-kernel.sh) |
|
||||
| Flasher & GPT | Vendored GPLv3 `mtkclient` + MT6797 DA + GPT builder | [flash-mtk.sh](file:///home/lux/proj/geminux/flash-mtk.sh), [flash-mtk.py](file:///home/lux/proj/geminux/flash-mtk.py) |
|
||||
| Kernel & boot | Linux `7.3.5-geminux` + Gemini x27 patches (`SSD2092` DSI/touch, CONSYS Wi-Fi/BT, CCCI/CLDMA, `sii902x`, `dm-crypt` LUKS2 initramfs) | [scripts/build-kernel.sh](file:///home/lux/proj/geminux/scripts/build-kernel.sh) |
|
||||
| Flasher & GPT | Vendored GPLv3 `mtkclient` + MT6797 DA + GPT builder + offline credential & LUKS2 provisioning | [flash-mtk.sh](file:///home/lux/proj/geminux/flash-mtk.sh), [flash-mtk.py](file:///home/lux/proj/geminux/flash-mtk.py), [scripts/geminux_accounts.py](file:///home/lux/proj/geminux/scripts/geminux_accounts.py), [scripts/geminux_luks.py](file:///home/lux/proj/geminux/scripts/geminux_luks.py) |
|
||||
| Display server | XLibre Xorg 25.x (`Glamor`, `modesetting`, `fbdev`, `libinput`) | [scripts/build-xlibre.sh](file:///home/lux/proj/geminux/scripts/build-xlibre.sh) |
|
||||
| Window manager & terminal | Patched `dwm` (Pango, systray, `.Xresources`, `Mod4`), `st` (HarfBuzz ligatures), `dmenu` | [scripts/build-suckless.sh](file:///home/lux/proj/geminux/scripts/build-suckless.sh) |
|
||||
| Window manager & terminal | Patched `dwm` (Pango, systray, `.Xresources`, `Mod4`), `st` (HarfBuzz ligatures, wheel scrollback), full-height `dmenu` | [scripts/build-suckless.sh](file:///home/lux/proj/geminux/scripts/build-suckless.sh) |
|
||||
| Notifications | Pure-X11 zero-`gdk-pixbuf` `dunst v1.12.2` + custom GDBus `notify-send` / `dunstify` | [scripts/build-dunst.sh](file:///home/lux/proj/geminux/scripts/build-dunst.sh) |
|
||||
| UI & daemons | `libgemui.so`, 9 landscape HiDPI apps, 7 zero-poll C11 daemons | [scripts/build-geminux-ui.sh](file:///home/lux/proj/geminux/scripts/build-geminux-ui.sh) |
|
||||
| Local APK repository | Signed `@geminux` `.apk` packages + `APKINDEX.tar.gz` | [scripts/package-local-apks.sh](file:///home/lux/proj/geminux/scripts/package-local-apks.sh) |
|
||||
| UI, daemons & CLI agent | `libgemui.so`, 11 landscape HiDPI apps, zero-poll C11 daemons, and `bantam` CLI AI agent | [scripts/build-geminux-ui.sh](file:///home/lux/proj/geminux/scripts/build-geminux-ui.sh), [scripts/build-bantam.sh](file:///home/lux/proj/geminux/scripts/build-bantam.sh) |
|
||||
| Local APK repository | 7 signed `@geminux` `.apk` packages + `APKINDEX.tar.gz` | [scripts/package-local-apks.sh](file:///home/lux/proj/geminux/scripts/package-local-apks.sh) |
|
||||
| Full build & checks | Full image assembly + offline verification suite | [rebuild-image.sh](file:///home/lux/proj/geminux/rebuild-image.sh), [scripts/check-rebuild.sh](file:///home/lux/proj/geminux/scripts/check-rebuild.sh) |
|
||||
|
||||
## Repository layout
|
||||
|
||||
- [kernel/](file:///home/lux/proj/geminux/kernel) and [patches/kernel/](file:///home/lux/proj/geminux/patches/kernel) — kernel manifest, MT6797X configuration, and Linux `7.3.5` patch queue
|
||||
- [src/](file:///home/lux/proj/geminux/src) — initramfs scripts, `st`, `dwm`, `dmenu`, `dunst-notify`, `libgemui`, `geminux-apps`, and `geminux-daemons`
|
||||
- [overlay/rootfs/](file:///home/lux/proj/geminux/overlay/rootfs) — OpenRC services, ALSA UCM2, XKB layout, Xorg drop-ins, 21 `.xth` themes, PipeWire/WirePlumber, udev, and NetworkManager configs
|
||||
- [src/](file:///home/lux/proj/geminux/src) — initramfs scripts, `st`, `dwm`, `dmenu`, `dunst-notify`, `bantam`, `libgemui`, `geminux-apps`, and `geminux-daemons`
|
||||
- [overlay/rootfs/](file:///home/lux/proj/geminux/overlay/rootfs) — OpenRC services, ALSA UCM2, XKB layout, console keymap, Xorg drop-ins, 21 `.xth` themes, PipeWire/WirePlumber, udev, and NetworkManager configs
|
||||
- [scripts/](file:///home/lux/proj/geminux/scripts) — cross-compilation builders, APK packager, rootfs bootstrapper, verification suite, and unit tests
|
||||
- [prebuilt/](file:///home/lux/proj/geminux/prebuilt) — cross-compiled `aarch64` staging tree (`images/` holds built boot, recovery, and ext4 rootfs images)
|
||||
|
||||
## Verification status vs. on-device testing
|
||||
|
||||
All cross-compiled binaries, kernel/DTB artifacts, GPT repartitioning logic, XKB keymap compilation, `.Xresources`-to-`dunstrc` theme syncing, MT6797 CCCI framing/handshake unit tests, zero-poll power policy tests, ELF binary Rust scan, and `apk upgrade --simulate` checks are verified offline on the build host and inside Alpine Linux Docker containers.
|
||||
All cross-compiled binaries, kernel/DTB artifacts, GPT repartitioning logic, offline credential/LUKS2 builders, XKB keymap compilation, `.Xresources`-to-`dunstrc` theme syncing, MT6797 CCCI framing/handshake unit tests, zero-poll power policy tests, ELF binary Rust scan, and `apk upgrade --simulate` checks are verified automatically via [scripts/check-rebuild.sh](file:///home/lux/proj/geminux/scripts/check-rebuild.sh).
|
||||
|
||||
Runtime hardware testing on a physical Planet Computers Gemini PDA (x27 Wi-Fi + 4G) — including live BROM/DA flashing, 3D Panfrost rendering, cellular calls/SMS with device-extracted MediaTek firmware, camera capture, HDMI output, and battery drain telemetry — must be completed on physical hardware; see [INSTALL.md](file:///home/lux/proj/geminux/INSTALL.md).
|
||||
Live hardware bring-up on a physical Planet Computers Gemini PDA (x27 Wi-Fi + 4G) has been verified for USB BROM/DA flashing, offline account provisioning, LUKS2 full-disk encryption unlock & first-boot ext4 resize, `SSD2092` FHD+ display & multi-touch gestures (`geminux-touchd`), CONSYS Wi-Fi/BT, PipeWire audio, Media Controller + 10-bit Bayer camera ISP, AW9120 RGB back LEDs, Chrony online time sync, and USB NCM networking. Accessory/carrier-dependent checks (such as live cellular calls/SMS with a SIM card and external Slimport/HDMI monitors) are documented in the hardware checklist in [INSTALL.md](file:///home/lux/proj/geminux/INSTALL.md).
|
||||
|
||||
## Quick start (host build and checks)
|
||||
|
||||
|
||||
+248
-14
@@ -5,6 +5,7 @@ Uses vendored GPLv3 mtkclient transport (no proprietary MediaTek FlashTool).
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import getpass
|
||||
import hashlib
|
||||
import logging
|
||||
import os
|
||||
@@ -21,6 +22,17 @@ for p in (VENDOR_MTK, SCRIPTS_DIR):
|
||||
if p not in sys.path:
|
||||
sys.path.insert(0, p)
|
||||
|
||||
from geminux_accounts import (
|
||||
AccountConfig,
|
||||
customize_ext4_accounts,
|
||||
sha512_crypt,
|
||||
validate_username,
|
||||
)
|
||||
from geminux_luks import (
|
||||
LuksConfig,
|
||||
encrypt_ext4_image_luks2,
|
||||
validate_luks_passphrase,
|
||||
)
|
||||
from geminux_gpt import (
|
||||
SECTOR_SIZE,
|
||||
GPT_ARRAY_SECTORS,
|
||||
@@ -279,7 +291,177 @@ def extract_fw_from_device(da_handler, fw_out_dir):
|
||||
print(f"[+] Extracted {len(found)} firmware blob(s) to {fw_out_dir}.")
|
||||
|
||||
|
||||
def flash_full(mtk, da_handler, args):
|
||||
def prompt_confirmed_password(label, required=False):
|
||||
"""Prompt securely via TTY for a password and confirmation."""
|
||||
while True:
|
||||
hint = "" if required else " (Enter to keep image default)"
|
||||
pw = getpass.getpass(f"Password for '{label}'{hint}: ")
|
||||
if not pw:
|
||||
if required:
|
||||
print("[!] Password cannot be empty.")
|
||||
continue
|
||||
return None
|
||||
if any(ch in pw for ch in ("\x00", "\n", "\r")):
|
||||
print("[!] Password must not contain NUL or newline characters.")
|
||||
continue
|
||||
pw2 = getpass.getpass(f"Confirm password for '{label}': ")
|
||||
if pw != pw2:
|
||||
print("[!] Passwords do not match; try again.")
|
||||
continue
|
||||
return pw
|
||||
|
||||
|
||||
def resolve_account_config(args, interactive=None):
|
||||
"""Resolve username and SHA-512 ($6$) hashes before connecting USB."""
|
||||
if args.user_password is not None and args.ask_user_password:
|
||||
raise ValueError("Cannot combine --user-password and --ask-user-password")
|
||||
if args.root_password is not None and args.ask_root_password:
|
||||
raise ValueError("Cannot combine --root-password and --ask-root-password")
|
||||
|
||||
is_tty = sys.stdin.isatty() if interactive is None else bool(interactive)
|
||||
prompt_interactive = is_tty and not args.use_default_credentials
|
||||
|
||||
username = args.username
|
||||
if username is not None:
|
||||
validate_username(username)
|
||||
elif prompt_interactive:
|
||||
while True:
|
||||
entered = input("Desktop username [user]: ").strip()
|
||||
if not entered:
|
||||
username = None
|
||||
break
|
||||
try:
|
||||
username = validate_username(entered)
|
||||
break
|
||||
except ValueError as exc:
|
||||
print(f"[!] {exc}")
|
||||
|
||||
eff_user = username or "user"
|
||||
|
||||
if args.user_password is not None:
|
||||
user_pw = args.user_password
|
||||
elif args.ask_user_password:
|
||||
user_pw = prompt_confirmed_password(eff_user, required=True)
|
||||
elif prompt_interactive:
|
||||
user_pw = prompt_confirmed_password(eff_user, required=False)
|
||||
else:
|
||||
user_pw = None
|
||||
|
||||
if args.root_password is not None:
|
||||
root_pw = args.root_password
|
||||
elif args.ask_root_password:
|
||||
root_pw = prompt_confirmed_password("root", required=True)
|
||||
elif prompt_interactive:
|
||||
root_pw = prompt_confirmed_password("root", required=False)
|
||||
else:
|
||||
root_pw = None
|
||||
|
||||
user_pw_hash = sha512_crypt(user_pw) if user_pw is not None else None
|
||||
root_pw_hash = sha512_crypt(root_pw) if root_pw is not None else None
|
||||
return AccountConfig(
|
||||
username=username,
|
||||
user_pw_hash=user_pw_hash,
|
||||
root_pw_hash=root_pw_hash,
|
||||
)
|
||||
|
||||
|
||||
def resolve_luks_config(args, interactive=None):
|
||||
"""Resolve optional LUKS2 encryption passphrase before connecting USB."""
|
||||
if args.luks_password is not None and args.ask_luks_password:
|
||||
raise ValueError("Cannot combine --luks-password and --ask-luks-password")
|
||||
|
||||
if args.luks_password is not None:
|
||||
validate_luks_passphrase(args.luks_password)
|
||||
return LuksConfig(enabled=True, passphrase=args.luks_password)
|
||||
|
||||
if args.ask_luks_password or args.encrypt:
|
||||
pw = prompt_confirmed_password("LUKS2 disk encryption", required=True)
|
||||
return LuksConfig(enabled=True, passphrase=pw)
|
||||
|
||||
is_tty = sys.stdin.isatty() if interactive is None else bool(interactive)
|
||||
if is_tty and not args.use_default_credentials and not args.customize_rootfs:
|
||||
while True:
|
||||
ans = input("Enable LUKS2 full-disk encryption? [y/N]: ").strip().lower()
|
||||
if ans in ("", "n", "no"):
|
||||
break
|
||||
if ans in ("y", "yes"):
|
||||
pw = prompt_confirmed_password("LUKS2 disk encryption", required=True)
|
||||
return LuksConfig(enabled=True, passphrase=pw)
|
||||
print("[!] Please answer 'y' or 'n'.")
|
||||
|
||||
return LuksConfig(enabled=False, passphrase=None)
|
||||
|
||||
|
||||
def copy_raw_image(src, dst):
|
||||
if shutil.which("cp"):
|
||||
subprocess.run(["cp", "--reflink=auto", "--sparse=always", src, dst], check=True)
|
||||
else:
|
||||
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."""
|
||||
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
|
||||
|
||||
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:
|
||||
return root_img
|
||||
|
||||
staged = os.path.join(tmp_dir, "linux.raw.img")
|
||||
if is_sparse:
|
||||
if shutil.which("simg2img") is None:
|
||||
raise RuntimeError("simg2img is required to unsparse geminux-rootfs.img")
|
||||
subprocess.run(["simg2img", root_img, staged], check=True)
|
||||
else:
|
||||
copy_raw_image(root_img, staged)
|
||||
|
||||
if has_changes:
|
||||
customize_ext4_accounts(
|
||||
staged,
|
||||
new_username=account_cfg.username,
|
||||
user_pw_hash=account_cfg.user_pw_hash,
|
||||
root_pw_hash=account_cfg.root_pw_hash,
|
||||
)
|
||||
summary = []
|
||||
if account_cfg.username:
|
||||
summary.append(f"username={account_cfg.username}")
|
||||
if account_cfg.user_pw_hash:
|
||||
summary.append("user password updated")
|
||||
if account_cfg.root_pw_hash:
|
||||
summary.append("root password updated")
|
||||
print(f"[+] Provisioned rootfs credentials ({', '.join(summary)}).")
|
||||
|
||||
if has_luks:
|
||||
print("[*] Encrypting staged rootfs image with LUKS2 (aes-xts-plain64, Argon2id)...")
|
||||
encrypt_ext4_image_luks2(staged, luks_cfg.passphrase)
|
||||
print("[+] LUKS2 full-disk encryption image verified.")
|
||||
|
||||
return staged
|
||||
|
||||
|
||||
def customize_rootfs_offline(args, account_cfg, luks_cfg=None):
|
||||
"""Write an offline customized (and optionally LUKS2-encrypted) rootfs copy."""
|
||||
root_img = os.path.join(args.images_dir, "geminux-rootfs.img")
|
||||
out_img = os.path.abspath(args.customize_rootfs)
|
||||
out_dir = os.path.dirname(out_img) or "."
|
||||
os.makedirs(out_dir, exist_ok=True)
|
||||
has_luks = bool(luks_cfg and luks_cfg.enabled)
|
||||
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
|
||||
)
|
||||
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)
|
||||
os.replace(staged, out_img)
|
||||
kind = "LUKS2-encrypted" if has_luks else "customized ext4"
|
||||
print(f"[+] Wrote {kind} rootfs image to {out_img}.")
|
||||
|
||||
|
||||
def flash_full(mtk, da_handler, args, account_cfg=None, luks_cfg=None):
|
||||
backup_dir = args.backup_dir
|
||||
if not args.skip_backup:
|
||||
run_backup(mtk, da_handler, backup_dir)
|
||||
@@ -344,22 +526,21 @@ def flash_full(mtk, da_handler, args):
|
||||
write_partition_checked(da_handler, "recovery", rec_img, verify=True)
|
||||
write_partition_checked(da_handler, "boot2", boot_img, verify=True)
|
||||
|
||||
# Convert sparse rootfs if needed before writing to 'linux'
|
||||
with open(root_img, "rb") as rf:
|
||||
is_sparse = rf.read(4) == SPARSE_MAGIC
|
||||
if is_sparse:
|
||||
if shutil.which("simg2img") is None:
|
||||
raise RuntimeError("simg2img is required to unsparse geminux-rootfs.img")
|
||||
with tempfile.TemporaryDirectory(prefix="geminux-rawroot-") as tmp:
|
||||
raw_root = os.path.join(tmp, "linux.raw.img")
|
||||
subprocess.run(["simg2img", root_img, raw_root], check=True)
|
||||
write_partition_checked(da_handler, "linux", raw_root, verify=False)
|
||||
else:
|
||||
write_partition_checked(da_handler, "linux", root_img, verify=False)
|
||||
with tempfile.TemporaryDirectory(prefix="geminux-stage-") as tmp:
|
||||
staged_root = stage_rootfs_image(root_img, account_cfg, tmp, luks_cfg=luks_cfg)
|
||||
write_partition_checked(da_handler, "linux", staged_root, verify=False)
|
||||
|
||||
print("[+] Full Geminux installation complete!")
|
||||
|
||||
|
||||
def flash_rootfs_only(da_handler, args, account_cfg=None, luks_cfg=None):
|
||||
root_img = os.path.join(args.images_dir, "geminux-rootfs.img")
|
||||
with tempfile.TemporaryDirectory(prefix="geminux-stage-") as tmp:
|
||||
staged_root = stage_rootfs_image(root_img, account_cfg, tmp, luks_cfg=luks_cfg)
|
||||
write_partition_checked(da_handler, "linux", staged_root, verify=False)
|
||||
print("[+] Geminux rootfs update complete!")
|
||||
|
||||
|
||||
def flash_kernel_only(da_handler, args):
|
||||
boot_img = os.path.join(args.images_dir, "boot-geminux.img")
|
||||
rec_img = os.path.join(args.images_dir, "recovery-geminux.img")
|
||||
@@ -424,6 +605,10 @@ def build_arg_parser():
|
||||
help="Extract MT6797 Wi-Fi/BT/SPM blobs from device 'system' or --system-img")
|
||||
mode.add_argument("--flash-kernel-only", action="store_true",
|
||||
help="Update only boot, boot2, and recovery images without touching GPT or linux")
|
||||
mode.add_argument("--flash-rootfs-only", action="store_true",
|
||||
help="Update only the linux rootfs partition without touching GPT or boot/recovery")
|
||||
mode.add_argument("--customize-rootfs", metavar="OUT_IMG",
|
||||
help="Offline: write customized geminux-rootfs.img to OUT_IMG without USB flashing")
|
||||
mode.add_argument("--restore-backup", metavar="DIR",
|
||||
help="Restore GPT and backed-up partitions from DIR")
|
||||
mode.add_argument("--reboot", action="store_true",
|
||||
@@ -431,6 +616,28 @@ def build_arg_parser():
|
||||
mode.add_argument("--poweroff", action="store_true",
|
||||
help="Connect to BROM/DA and cleanly power off out of DA mode")
|
||||
|
||||
creds = p.add_argument_group("Account & credential options")
|
||||
creds.add_argument("--username", metavar="USER",
|
||||
help="Desktop account username (UID 10000; default in image: user)")
|
||||
creds.add_argument("--user-password", metavar="PASS",
|
||||
help="Set desktop user password non-interactively")
|
||||
creds.add_argument("--ask-user-password", action="store_true",
|
||||
help="Prompt securely for desktop user password before flashing")
|
||||
creds.add_argument("--root-password", metavar="PASS",
|
||||
help="Set root password non-interactively")
|
||||
creds.add_argument("--ask-root-password", action="store_true",
|
||||
help="Prompt securely for root password before flashing")
|
||||
creds.add_argument("--use-default-credentials", action="store_true",
|
||||
help="Skip interactive credential prompts and keep image defaults")
|
||||
|
||||
enc = p.add_argument_group("Full-disk encryption options")
|
||||
enc.add_argument("--encrypt", action="store_true",
|
||||
help="Encrypt the linux rootfs partition with LUKS2 (aes-xts-plain64, Argon2id)")
|
||||
enc.add_argument("--luks-password", metavar="PASS",
|
||||
help="Set LUKS2 disk encryption passphrase non-interactively (implies --encrypt)")
|
||||
enc.add_argument("--ask-luks-password", action="store_true",
|
||||
help="Prompt securely for LUKS2 disk encryption passphrase (implies --encrypt)")
|
||||
|
||||
p.add_argument("--backup-dir", default=os.path.join(BASE_DIR, "backup", time.strftime("%Y%m%d-%H%M%S")),
|
||||
help="Directory for partition backups")
|
||||
p.add_argument("--images-dir", default=os.path.join(BASE_DIR, "images"),
|
||||
@@ -464,6 +671,28 @@ def main():
|
||||
return 1
|
||||
return 0
|
||||
|
||||
needs_rootfs_cfg = bool(
|
||||
args.customize_rootfs or
|
||||
args.flash_rootfs_only or
|
||||
not (
|
||||
args.extract_firmware or args.only_backup or args.flash_kernel_only or
|
||||
args.restore_backup or args.reboot or args.poweroff
|
||||
)
|
||||
)
|
||||
account_cfg = None
|
||||
luks_cfg = None
|
||||
if needs_rootfs_cfg:
|
||||
try:
|
||||
account_cfg = resolve_account_config(args)
|
||||
luks_cfg = resolve_luks_config(args)
|
||||
except ValueError as exc:
|
||||
print(f"[!] {exc}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
if args.customize_rootfs:
|
||||
customize_rootfs_offline(args, account_cfg, luks_cfg=luks_cfg)
|
||||
return 0
|
||||
|
||||
mtk, da_handler = connect_mtk(
|
||||
loader_path=args.da,
|
||||
preloader_path=args.preloader,
|
||||
@@ -495,13 +724,18 @@ def main():
|
||||
finish_da_session(mtk, reboot=not args.no_reboot)
|
||||
print("[+] Powered off out of DA mode." if args.no_reboot else "[+] Triggering device reboot...")
|
||||
finished = True
|
||||
elif args.flash_rootfs_only:
|
||||
flash_rootfs_only(da_handler, args, account_cfg=account_cfg, luks_cfg=luks_cfg)
|
||||
finish_da_session(mtk, reboot=not args.no_reboot)
|
||||
print("[+] Powered off out of DA mode." if args.no_reboot else "[+] Triggering device reboot...")
|
||||
finished = True
|
||||
elif args.restore_backup:
|
||||
restore_backup(mtk, da_handler, args.restore_backup)
|
||||
finish_da_session(mtk, reboot=not args.no_reboot)
|
||||
print("[+] Powered off out of DA mode." if args.no_reboot else "[+] Triggering device reboot...")
|
||||
finished = True
|
||||
else:
|
||||
flash_full(mtk, da_handler, args)
|
||||
flash_full(mtk, da_handler, args, account_cfg=account_cfg, luks_cfg=luks_cfg)
|
||||
finish_da_session(mtk, reboot=not args.no_reboot)
|
||||
print("[+] Powered off out of DA mode." if args.no_reboot else "[+] Triggering device reboot...")
|
||||
finished = True
|
||||
|
||||
+17
-3
@@ -19,11 +19,25 @@ if ! "$PYTHON_BIN" -c 'import usb.core, serial, Crypto, colorama' >/dev/null 2>&
|
||||
export PYTHONPATH
|
||||
fi
|
||||
|
||||
OFFLINE_OP=0
|
||||
HAS_EXTRACT=0
|
||||
HAS_SYSIMG=0
|
||||
for arg in "$@"; do
|
||||
if [ "$arg" = "-h" ] || [ "$arg" = "--help" ]; then
|
||||
exec "$PYTHON_BIN" "$FLASHER_PY" "$@"
|
||||
fi
|
||||
case "$arg" in
|
||||
-h|--help|--customize-rootfs|--customize-rootfs=*)
|
||||
OFFLINE_OP=1
|
||||
;;
|
||||
--extract-firmware)
|
||||
HAS_EXTRACT=1
|
||||
;;
|
||||
--system-img|--system-img=*)
|
||||
HAS_SYSIMG=1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [ "$OFFLINE_OP" -eq 1 ] || { [ "$HAS_EXTRACT" -eq 1 ] && [ "$HAS_SYSIMG" -eq 1 ]; }; then
|
||||
exec "$PYTHON_BIN" "$FLASHER_PY" "$@"
|
||||
fi
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
|
||||
@@ -154,7 +154,7 @@ CONFIG_PERF_EVENTS=y
|
||||
CONFIG_SCSI=y
|
||||
# CONFIG_ATA is not set
|
||||
# CONFIG_MTD is not set
|
||||
# CONFIG_MD is not set
|
||||
CONFIG_MD=y
|
||||
CONFIG_NET=y
|
||||
# CONFIG_PCI is not set
|
||||
CONFIG_MMC=y
|
||||
@@ -944,3 +944,18 @@ CONFIG_PPP_DEFLATE=m
|
||||
CONFIG_PPP_BSDCOMP=m
|
||||
CONFIG_TUN=m
|
||||
CONFIG_WIREGUARD=m
|
||||
|
||||
# Full-disk encryption (Device Mapper + dm-crypt LUKS2 + ARMv8 AES-CE XTS)
|
||||
CONFIG_MD=y
|
||||
# CONFIG_BLK_DEV_MD is not set
|
||||
CONFIG_BLK_DEV_DM=y
|
||||
CONFIG_DM_CRYPT=y
|
||||
CONFIG_CRYPTO_ESSIV=y
|
||||
CONFIG_CRYPTO_XTS=y
|
||||
CONFIG_CRYPTO_SHA256=y
|
||||
CONFIG_CRYPTO_SHA512=y
|
||||
CONFIG_CRYPTO_USER_API=y
|
||||
CONFIG_CRYPTO_USER_API_HASH=y
|
||||
CONFIG_CRYPTO_USER_API_SKCIPHER=y
|
||||
CONFIG_CRYPTO_USER_API_RNG=y
|
||||
CONFIG_CRYPTO_USER_API_AEAD=y
|
||||
@@ -1,12 +1,38 @@
|
||||
# Geminux Linux VT console keymap for Gemini PDA US physical keyboard
|
||||
# Matches X11 layout: Left Meta (Fn, keycode 125) = AltGr, Fn+1..0 = F1..F10,
|
||||
# Complete standalone map (safe for both loadkeys and loadkeys -b -> busybox loadkmap).
|
||||
# Left Meta (Fn, keycode 125) = AltGr, Fn+1..0 = F1..F10,
|
||||
# Shift+Fn+1..0 = ~ ` £ € < > [ ] { }
|
||||
keymaps 0-6,8-9,12
|
||||
alt_is_meta
|
||||
include "qwerty-layout"
|
||||
include "linux-with-alt-and-altgr"
|
||||
strings as usual
|
||||
|
||||
keycode 125 = AltGr
|
||||
keycode 1 = Escape
|
||||
keycode 12 = minus underscore
|
||||
keycode 13 = equal plus
|
||||
keycode 14 = BackSpace Delete
|
||||
shift keycode 14 = Delete
|
||||
keycode 15 = Tab Tab
|
||||
altgr keycode 15 = Caps_Lock
|
||||
keycode 26 = bracketleft braceleft
|
||||
keycode 27 = bracketright braceright
|
||||
keycode 28 = Return
|
||||
alt keycode 28 = Meta_Control_m
|
||||
keycode 29 = Control
|
||||
keycode 39 = semicolon colon
|
||||
keycode 41 = grave asciitilde
|
||||
keycode 42 = Shift
|
||||
keycode 43 = backslash bar
|
||||
keycode 53 = slash question
|
||||
keycode 54 = Shift
|
||||
keycode 56 = Alt
|
||||
keycode 57 = space
|
||||
control keycode 57 = nul
|
||||
keycode 58 = Caps_Lock
|
||||
keycode 86 = less greater bar
|
||||
keycode 97 = Control
|
||||
keycode 125 = AltGr
|
||||
|
||||
keycode 2 = one exclam F1 asciitilde
|
||||
altgr keycode 2 = F1
|
||||
@@ -39,10 +65,6 @@ keycode 11 = zero parenright F10 braceright
|
||||
altgr keycode 11 = F10
|
||||
shift altgr keycode 11 = braceright
|
||||
|
||||
keycode 14 = BackSpace Delete
|
||||
shift keycode 14 = Delete
|
||||
keycode 15 = Tab Tab
|
||||
altgr keycode 15 = Caps_Lock
|
||||
keycode 23 = i I plus plusminus
|
||||
altgr keycode 23 = plus
|
||||
keycode 24 = o O minus
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -298,6 +298,7 @@ CONFIG_KEXEC_CORE=y
|
||||
CONFIG_KEXEC_FILE=y
|
||||
# CONFIG_KEXEC_SIG is not set
|
||||
CONFIG_CRASH_DUMP=y
|
||||
# CONFIG_CRASH_DM_CRYPT is not set
|
||||
# end of Kexec and crash features
|
||||
|
||||
#
|
||||
@@ -875,6 +876,8 @@ CONFIG_EFI_PARTITION=y
|
||||
# end of Partition Types
|
||||
|
||||
CONFIG_BLK_PM=y
|
||||
CONFIG_BLOCK_HOLDER_DEPRECATED=y
|
||||
CONFIG_BLK_MQ_STACKING=y
|
||||
# CONFIG_BLK_ERROR_INJECTION is not set
|
||||
|
||||
#
|
||||
@@ -1772,7 +1775,37 @@ CONFIG_SCSI_LOWLEVEL=y
|
||||
# end of SCSI device support
|
||||
|
||||
# CONFIG_ATA is not set
|
||||
# CONFIG_MD is not set
|
||||
CONFIG_MD=y
|
||||
# CONFIG_BLK_DEV_MD is not set
|
||||
# CONFIG_BCACHE is not set
|
||||
CONFIG_BLK_DEV_DM_BUILTIN=y
|
||||
CONFIG_BLK_DEV_DM=y
|
||||
# CONFIG_DM_DEBUG is not set
|
||||
# CONFIG_DM_UNSTRIPED is not set
|
||||
CONFIG_DM_CRYPT=y
|
||||
# CONFIG_DM_INLINECRYPT is not set
|
||||
# CONFIG_DM_SNAPSHOT is not set
|
||||
# CONFIG_DM_THIN_PROVISIONING is not set
|
||||
# CONFIG_DM_CACHE is not set
|
||||
# CONFIG_DM_WRITECACHE is not set
|
||||
# CONFIG_DM_EBS is not set
|
||||
# CONFIG_DM_ERA is not set
|
||||
# CONFIG_DM_CLONE is not set
|
||||
CONFIG_DM_MIRROR=m
|
||||
# CONFIG_DM_LOG_USERSPACE is not set
|
||||
# CONFIG_DM_RAID is not set
|
||||
CONFIG_DM_ZERO=m
|
||||
# CONFIG_DM_MULTIPATH is not set
|
||||
# CONFIG_DM_DELAY is not set
|
||||
# CONFIG_DM_DUST is not set
|
||||
# CONFIG_DM_INIT is not set
|
||||
# CONFIG_DM_UEVENT is not set
|
||||
# CONFIG_DM_FLAKEY is not set
|
||||
# CONFIG_DM_VERITY is not set
|
||||
# CONFIG_DM_SWITCH is not set
|
||||
# CONFIG_DM_LOG_WRITES is not set
|
||||
# CONFIG_DM_INTEGRITY is not set
|
||||
# CONFIG_DM_VDO is not set
|
||||
# CONFIG_TARGET_CORE is not set
|
||||
CONFIG_NETDEVICES=y
|
||||
CONFIG_MII=m
|
||||
@@ -6544,8 +6577,8 @@ CONFIG_CRYPTO_SKCIPHER=y
|
||||
CONFIG_CRYPTO_SKCIPHER2=y
|
||||
CONFIG_CRYPTO_HASH=y
|
||||
CONFIG_CRYPTO_HASH2=y
|
||||
CONFIG_CRYPTO_RNG=m
|
||||
CONFIG_CRYPTO_RNG2=m
|
||||
CONFIG_CRYPTO_RNG=y
|
||||
CONFIG_CRYPTO_RNG2=y
|
||||
CONFIG_CRYPTO_AKCIPHER2=y
|
||||
CONFIG_CRYPTO_AKCIPHER=y
|
||||
CONFIG_CRYPTO_KPP2=y
|
||||
@@ -6621,7 +6654,7 @@ CONFIG_CRYPTO_GCM=y
|
||||
CONFIG_CRYPTO_GENIV=y
|
||||
# CONFIG_CRYPTO_SEQIV is not set
|
||||
CONFIG_CRYPTO_ECHAINIV=y
|
||||
# CONFIG_CRYPTO_ESSIV is not set
|
||||
CONFIG_CRYPTO_ESSIV=y
|
||||
# end of AEAD (authenticated encryption with associated data) ciphers
|
||||
|
||||
#
|
||||
@@ -6676,8 +6709,8 @@ CONFIG_CRYPTO_KDF800108_CTR=y
|
||||
CONFIG_CRYPTO_USER_API=y
|
||||
CONFIG_CRYPTO_USER_API_HASH=y
|
||||
CONFIG_CRYPTO_USER_API_SKCIPHER=y
|
||||
CONFIG_CRYPTO_USER_API_RNG=m
|
||||
CONFIG_CRYPTO_USER_API_AEAD=m
|
||||
CONFIG_CRYPTO_USER_API_RNG=y
|
||||
CONFIG_CRYPTO_USER_API_AEAD=y
|
||||
CONFIG_CRYPTO_USER_API_ENABLE_OBSOLETE=y
|
||||
# end of Userspace interface (deprecated)
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -69,11 +69,15 @@ kernel/crypto/krb5enc.ko
|
||||
kernel/crypto/lzo.ko
|
||||
kernel/crypto/lzo-rle.ko
|
||||
kernel/crypto/lz4.ko
|
||||
kernel/crypto/rng.ko
|
||||
kernel/crypto/af_alg.ko
|
||||
kernel/crypto/algif_hash.ko
|
||||
kernel/crypto/algif_skcipher.ko
|
||||
kernel/crypto/algif_rng.ko
|
||||
kernel/crypto/algif_aead.ko
|
||||
kernel/crypto/zstd.ko
|
||||
kernel/crypto/ecc.ko
|
||||
kernel/crypto/essiv.ko
|
||||
kernel/crypto/ecdh_generic.ko
|
||||
kernel/crypto/asymmetric_keys/public_key.ko
|
||||
kernel/crypto/asymmetric_keys/x509_key_parser.ko
|
||||
@@ -502,6 +506,8 @@ kernel/drivers/watchdog/mtk_wdt.ko
|
||||
kernel/drivers/watchdog/arm_smc_wdt.ko
|
||||
kernel/drivers/watchdog/of_xilinx_wdt.ko
|
||||
kernel/drivers/watchdog/xilinx_wwdt.ko
|
||||
kernel/drivers/md/dm-mod.ko
|
||||
kernel/drivers/md/dm-crypt.ko
|
||||
kernel/drivers/edac/edac_core.ko
|
||||
kernel/drivers/cpufreq/cpufreq_performance.ko
|
||||
kernel/drivers/cpufreq/cpufreq_powersave.ko
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,8 +1,5 @@
|
||||
kernel/fs/exfat/exfat.ko.zst:
|
||||
kernel/crypto/rng.ko.zst:
|
||||
kernel/crypto/tcrypt.ko.zst:
|
||||
kernel/crypto/algif_rng.ko.zst: kernel/crypto/rng.ko.zst
|
||||
kernel/crypto/algif_aead.ko.zst:
|
||||
kernel/lib/crc/crc8.ko.zst:
|
||||
kernel/lib/crc/crc-itu-t.ko.zst:
|
||||
kernel/lib/crypto/libchacha20poly1305.ko.zst: kernel/lib/crypto/libpoly1305.ko.zst
|
||||
@@ -213,6 +210,10 @@ kernel/drivers/media/v4l2-core/videodev.ko.zst: kernel/drivers/media/mc/mc.ko.zs
|
||||
kernel/drivers/media/cec/core/cec.ko.zst:
|
||||
kernel/drivers/media/radio/radio-mt6797.ko.zst: kernel/drivers/media/v4l2-core/videodev.ko.zst kernel/drivers/media/mc/mc.ko.zst kernel/drivers/soc/mediatek/mt6797-consys.ko.zst kernel/drivers/net/wireless/mediatek/mt6797/mt6797-wlan-core.ko.zst
|
||||
kernel/drivers/hwmon/sht4x.ko.zst: kernel/lib/crc/crc8.ko.zst
|
||||
kernel/drivers/md/dm-mirror.ko.zst: kernel/drivers/md/dm-region-hash.ko.zst kernel/drivers/md/dm-log.ko.zst
|
||||
kernel/drivers/md/dm-log.ko.zst:
|
||||
kernel/drivers/md/dm-region-hash.ko.zst: kernel/drivers/md/dm-log.ko.zst
|
||||
kernel/drivers/md/dm-zero.ko.zst:
|
||||
kernel/drivers/cpufreq/cpufreq_conservative.ko.zst:
|
||||
kernel/drivers/cpufreq/battery-headroom.ko.zst:
|
||||
kernel/drivers/cpufreq/cpufreq-dt.ko.zst:
|
||||
|
||||
Binary file not shown.
@@ -1,8 +1,5 @@
|
||||
kernel/fs/exfat/exfat.ko
|
||||
kernel/crypto/rng.ko
|
||||
kernel/crypto/tcrypt.ko
|
||||
kernel/crypto/algif_rng.ko
|
||||
kernel/crypto/algif_aead.ko
|
||||
kernel/lib/crc/crc8.ko
|
||||
kernel/lib/crc/crc-itu-t.ko
|
||||
kernel/lib/crypto/libchacha20poly1305.ko
|
||||
@@ -213,6 +210,10 @@ kernel/drivers/media/v4l2-core/videodev.ko
|
||||
kernel/drivers/media/cec/core/cec.ko
|
||||
kernel/drivers/media/radio/radio-mt6797.ko
|
||||
kernel/drivers/hwmon/sht4x.ko
|
||||
kernel/drivers/md/dm-mirror.ko
|
||||
kernel/drivers/md/dm-log.ko
|
||||
kernel/drivers/md/dm-region-hash.ko
|
||||
kernel/drivers/md/dm-zero.ko
|
||||
kernel/drivers/cpufreq/cpufreq_conservative.ko
|
||||
kernel/drivers/cpufreq/battery-headroom.ko
|
||||
kernel/drivers/cpufreq/cpufreq-dt.ko
|
||||
|
||||
@@ -59,7 +59,6 @@ alias symbol:snd_soc_add_pcm_runtimes snd_soc_core
|
||||
alias symbol:snd_rawmidi_free snd_rawmidi
|
||||
alias symbol:snd_refcount_sync snd
|
||||
alias symbol:cec_transmit_msg cec
|
||||
alias symbol:crypto_unregister_rngs rng
|
||||
alias symbol:mt6797_hif_free mt6797_wlan_core
|
||||
alias symbol:drm_dp_atomic_find_time_slots drm_display_helper
|
||||
alias symbol:media_entity_enum_cleanup mc
|
||||
@@ -104,7 +103,6 @@ alias symbol:v4l2_fh_init videodev
|
||||
alias symbol:__phy_write_mmd libphy
|
||||
alias symbol:graph_util_card_probe snd_soc_simple_card_utils
|
||||
alias symbol:tcpci_register_port tcpci
|
||||
alias symbol:crypto_register_rng rng
|
||||
alias symbol:snd_timer_pause snd_timer
|
||||
alias symbol:media_graph_walk_init mc
|
||||
alias symbol:snd_soc_find_dai_with_mutex snd_soc_core
|
||||
@@ -219,6 +217,7 @@ alias symbol:fsl_asrc_m2m_init snd_soc_fsl_asrc
|
||||
alias symbol:__nf_conntrack_confirm nf_conntrack
|
||||
alias symbol:devm_snd_soc_register_card snd_soc_core
|
||||
alias symbol:v4l2_ctrl_handler_log_status videodev
|
||||
alias symbol:dm_rh_dec dm_region_hash
|
||||
alias symbol:mdiobus_modify_changed mdio_bus
|
||||
alias symbol:v4l2_get_link_freq videodev
|
||||
alias symbol:snd_pcm_fill_iec958_consumer_hw_params snd_pcm
|
||||
@@ -294,6 +293,7 @@ alias symbol:sdw_rows soundwire_bus
|
||||
alias symbol:btintel_regmap_init btintel
|
||||
alias symbol:mdio_driver_register libphy
|
||||
alias symbol:phy_get_pause libphy
|
||||
alias symbol:dm_rh_recovery_prepare dm_region_hash
|
||||
alias symbol:snd_card_register snd
|
||||
alias symbol:fwnode_get_phy_node libphy
|
||||
alias symbol:of_mdiobus_child_is_phy of_mdio
|
||||
@@ -500,6 +500,7 @@ alias symbol:phy_link_topo_del_phy libphy
|
||||
alias symbol:xhci_init_driver xhci_hcd
|
||||
alias symbol:bt_sock_recvmsg bluetooth
|
||||
alias symbol:snd_ctl_disconnect_layer snd
|
||||
alias symbol:dm_rh_dirty_log dm_region_hash
|
||||
alias symbol:snd_soc_component_set_pll snd_soc_core
|
||||
alias symbol:gen10g_config_aneg libphy
|
||||
alias symbol:lpass_macro_get_codec_version snd_soc_lpass_macro_common
|
||||
@@ -510,6 +511,7 @@ alias symbol:snd_soc_put_volsw_sx snd_soc_core
|
||||
alias symbol:xhci_update_hub_device xhci_hcd
|
||||
alias symbol:snd_soc_daifmt_clock_provider_from_bitmap snd_soc_core
|
||||
alias symbol:vb2_querybuf videobuf2_v4l2
|
||||
alias symbol:dm_dirty_log_type_unregister dm_log
|
||||
alias symbol:fsl_asoc_get_dma_channel snd_soc_fsl_utils
|
||||
alias symbol:mdiobus_is_registered_device mdio_bus
|
||||
alias symbol:snd_soc_of_parse_aux_devs snd_soc_core
|
||||
@@ -596,15 +598,16 @@ alias symbol:drm_dp_downstream_420_passthrough drm_display_helper
|
||||
alias symbol:v4l2_fwnode_connector_parse v4l2_fwnode
|
||||
alias symbol:xhci_sideband_create_interrupter xhci_hcd
|
||||
alias symbol:__phy_resume libphy
|
||||
alias symbol:dm_rh_get_region_key dm_region_hash
|
||||
alias symbol:iio_kfifo_allocate kfifo_buf
|
||||
alias symbol:mtk_mmsys_ddp_connect mtk_mmsys
|
||||
alias symbol:drm_dp_mst_topology_state_funcs drm_display_helper
|
||||
alias symbol:dm_dirty_log_type_register dm_log
|
||||
alias symbol:mt6797_wlan_firmware_release mt6797_wlan_core
|
||||
alias symbol:nf_ct_helper_expectfn_find_by_symbol nf_conntrack
|
||||
alias symbol:sdw_stream_remove_master soundwire_bus
|
||||
alias symbol:genphy_aneg_done libphy
|
||||
alias symbol:__sdw_register_driver soundwire_bus
|
||||
alias symbol:crypto_unregister_rng rng
|
||||
alias symbol:iio_triggered_buffer_cleanup industrialio_triggered_buffer
|
||||
alias symbol:v4l2_m2m_dqbuf v4l2_mem2mem
|
||||
alias symbol:v4l2_vp9_kf_partition_probs v4l2_vp9
|
||||
@@ -626,6 +629,7 @@ alias symbol:snd_soc_dai_set_tdm_idle snd_soc_core
|
||||
alias symbol:mtk_sof_card_late_probe snd_soc_mtk_common
|
||||
alias symbol:usb_serial_generic_write usbserial
|
||||
alias symbol:drm_dp_128b132b_lane_channel_eq_done drm_display_helper
|
||||
alias symbol:dm_rh_region_context dm_region_hash
|
||||
alias symbol:genphy_write_mmd_unsupported libphy
|
||||
alias symbol:snd_compr_task_finished snd_compress
|
||||
alias symbol:__v4l2_ctrl_s_ctrl_int64 videodev
|
||||
@@ -835,7 +839,6 @@ alias symbol:v4l2_detect_cvt v4l2_dv_timings
|
||||
alias symbol:phy_10gbit_features libphy
|
||||
alias symbol:cec_allocate_adapter cec
|
||||
alias symbol:drm_dp_dpcd_poll_act_handled drm_display_helper
|
||||
alias symbol:crypto_del_default_rng rng
|
||||
alias symbol:tcpm_pd_receive tcpm
|
||||
alias symbol:mt6797_hif_set_data_bw40 mt6797_wlan_core
|
||||
alias symbol:snd_soc_component_alloc snd_soc_core
|
||||
@@ -1043,6 +1046,7 @@ alias symbol:vb2_core_querybuf videobuf2_common
|
||||
alias symbol:mt6797_hif_power_off mt6797_wlan_core
|
||||
alias symbol:sdw_read soundwire_bus
|
||||
alias symbol:xt_copy_counters x_tables
|
||||
alias symbol:dm_rh_get_state dm_region_hash
|
||||
alias symbol:oa_1000bt1_get_tdr_distance libphy
|
||||
alias symbol:snd_soc_dai_compr_trigger snd_soc_core
|
||||
alias symbol:drm_atomic_helper_connector_hdmi_hotplug drm_display_helper
|
||||
@@ -1214,6 +1218,7 @@ alias symbol:usbnet_probe usbnet
|
||||
alias symbol:snd_card_free_on_error snd
|
||||
alias symbol:v4l2_ctrl_handler_init_class videodev
|
||||
alias symbol:__media_remove_intf_link mc
|
||||
alias symbol:dm_rh_recovery_end dm_region_hash
|
||||
alias symbol:hci_set_hw_info bluetooth
|
||||
alias symbol:v4l2_subdev_call_wrappers videodev
|
||||
alias symbol:usbnet_set_link_ksettings_mii usbnet
|
||||
@@ -1463,6 +1468,7 @@ alias symbol:cros_ec_sensors_core_read_avail cros_ec_sensors_core
|
||||
alias symbol:drm_gem_dma_create drm_dma_helper
|
||||
alias symbol:drm_sched_entity_error gpu_sched
|
||||
alias symbol:usbnet_change_mtu usbnet
|
||||
alias symbol:dm_region_hash_destroy dm_region_hash
|
||||
alias symbol:drm_dp_lttpr_max_lane_count drm_display_helper
|
||||
alias symbol:snd_soc_of_parse_node_prefix snd_soc_core
|
||||
alias symbol:cdc_ncm_tx_fixup cdc_ncm
|
||||
@@ -1624,6 +1630,7 @@ alias symbol:nft_meta_get_dump nf_tables
|
||||
alias symbol:snd_soc_component_set_priv snd_soc_core
|
||||
alias symbol:rt5640_set_ovcd_params snd_soc_rt5640
|
||||
alias symbol:__mdiobus_modify mdio_bus
|
||||
alias symbol:dm_region_hash_create dm_region_hash
|
||||
alias symbol:drm_gem_dma_dumb_create drm_dma_helper
|
||||
alias symbol:nf_ct_deliver_cached_events nf_conntrack
|
||||
alias symbol:phy_caps_from_interface libphy
|
||||
@@ -1638,6 +1645,7 @@ alias symbol:rt5682_reset snd_soc_rt5682
|
||||
alias symbol:tun_ptr_free tun
|
||||
alias symbol:usbnet_link_change usbnet
|
||||
alias symbol:usb_serial_generic_open usbserial
|
||||
alias symbol:dm_rh_stop_recovery dm_region_hash
|
||||
alias symbol:snd_soc_dai_prepare snd_soc_core
|
||||
alias symbol:nf_nat_masquerade_inet_unregister_notifiers nf_nat
|
||||
alias symbol:rt5640_enable_micbias1_for_ovcd snd_soc_rt5640
|
||||
@@ -1646,6 +1654,7 @@ alias symbol:drm_dp_set_phy_test_pattern drm_display_helper
|
||||
alias symbol:phylink_start phylink
|
||||
alias symbol:nf_reject_skb_v4_unreach nf_reject_ipv4
|
||||
alias symbol:slhc_init slhc
|
||||
alias symbol:dm_rh_recovery_in_flight dm_region_hash
|
||||
alias symbol:btintel_load_ddc_config btintel
|
||||
alias symbol:mtk_memif_set_disable snd_soc_mtk_common
|
||||
alias symbol:mt8183_dai_i2s_set_share snd_soc_mt8183_afe
|
||||
@@ -1666,6 +1675,7 @@ alias symbol:vb2_core_qbuf videobuf2_common
|
||||
alias symbol:phy_gbit_features libphy
|
||||
alias symbol:snd_unregister_device snd
|
||||
alias symbol:v4l2_fwnode_put_link v4l2_fwnode
|
||||
alias symbol:dm_rh_flush dm_region_hash
|
||||
alias symbol:genphy_c45_read_status libphy
|
||||
alias symbol:xt_check_hooks_target x_tables
|
||||
alias symbol:rt5682s_sel_asrc_clk_src snd_soc_rt5682s
|
||||
@@ -1725,6 +1735,7 @@ alias symbol:bt_procfs_init bluetooth
|
||||
alias symbol:nft_unregister_obj nf_tables
|
||||
alias symbol:genphy_read_lpa libphy
|
||||
alias symbol:snd_soc_register_component_c snd_soc_core
|
||||
alias symbol:dm_rh_recovery_start dm_region_hash
|
||||
alias symbol:of_dp_aux_populate_bus drm_dp_aux_bus
|
||||
alias symbol:at803x_read_specific_status qcom_phy_lib
|
||||
alias symbol:devm_phy_package_join phy_package
|
||||
@@ -1863,6 +1874,7 @@ alias symbol:drm_dp_mst_edid_read drm_display_helper
|
||||
alias symbol:nf_conntrack_count nf_conntrack
|
||||
alias symbol:drm_dp_lttpr_max_link_rate drm_display_helper
|
||||
alias symbol:l2cap_chan_list bluetooth
|
||||
alias symbol:dm_rh_delay dm_region_hash
|
||||
alias symbol:pcm3168a_probe snd_soc_pcm3168a
|
||||
alias symbol:phy_caps_linkmodes libphy
|
||||
alias symbol:phylink_stop phylink
|
||||
@@ -1878,7 +1890,6 @@ alias symbol:mdio_driver_unregister libphy
|
||||
alias symbol:usb_stor_pre_reset usb_storage
|
||||
alias symbol:bcm_phy_config_intr bcm_phy_lib
|
||||
alias symbol:snd_soc_put_strobe snd_soc_core
|
||||
alias symbol:crypto_alloc_rng rng
|
||||
alias symbol:drm_dp_psr_setup_time drm_display_helper
|
||||
alias symbol:xt_register_target x_tables
|
||||
alias symbol:nf_nat_masquerade_ipv4 nf_nat
|
||||
@@ -1904,6 +1915,7 @@ alias symbol:nf_ct_netns_put nf_conntrack
|
||||
alias symbol:snd_compr_stop_error snd_compress
|
||||
alias symbol:of_phy_package_join phy_package
|
||||
alias symbol:usbnet_cdc_bind cdc_ether
|
||||
alias symbol:dm_dirty_log_destroy dm_log
|
||||
alias symbol:snd_pcm_format_set_silence snd_pcm
|
||||
alias symbol:nf_defrag_ipv6_disable nf_defrag_ipv6
|
||||
alias symbol:nf_conntrack_helpers_register nf_conntrack
|
||||
@@ -2052,7 +2064,6 @@ alias symbol:drm_dp_mst_get_edid drm_display_helper
|
||||
alias symbol:rt5640_disable_micbias1_for_ovcd snd_soc_rt5640
|
||||
alias symbol:phy_stop libphy
|
||||
alias symbol:cdc_ncm_rx_verify_nth16 cdc_ncm
|
||||
alias symbol:crypto_rng_reset rng
|
||||
alias symbol:lpass_macro_pds_init snd_soc_lpass_macro_common
|
||||
alias symbol:at803x_handle_interrupt qcom_phy_lib
|
||||
alias symbol:btintel_version_info btintel
|
||||
@@ -2195,6 +2206,7 @@ alias symbol:fsl_asrc_m2m_resume snd_soc_fsl_asrc
|
||||
alias symbol:phy_package_init_once phy_package
|
||||
alias symbol:snd_card_new snd
|
||||
alias symbol:v4l2_ctrl_handler_free videodev
|
||||
alias symbol:dm_dirty_log_create dm_log
|
||||
alias symbol:xhci_port_state_to_neutral xhci_hcd
|
||||
alias symbol:qca808x_led_reg_hw_control_status qcom_phy_lib
|
||||
alias symbol:snd_pcm_runtime_buffer_set_silence snd_pcm
|
||||
@@ -2243,7 +2255,6 @@ alias symbol:st_sensors_init_sensor st_sensors
|
||||
alias symbol:udp_tunnel_notify_del_rx_port udp_tunnel
|
||||
alias symbol:snd_ctl_find_numid snd
|
||||
alias symbol:chacha20poly1305_encrypt libchacha20poly1305
|
||||
alias symbol:crypto_register_rngs rng
|
||||
alias symbol:qca808x_led_reg_hw_control_enable qcom_phy_lib
|
||||
alias symbol:__devm_regmap_init_spmi_ext regmap_spmi
|
||||
alias symbol:nft_hook_find_ops nf_tables
|
||||
@@ -2308,6 +2319,7 @@ alias symbol:panfrost_pm_ops panfrost
|
||||
alias symbol:xhci_get_endpoint_index xhci_hcd
|
||||
alias symbol:snd_usbmidi_input_start snd_usbmidi_lib
|
||||
alias symbol:bmi160_core_pm_ops bmi160_core
|
||||
alias symbol:dm_rh_mark_nosync dm_region_hash
|
||||
alias symbol:drm_dp_dump_lttpr_desc drm_display_helper
|
||||
alias symbol:bt_sock_wait_state bluetooth
|
||||
alias symbol:mt6797_hif_join_station mt6797_wlan_core
|
||||
@@ -2323,6 +2335,7 @@ alias symbol:drm_dp_mst_root_conn_atomic_check drm_display_helper
|
||||
alias symbol:drm_sched_job_is_signaled gpu_sched
|
||||
alias symbol:ip_tunnel_parm_to_user ip_tunnel
|
||||
alias symbol:v4l2_ctrl_subdev_subscribe_event videodev
|
||||
alias symbol:dm_rh_get_region_size dm_region_hash
|
||||
alias symbol:dp_altmode_remove typec_displayport
|
||||
alias symbol:nft_register_flowtable_type nf_tables
|
||||
alias symbol:__tracepoint_vb2_qbuf videobuf2_common
|
||||
@@ -2393,7 +2406,6 @@ alias symbol:macvlan_link_register macvlan
|
||||
alias symbol:rl6231_calc_dmic_clk snd_soc_rl6231
|
||||
alias symbol:snd_soc_card_set_topology_name snd_soc_core
|
||||
alias symbol:tuners tuner_types
|
||||
alias symbol:__crypto_stdrng_get_bytes rng
|
||||
alias symbol:video_ioctl2 videodev
|
||||
alias symbol:fsl_asoc_get_enum_double snd_soc_fsl_utils
|
||||
alias symbol:snd_pcm_lib_free_pages snd_pcm
|
||||
@@ -2402,12 +2414,14 @@ alias symbol:v4l2_m2m_resume v4l2_mem2mem
|
||||
alias symbol:bcm_phy_write_shadow bcm_phy_lib
|
||||
alias symbol:generic_rndis_bind rndis_host
|
||||
alias symbol:simple_tuner_attach tuner_simple
|
||||
alias symbol:dm_rh_start_recovery dm_region_hash
|
||||
alias symbol:snd_rawmidi_new snd_rawmidi
|
||||
alias symbol:ip_tunnel_get_iflink ip_tunnel
|
||||
alias symbol:phy_request_interrupt libphy
|
||||
alias symbol:snd_soc_component_compr_ack snd_soc_core
|
||||
alias symbol:mmd_phy_read libphy
|
||||
alias symbol:snd_pcm_hw_param_first snd_pcm
|
||||
alias symbol:dm_rh_region_to_sector dm_region_hash
|
||||
alias symbol:nf_tables_deactivate_flowtable nf_tables
|
||||
alias symbol:vb2_core_poll videobuf2_common
|
||||
alias symbol:mtk_mmsys_hdr_config mtk_mmsys
|
||||
@@ -2430,6 +2444,7 @@ alias symbol:ip_tunnel_dellink ip_tunnel
|
||||
alias symbol:drm_dp_read_sink_count drm_display_helper
|
||||
alias symbol:v4l2_prio_open videodev
|
||||
alias symbol:xt_proto_fini x_tables
|
||||
alias symbol:dm_rh_bio_to_region dm_region_hash
|
||||
alias symbol:drm_dp_bw_code_to_link_rate drm_display_helper
|
||||
alias symbol:mdio_device_create libphy
|
||||
alias symbol:snd_jack_set_key snd
|
||||
@@ -2547,6 +2562,7 @@ alias symbol:at803x_get_tunable qcom_phy_lib
|
||||
alias symbol:ip_vs_conn_out_get ip_vs
|
||||
alias symbol:snd_soc_dai_set_clkdiv snd_soc_core
|
||||
alias symbol:snd_soc_dapm_to_dev snd_soc_core
|
||||
alias symbol:dm_rh_inc_pending dm_region_hash
|
||||
alias symbol:media_create_pad_link mc
|
||||
alias symbol:v4l2_m2m_streamoff v4l2_mem2mem
|
||||
alias symbol:qcom_adc5_prescaling_from_dt qcom_vadc_common
|
||||
@@ -2559,6 +2575,7 @@ alias symbol:v4l2_ctrl_request_complete videodev
|
||||
alias symbol:phy_disable_eee libphy
|
||||
alias symbol:snd_soc_component_read_field snd_soc_core
|
||||
alias symbol:bt_info bluetooth
|
||||
alias symbol:dm_rh_update_states dm_region_hash
|
||||
alias symbol:hci_recv_diag bluetooth
|
||||
alias symbol:phy_detach libphy
|
||||
alias symbol:usbnet_cdc_unbind cdc_ether
|
||||
|
||||
Binary file not shown.
+15
-5
@@ -55,7 +55,7 @@ EOF
|
||||
[ -f /geminux/prebuilt/kernel/boot/Image.gz ] && \
|
||||
[ -f /geminux/prebuilt/kernel/boot/mt6797-gemini-pda-geminux.dtb ]; then
|
||||
echo "[1/2] Installing initramfs & bootimg tools in Docker (repack-only)..."
|
||||
apk add --no-cache cpio gzip coreutils mkbootimg-osm0sis >/dev/null
|
||||
apk add --no-cache cpio gzip coreutils mkbootimg-osm0sis kbd kbd-legacy >/dev/null
|
||||
else
|
||||
REPACK_ONLY=0
|
||||
echo "[1/6] Installing Linux 7.3.5 cross-compile & bootimg tools in Docker..."
|
||||
@@ -84,6 +84,8 @@ EOF
|
||||
openssl-dev \
|
||||
linux-headers \
|
||||
dtc \
|
||||
kbd \
|
||||
kbd-legacy \
|
||||
mkbootimg-osm0sis \
|
||||
gcc-aarch64 \
|
||||
g++-aarch64 \
|
||||
@@ -175,10 +177,13 @@ EOF
|
||||
for cmd in sh ash mount umount switch_root mkdir mknod chmod chown \
|
||||
cat cp mv rm ln ls echo printf grep awk sed head tail \
|
||||
cut tr wc sort uniq find xargs hexdump dd sync sleep usleep \
|
||||
loadkmap clear stty readlink stat \
|
||||
poweroff reboot ip ifconfig route basename dirname env touch; do
|
||||
ln -sf busybox "$stage_dir/bin/$cmd"
|
||||
done
|
||||
# Pull static/musl e2fsck + resize2fs if available from aarch64 rootfs/apk
|
||||
cp /tmp/gemini-us.kmap "$stage_dir/etc/gemini-us.kmap"
|
||||
chmod 0644 "$stage_dir/etc/gemini-us.kmap"
|
||||
# Pull static/musl e2fsck + resize2fs + cryptsetup if available from aarch64 rootfs/apk
|
||||
if [ "$mode" = "recovery" ]; then
|
||||
cp /geminux/src/initramfs/init-recovery "$stage_dir/init"
|
||||
else
|
||||
@@ -188,10 +193,15 @@ EOF
|
||||
(cd "$stage_dir" && find . -print0 | cpio --null -ov --format=newc --quiet | gzip -9 > "$out_gz")
|
||||
}
|
||||
|
||||
# Also add e2fsprogs (e2fsck, resize2fs) + shared libs for initramfs filesystem safety,
|
||||
# Also add e2fsprogs (e2fsck, resize2fs), cryptsetup (LUKS2 FDE), + shared libs for initramfs,
|
||||
# and wireless-regdb so built-in cfg80211 loads regulatory.db at early boot.
|
||||
apk --root "$SYSROOT_INIT" --arch aarch64 add --no-scripts \
|
||||
musl e2fsprogs e2fsprogs-extra util-linux-misc wireless-regdb >/dev/null
|
||||
musl e2fsprogs e2fsprogs-extra util-linux-misc wireless-regdb cryptsetup >/dev/null
|
||||
|
||||
(
|
||||
cd /usr/share/keymaps/legacy/i386/include
|
||||
loadkeys -b /geminux/overlay/rootfs/etc/keymap/gemini-us.map > /tmp/gemini-us.kmap
|
||||
)
|
||||
|
||||
build_cpio_with_fs() {
|
||||
mode="$1"
|
||||
@@ -206,7 +216,7 @@ EOF
|
||||
mkdir -p "$stage_dir/lib/firmware"
|
||||
cp -a "$SYSROOT_INIT/lib/firmware/regulatory.db"* "$stage_dir/lib/firmware/"
|
||||
fi
|
||||
for tool in e2fsck fsck.ext4 resize2fs blkid; do
|
||||
for tool in e2fsck fsck.ext4 resize2fs blkid cryptsetup dmsetup; do
|
||||
if [ -e "$SYSROOT_INIT/sbin/$tool" ]; then
|
||||
cp -a "$SYSROOT_INIT/sbin/$tool" "$stage_dir/sbin/"
|
||||
elif [ -e "$SYSROOT_INIT/usr/sbin/$tool" ]; then
|
||||
|
||||
@@ -159,21 +159,103 @@ DTB_SZ="$(stat -c %s "$BASE_DIR/prebuilt/kernel/boot/mt6797-gemini-pda-geminux.d
|
||||
[ "$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" <<'PYEOF'
|
||||
"$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:
|
||||
hdr = f.read(640)
|
||||
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():
|
||||
@@ -189,8 +271,9 @@ for line in kcfg.splitlines():
|
||||
break
|
||||
else:
|
||||
raise SystemExit(f"FAIL: {sys.argv[3]} missing CONFIG_CMDLINE")
|
||||
if "CONFIG_REGULATOR_FIXED_VOLTAGE=y" not in kcfg.splitlines():
|
||||
raise SystemExit(f"FAIL: {sys.argv[3]} missing CONFIG_REGULATOR_FIXED_VOLTAGE=y")
|
||||
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",
|
||||
@@ -200,12 +283,15 @@ for req_rel in ("etc/pam.d/autologin", "etc/init.d/geminux-hwinit",
|
||||
"usr/sbin/geminux-wifi-nvram", "usr/sbin/geminux-tzctl",
|
||||
"usr/bin/geminux-datetime",
|
||||
"usr/bin/bantam",
|
||||
"etc/keymap/gemini-us.map",
|
||||
"etc/skel/.gitconfig",
|
||||
"home/user/.gitconfig",
|
||||
"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")):
|
||||
|
||||
@@ -0,0 +1,324 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Offline ext4 account and SHA-512 ($6$) credential provisioning for Geminux."""
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
import re
|
||||
import secrets
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
_B64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
_USERNAME_RE = re.compile(r"^[a-z_][a-z0-9_-]{0,30}$")
|
||||
|
||||
RESERVED_USERNAMES = frozenset({
|
||||
"root", "bin", "daemon", "adm", "lp", "sync", "shutdown", "halt",
|
||||
"mail", "news", "uucp", "operator", "man", "postmaster", "cron", "ftp",
|
||||
"sshd", "at", "squid", "xfs", "games", "cyrus", "vpopmail", "ntp",
|
||||
"smmsp", "guest", "nobody", "klogd", "chrony", "messagebus", "dnsmasq",
|
||||
"polkitd", "greetd",
|
||||
})
|
||||
|
||||
_SHA512_BYTE_TUPLES = (
|
||||
(0, 21, 42), (22, 43, 1), (44, 2, 23), (3, 24, 45), (25, 46, 4), (47, 5, 26),
|
||||
(6, 27, 48), (28, 49, 7), (50, 8, 29), (9, 30, 51), (31, 52, 10), (53, 11, 32),
|
||||
(12, 33, 54), (34, 55, 13), (56, 14, 35), (15, 36, 57), (37, 58, 16), (59, 17, 38),
|
||||
(18, 39, 60), (40, 61, 19), (62, 20, 41),
|
||||
)
|
||||
|
||||
|
||||
class AccountConfig:
|
||||
"""Provisioning overrides for the desktop user and root credentials."""
|
||||
|
||||
def __init__(self, username=None, user_pw_hash=None, root_pw_hash=None):
|
||||
self.username = username
|
||||
self.user_pw_hash = user_pw_hash
|
||||
self.root_pw_hash = root_pw_hash
|
||||
|
||||
@property
|
||||
def has_changes(self):
|
||||
return bool(self.username or self.user_pw_hash or self.root_pw_hash)
|
||||
|
||||
|
||||
def validate_username(username):
|
||||
"""Validate a POSIX Linux username suitable for Geminux desktop login."""
|
||||
if not isinstance(username, str) or not _USERNAME_RE.match(username):
|
||||
raise ValueError(
|
||||
f"Invalid username {username!r}: must match ^[a-z_][a-z0-9_-]{{0,30}}$"
|
||||
)
|
||||
if username in RESERVED_USERNAMES:
|
||||
raise ValueError(f"Username {username!r} is reserved for a system account")
|
||||
return username
|
||||
|
||||
|
||||
def _b64_from_24bit(b2, b1, b0, n):
|
||||
w = (b2 << 16) | (b1 << 8) | b0
|
||||
out = []
|
||||
for _ in range(n):
|
||||
out.append(_B64[w & 0x3F])
|
||||
w >>= 6
|
||||
return "".join(out)
|
||||
|
||||
|
||||
def sha512_crypt(password, salt=None):
|
||||
"""Compute a standard 5000-round glibc/musl SHA-512 ($6$) shadow hash."""
|
||||
if not isinstance(password, str) or not password:
|
||||
raise ValueError("Password must be a non-empty string")
|
||||
if any(ch in password for ch in ("\x00", "\n", "\r")):
|
||||
raise ValueError("Password must not contain NUL or newline characters")
|
||||
|
||||
if salt is None:
|
||||
salt = "".join(secrets.choice(_B64) for _ in range(16))
|
||||
else:
|
||||
if not isinstance(salt, str) or not (1 <= len(salt) <= 16) or any(ch not in _B64 for ch in salt):
|
||||
raise ValueError("Salt must be 1..16 crypt-base64 characters")
|
||||
|
||||
key = password.encode("utf-8")
|
||||
sb = salt.encode("ascii")
|
||||
klen, slen = len(key), len(sb)
|
||||
|
||||
b = hashlib.sha512(key + sb + key).digest()
|
||||
ca = hashlib.sha512(key + sb)
|
||||
ca.update(b * (klen // 64) + b[:klen % 64])
|
||||
cnt = klen
|
||||
while cnt:
|
||||
ca.update(b if (cnt & 1) else key)
|
||||
cnt >>= 1
|
||||
a = ca.digest()
|
||||
|
||||
dp = hashlib.sha512(key * klen).digest()
|
||||
p = dp * (klen // 64) + dp[:klen % 64]
|
||||
ds = hashlib.sha512(sb * (16 + a[0])).digest()
|
||||
s = ds * (slen // 64) + ds[:slen % 64]
|
||||
|
||||
for i in range(5000):
|
||||
c = hashlib.sha512()
|
||||
c.update(p if (i & 1) else a)
|
||||
if i % 3:
|
||||
c.update(s)
|
||||
if i % 7:
|
||||
c.update(p)
|
||||
c.update(a if (i & 1) else p)
|
||||
a = c.digest()
|
||||
|
||||
enc = "".join(_b64_from_24bit(a[x], a[y], a[z], 4) for x, y, z in _SHA512_BYTE_TUPLES)
|
||||
enc += _b64_from_24bit(0, 0, a[63], 2)
|
||||
return f"$6${salt}${enc}"
|
||||
|
||||
|
||||
def rewrite_account_tables(
|
||||
passwd_txt,
|
||||
group_txt,
|
||||
shadow_txt,
|
||||
new_username=None,
|
||||
user_pw_hash=None,
|
||||
root_pw_hash=None,
|
||||
desktop_uid=10000,
|
||||
):
|
||||
"""Rewrite /etc/passwd, /etc/group, and /etc/shadow contents for the target user and root."""
|
||||
passwd_rows = [line for line in passwd_txt.splitlines() if line]
|
||||
group_rows = [line for line in group_txt.splitlines() if line]
|
||||
shadow_rows = [line for line in shadow_txt.splitlines() if line]
|
||||
|
||||
desktop_idx = None
|
||||
for idx, row in enumerate(passwd_rows):
|
||||
fields = row.split(":")
|
||||
if len(fields) >= 6 and fields[2].isdigit() and int(fields[2]) == desktop_uid:
|
||||
desktop_idx = idx
|
||||
break
|
||||
if desktop_idx is None:
|
||||
for idx, row in enumerate(passwd_rows):
|
||||
fields = row.split(":")
|
||||
if len(fields) >= 6 and fields[0] == "user":
|
||||
desktop_idx = idx
|
||||
break
|
||||
if desktop_idx is None:
|
||||
raise RuntimeError(f"Desktop user (UID {desktop_uid}) not found in /etc/passwd")
|
||||
|
||||
pw_fields = passwd_rows[desktop_idx].split(":")
|
||||
old_username = pw_fields[0]
|
||||
target_username = new_username if new_username else old_username
|
||||
|
||||
if target_username != old_username:
|
||||
validate_username(target_username)
|
||||
for idx, row in enumerate(passwd_rows):
|
||||
fields = row.split(":")
|
||||
if idx != desktop_idx and fields[0] == target_username:
|
||||
raise ValueError(f"Username {target_username!r} already exists in /etc/passwd")
|
||||
for row in group_rows:
|
||||
fields = row.split(":")
|
||||
is_desktop_pri = (
|
||||
fields[0] == old_username or
|
||||
(len(fields) >= 3 and fields[2].isdigit() and int(fields[2]) == desktop_uid)
|
||||
)
|
||||
if not is_desktop_pri and fields[0] == target_username:
|
||||
raise ValueError(f"Group name {target_username!r} collides with an existing system group")
|
||||
|
||||
pw_fields[0] = target_username
|
||||
pw_fields[5] = f"/home/{target_username}"
|
||||
passwd_rows[desktop_idx] = ":".join(pw_fields)
|
||||
|
||||
for idx, row in enumerate(group_rows):
|
||||
fields = row.split(":")
|
||||
is_desktop_pri = (
|
||||
fields[0] == old_username or
|
||||
(len(fields) >= 3 and fields[2].isdigit() and int(fields[2]) == desktop_uid)
|
||||
)
|
||||
if is_desktop_pri:
|
||||
fields[0] = target_username
|
||||
if len(fields) >= 4 and fields[3]:
|
||||
members = [
|
||||
target_username if m == old_username else m
|
||||
for m in fields[3].split(",") if m
|
||||
]
|
||||
fields[3] = ",".join(dict.fromkeys(members))
|
||||
group_rows[idx] = ":".join(fields)
|
||||
|
||||
for idx, row in enumerate(shadow_rows):
|
||||
fields = row.split(":")
|
||||
if fields[0] == old_username:
|
||||
fields[0] = target_username
|
||||
shadow_rows[idx] = ":".join(fields)
|
||||
|
||||
if user_pw_hash:
|
||||
updated = False
|
||||
for idx, row in enumerate(shadow_rows):
|
||||
fields = row.split(":")
|
||||
if fields[0] == target_username and len(fields) >= 2:
|
||||
fields[1] = user_pw_hash
|
||||
shadow_rows[idx] = ":".join(fields)
|
||||
updated = True
|
||||
break
|
||||
if not updated:
|
||||
shadow_rows.append(f"{target_username}:{user_pw_hash}:::::::")
|
||||
|
||||
if root_pw_hash:
|
||||
updated = False
|
||||
for idx, row in enumerate(shadow_rows):
|
||||
fields = row.split(":")
|
||||
if fields[0] == "root" and len(fields) >= 2:
|
||||
fields[1] = root_pw_hash
|
||||
shadow_rows[idx] = ":".join(fields)
|
||||
updated = True
|
||||
break
|
||||
if not updated:
|
||||
shadow_rows.insert(0, f"root:{root_pw_hash}:::::::")
|
||||
|
||||
return (
|
||||
"\n".join(passwd_rows) + "\n",
|
||||
"\n".join(group_rows) + "\n",
|
||||
"\n".join(shadow_rows) + "\n",
|
||||
old_username,
|
||||
target_username,
|
||||
)
|
||||
|
||||
|
||||
def _have_host_ext4_tools():
|
||||
return shutil.which("debugfs") is not None and shutil.which("e2fsck") is not None
|
||||
|
||||
|
||||
def _run_docker_ext4(img_dir, work_dir, shell_cmd, input_text=None):
|
||||
docker_bin = shutil.which("docker")
|
||||
if not docker_bin:
|
||||
raise RuntimeError("Need host debugfs/e2fsck (e2fsprogs) or docker to customize ext4 image")
|
||||
subprocess.run(
|
||||
[
|
||||
docker_bin, "run", "--rm", "-i",
|
||||
"-v", f"{img_dir}:/img",
|
||||
"-v", f"{work_dir}:/work",
|
||||
"alpine:3.24",
|
||||
"sh", "-eu", "-c",
|
||||
f"apk add --no-cache e2fsprogs >/dev/null && {shell_cmd}",
|
||||
],
|
||||
input=input_text,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
|
||||
|
||||
def customize_ext4_accounts(ext4_img_path, new_username=None, user_pw_hash=None, root_pw_hash=None):
|
||||
"""Apply username and shadow password hash changes inside an unmounted ext4 rootfs image."""
|
||||
if not (new_username or user_pw_hash or root_pw_hash):
|
||||
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}")
|
||||
img_dir = os.path.dirname(abs_img)
|
||||
img_name = os.path.basename(abs_img)
|
||||
use_host = _have_host_ext4_tools()
|
||||
|
||||
with tempfile.TemporaryDirectory(prefix="geminux-acct-") as tmp:
|
||||
if use_host:
|
||||
for name in ("passwd", "group", "shadow"):
|
||||
dst = os.path.join(tmp, f"{name}.orig")
|
||||
subprocess.run(
|
||||
["debugfs", "-R", f"dump /etc/{name} {dst}", abs_img],
|
||||
check=True,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL,
|
||||
)
|
||||
else:
|
||||
dump_cmds = " && ".join(
|
||||
f"debugfs -R 'dump /etc/{name} /work/{name}.orig' '/img/{img_name}' >/dev/null 2>&1"
|
||||
for name in ("passwd", "group", "shadow")
|
||||
)
|
||||
_run_docker_ext4(img_dir, tmp, dump_cmds)
|
||||
|
||||
texts = {}
|
||||
for name in ("passwd", "group", "shadow"):
|
||||
with open(os.path.join(tmp, f"{name}.orig"), "r", encoding="utf-8") as f:
|
||||
texts[name] = f.read()
|
||||
|
||||
new_pw, new_gr, new_sh, old_user, target_user = rewrite_account_tables(
|
||||
texts["passwd"],
|
||||
texts["group"],
|
||||
texts["shadow"],
|
||||
new_username=new_username,
|
||||
user_pw_hash=user_pw_hash,
|
||||
root_pw_hash=root_pw_hash,
|
||||
)
|
||||
|
||||
out_contents = {"passwd": new_pw, "group": new_gr, "shadow": new_sh}
|
||||
inodes_spec = (
|
||||
("passwd", 0, 0, "0100644"),
|
||||
("group", 0, 0, "0100644"),
|
||||
("shadow", 0, 42, "0100640"),
|
||||
)
|
||||
for name, content in out_contents.items():
|
||||
p = os.path.join(tmp, name)
|
||||
with open(p, "w", encoding="utf-8") as f:
|
||||
f.write(content)
|
||||
|
||||
def build_debugfs_script(work_prefix):
|
||||
cmds = []
|
||||
if target_user != old_user:
|
||||
cmds.append(f"ln /home/{old_user} /home/{target_user}")
|
||||
cmds.append(f"unlink /home/{old_user}")
|
||||
for name, uid, gid, mode in inodes_spec:
|
||||
cmds.append(f"rm /etc/{name}")
|
||||
cmds.append(f"write {work_prefix}/{name} /etc/{name}")
|
||||
cmds.append(f"set_inode_field /etc/{name} uid {uid}")
|
||||
cmds.append(f"set_inode_field /etc/{name} gid {gid}")
|
||||
cmds.append(f"set_inode_field /etc/{name} mode {mode}")
|
||||
return "\n".join(cmds) + "\n"
|
||||
|
||||
if use_host:
|
||||
script = build_debugfs_script(tmp)
|
||||
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)
|
||||
else:
|
||||
script = build_debugfs_script("/work")
|
||||
_run_docker_ext4(
|
||||
img_dir,
|
||||
tmp,
|
||||
f"debugfs -w '/img/{img_name}' >/dev/null && e2fsck -fn '/img/{img_name}' >/dev/null",
|
||||
input_text=script,
|
||||
)
|
||||
return old_user, target_user
|
||||
@@ -0,0 +1,108 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Host-side LUKS2 full-disk encryption image builder for Geminux."""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
LUKS2_HEADER_PAD_MIB = 32
|
||||
DEFAULT_PBKDF_MEMORY_KB = 131072
|
||||
DEFAULT_PBKDF_ITERATIONS = 4
|
||||
DEFAULT_PBKDF_PARALLEL = 4
|
||||
|
||||
|
||||
class LuksConfig:
|
||||
"""LUKS2 encryption configuration collected before flashing."""
|
||||
|
||||
def __init__(self, enabled=False, passphrase=None):
|
||||
self.enabled = bool(enabled)
|
||||
self.passphrase = passphrase
|
||||
|
||||
|
||||
def validate_luks_passphrase(passphrase):
|
||||
"""Validate a LUKS2 disk passphrase (non-empty UTF-8 string without NUL/newlines)."""
|
||||
if not isinstance(passphrase, str) or not passphrase:
|
||||
raise ValueError("LUKS2 passphrase must be a non-empty string")
|
||||
if any(ch in passphrase for ch in ("\x00", "\n", "\r")):
|
||||
raise ValueError("LUKS2 passphrase must not contain NUL or newline characters")
|
||||
return passphrase
|
||||
|
||||
|
||||
def _run_cryptsetup(args, img_dir, input_bytes=None):
|
||||
host_cs = shutil.which("cryptsetup")
|
||||
if host_cs is not None:
|
||||
return subprocess.run(
|
||||
[host_cs] + args,
|
||||
input=input_bytes,
|
||||
check=True,
|
||||
capture_output=True,
|
||||
)
|
||||
docker_bin = shutil.which("docker")
|
||||
if docker_bin is None:
|
||||
raise RuntimeError("Need host 'cryptsetup' or 'docker' to encrypt rootfs image")
|
||||
return subprocess.run(
|
||||
[
|
||||
docker_bin, "run", "--rm", "-i",
|
||||
"-v", f"{img_dir}:/img",
|
||||
"alpine:3.24",
|
||||
"sh", "-eu", "-c",
|
||||
'apk add --no-cache cryptsetup >/dev/null && "$@"',
|
||||
"_", "cryptsetup",
|
||||
] + args,
|
||||
input=input_bytes,
|
||||
check=True,
|
||||
capture_output=True,
|
||||
)
|
||||
|
||||
|
||||
def encrypt_ext4_image_luks2(
|
||||
ext4_img_path,
|
||||
passphrase,
|
||||
pbkdf_memory_kb=DEFAULT_PBKDF_MEMORY_KB,
|
||||
pbkdf_iterations=DEFAULT_PBKDF_ITERATIONS,
|
||||
pbkdf_parallel=DEFAULT_PBKDF_PARALLEL,
|
||||
):
|
||||
"""Encrypt an ext4 image in place inside a LUKS2 (aes-xts-plain64, Argon2id) container."""
|
||||
validate_luks_passphrase(passphrase)
|
||||
abs_img = os.path.abspath(ext4_img_path)
|
||||
if not os.path.isfile(abs_img):
|
||||
raise FileNotFoundError(f"ext4 image not found: {abs_img}")
|
||||
|
||||
pad_bytes = LUKS2_HEADER_PAD_MIB * 1024 * 1024
|
||||
with open(abs_img, "r+b") as f:
|
||||
f.seek(0, os.SEEK_END)
|
||||
cur_sz = f.tell()
|
||||
f.truncate(cur_sz + pad_bytes)
|
||||
|
||||
use_host = shutil.which("cryptsetup") is not None
|
||||
img_dir = os.path.dirname(abs_img)
|
||||
img_arg = abs_img if use_host else f"/img/{os.path.basename(abs_img)}"
|
||||
pw_bytes = passphrase.encode("utf-8")
|
||||
|
||||
_run_cryptsetup(
|
||||
[
|
||||
"reencrypt", "--encrypt",
|
||||
"--disable-locks",
|
||||
"--type", "luks2",
|
||||
"--cipher", "aes-xts-plain64",
|
||||
"--key-size", "512",
|
||||
"--hash", "sha256",
|
||||
"--pbkdf", "argon2id",
|
||||
"--pbkdf-memory", str(int(pbkdf_memory_kb)),
|
||||
"--pbkdf-force-iterations", str(int(pbkdf_iterations)),
|
||||
"--pbkdf-parallel", str(int(pbkdf_parallel)),
|
||||
"--reduce-device-size", f"{LUKS2_HEADER_PAD_MIB}M",
|
||||
"--batch-mode",
|
||||
"--key-file", "-",
|
||||
img_arg,
|
||||
],
|
||||
img_dir,
|
||||
input_bytes=pw_bytes,
|
||||
)
|
||||
|
||||
_run_cryptsetup(["isLuks", "--disable-locks", img_arg], img_dir)
|
||||
_run_cryptsetup(
|
||||
["open", "--test-passphrase", "--disable-locks", "--key-file", "-", img_arg],
|
||||
img_dir,
|
||||
input_bytes=pw_bytes,
|
||||
)
|
||||
@@ -16,6 +16,7 @@ ca-certificates
|
||||
chrony
|
||||
chrony-openrc
|
||||
coreutils
|
||||
cryptsetup
|
||||
curl
|
||||
curl-dev
|
||||
dbus
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"""Offline test suite for Geminux flash-mtk GPT builder, safety guards, and firmware extractor."""
|
||||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import struct
|
||||
import subprocess
|
||||
@@ -17,6 +18,12 @@ if os.path.isdir(FLASH_DEPS):
|
||||
sys.path.insert(0, BASE_DIR)
|
||||
sys.path.insert(0, SCRIPTS_DIR)
|
||||
|
||||
from geminux_accounts import (
|
||||
customize_ext4_accounts,
|
||||
rewrite_account_tables,
|
||||
sha512_crypt,
|
||||
validate_username,
|
||||
)
|
||||
from geminux_gpt import (
|
||||
BASIC_DATA_TYPE_GUID,
|
||||
GPT_ARRAY_SECTORS,
|
||||
@@ -431,6 +438,299 @@ def test_xflash_shutdown_wire_packet():
|
||||
print("[PASS] XFlash 28-byte shutdown wire packet and ENOENT suppression verified")
|
||||
|
||||
|
||||
def test_sha512_crypt_and_username_validation():
|
||||
openssl = shutil.which("openssl")
|
||||
for pw, salt in (
|
||||
("geminux", "geminux"),
|
||||
("Tr0ub4dor&3!", "AbCdEf0123456789"),
|
||||
("p@ss word/with+chars", "Z9y8X7w6"),
|
||||
):
|
||||
hashed = sha512_crypt(pw, salt=salt)
|
||||
assert hashed.startswith(f"$6${salt}$") and len(hashed) == 4 + len(salt) + 86
|
||||
if openssl:
|
||||
expected = subprocess.check_output(
|
||||
[openssl, "passwd", "-6", "-salt", salt, pw], text=True
|
||||
).strip()
|
||||
assert hashed == expected, f"Hash mismatch: {hashed} != {expected}"
|
||||
|
||||
rand_hash = sha512_crypt("anotherSecret!")
|
||||
parts = rand_hash.split("$")
|
||||
assert len(parts) == 4 and parts[1] == "6" and len(parts[2]) == 16 and len(parts[3]) == 86
|
||||
|
||||
for bad_pw in ("", "line\nbreak", "nul\x00byte", "cr\rchar"):
|
||||
raised = False
|
||||
try:
|
||||
sha512_crypt(bad_pw)
|
||||
except ValueError:
|
||||
raised = True
|
||||
assert raised, f"Bad password {bad_pw!r} was not rejected"
|
||||
|
||||
assert validate_username("pdaowner") == "pdaowner"
|
||||
assert validate_username("_dev_01") == "_dev_01"
|
||||
for bad_user in ("", "root", "chrony", "123bad", "bad space", "UpperCase", "a" * 32):
|
||||
raised = False
|
||||
try:
|
||||
validate_username(bad_user)
|
||||
except ValueError:
|
||||
raised = True
|
||||
assert raised, f"Invalid/reserved username {bad_user!r} was not rejected"
|
||||
print("[PASS] Pure-Python sha512_crypt ($6$) and username validation verified")
|
||||
|
||||
|
||||
def test_account_customization_ext4():
|
||||
if not all(shutil.which(cmd) for cmd in ("mke2fs", "debugfs", "e2fsck")):
|
||||
print("[SKIP] mke2fs/debugfs/e2fsck not available on host for account customization test")
|
||||
return
|
||||
|
||||
with tempfile.TemporaryDirectory(prefix="geminux-acct-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", ".ssh"), 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\n"
|
||||
"chrony:x:101:102:chrony:/dev/null:/sbin/nologin\n"
|
||||
"user: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\n"
|
||||
"wheel:x:10:root,user\n"
|
||||
"audio:x:18:user\n"
|
||||
"netdev:x:28:user\n"
|
||||
"plugdev:x:106:user\n"
|
||||
"pipewire:x:107:user\n"
|
||||
"seat:x:108:user\n"
|
||||
"user:x:10000:\n"
|
||||
)
|
||||
with open(os.path.join(sysroot, "etc", "shadow"), "w", encoding="utf-8") as f:
|
||||
f.write(
|
||||
"root:$6$oldsalt$oldhashroot:::::::\n"
|
||||
"chrony:!:::::::\n"
|
||||
"user:$6$oldsalt$oldhashuser:::::::\n"
|
||||
)
|
||||
with open(os.path.join(sysroot, "home", "user", ".gitconfig"), "w", encoding="utf-8") as f:
|
||||
f.write("[pull]\n\trebase = false\n")
|
||||
with open(os.path.join(sysroot, "home", "user", ".ssh", "authorized_keys"), "w", encoding="utf-8") as f:
|
||||
f.write("ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAItest\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, "custom-rootfs.img")
|
||||
subprocess.run(
|
||||
["mke2fs", "-t", "ext4", "-F", "-q", "-d", sysroot, orig_img, "8M"],
|
||||
check=True,
|
||||
)
|
||||
subprocess.run(
|
||||
["debugfs", "-w", orig_img],
|
||||
input="\n".join([
|
||||
"set_inode_field /home/user uid 10000",
|
||||
"set_inode_field /home/user gid 10000",
|
||||
"set_inode_field /home/user/.gitconfig uid 10000",
|
||||
"set_inode_field /home/user/.gitconfig gid 10000",
|
||||
"set_inode_field /home/user/.ssh uid 10000",
|
||||
"set_inode_field /home/user/.ssh gid 10000",
|
||||
"set_inode_field /home/user/.ssh/authorized_keys uid 10000",
|
||||
"set_inode_field /home/user/.ssh/authorized_keys gid 10000",
|
||||
]) + "\n",
|
||||
text=True,
|
||||
check=True,
|
||||
stdout=subprocess.DEVNULL,
|
||||
)
|
||||
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,
|
||||
"--username", "pdaowner",
|
||||
"--user-password", "testUserPw!9",
|
||||
"--root-password", "testRootPw!9",
|
||||
],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
assert res.returncode == 0, f"customize-rootfs 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: {e2.stdout}\n{e2.stderr}"
|
||||
|
||||
for rel in ("/home/pdaowner/.gitconfig", "/home/pdaowner/.ssh/authorized_keys"):
|
||||
st = subprocess.run(
|
||||
["debugfs", "-R", f"stat {rel}", out_img],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
assert re.search(r"User:\s*10000\b", st.stdout), f"{rel} lost UID 10000:\n{st.stdout}"
|
||||
old_st = subprocess.run(
|
||||
["debugfs", "-R", "stat /home/user", out_img],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
assert "File not found" in (old_st.stdout + old_st.stderr), old_st.stdout + old_st.stderr
|
||||
|
||||
sh_stat = subprocess.run(
|
||||
["debugfs", "-R", "stat /etc/shadow", out_img],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
assert "Type: regular" in sh_stat.stdout, sh_stat.stdout
|
||||
assert re.search(r"Mode:\s*0640\b", sh_stat.stdout), sh_stat.stdout
|
||||
assert re.search(r"User:\s*0\b", sh_stat.stdout), sh_stat.stdout
|
||||
assert re.search(r"Group:\s*42\b", sh_stat.stdout), sh_stat.stdout
|
||||
|
||||
pw_txt = subprocess.check_output(["debugfs", "-R", "cat /etc/passwd", out_img], text=True)
|
||||
gr_txt = subprocess.check_output(["debugfs", "-R", "cat /etc/group", out_img], text=True)
|
||||
sh_txt = subprocess.check_output(["debugfs", "-R", "cat /etc/shadow", out_img], text=True)
|
||||
|
||||
assert "pdaowner:x:10000:10000::/home/pdaowner:/bin/bash" in pw_txt, pw_txt
|
||||
assert "user:" not in pw_txt
|
||||
for gname in ("wheel", "audio", "netdev", "plugdev", "pipewire", "seat"):
|
||||
assert any(line.startswith(f"{gname}:") and "pdaowner" in line.split(":")[3].split(",")
|
||||
for line in gr_txt.splitlines()), gr_txt
|
||||
assert "pdaowner:x:10000:" in gr_txt and "user:x:10000:" not in gr_txt, gr_txt
|
||||
|
||||
sh_rows = {row.split(":")[0]: row.split(":")[1] for row in sh_txt.splitlines() if row}
|
||||
assert "user" not in sh_rows and "pdaowner" in sh_rows and "root" in sh_rows
|
||||
u_salt = sh_rows["pdaowner"].split("$")[2]
|
||||
r_salt = sh_rows["root"].split("$")[2]
|
||||
assert sh_rows["pdaowner"] == sha512_crypt("testUserPw!9", salt=u_salt)
|
||||
assert sh_rows["root"] == sha512_crypt("testRootPw!9", salt=r_salt)
|
||||
print("[PASS] Offline ext4 account renaming and shadow password customization verified")
|
||||
|
||||
|
||||
def _xts_decrypt_ext4(enc_path, vk64, payload_offset, payload_bytes, out_dec_path):
|
||||
from Crypto.Cipher import AES
|
||||
|
||||
c_data = AES.new(vk64[:32], AES.MODE_ECB)
|
||||
c_tweak = AES.new(vk64[32:], AES.MODE_ECB)
|
||||
with open(enc_path, "rb") as sf, open(out_dec_path, "wb") as df:
|
||||
sf.seek(payload_offset)
|
||||
sectors = payload_bytes // 512
|
||||
for sec_idx in range(sectors):
|
||||
sec = sf.read(512)
|
||||
t = int.from_bytes(c_tweak.encrypt(struct.pack("<QQ", sec_idx, 0)), "little")
|
||||
out = bytearray(512)
|
||||
for blk in range(0, 512, 16):
|
||||
tb = t.to_bytes(16, "little")
|
||||
cc = bytes(a ^ b for a, b in zip(sec[blk:blk + 16], tb))
|
||||
pp = c_data.decrypt(cc)
|
||||
out[blk:blk + 16] = bytes(a ^ b for a, b in zip(pp, tb))
|
||||
t = ((t << 1) ^ (0x87 if (t >> 127) else 0)) & ((1 << 128) - 1)
|
||||
df.write(out)
|
||||
|
||||
|
||||
def test_luks2_encryption_offline():
|
||||
import pty
|
||||
|
||||
if not all(shutil.which(cmd) for cmd in ("mke2fs", "debugfs", "e2fsck", "cryptsetup")):
|
||||
print("[SKIP] mke2fs/debugfs/e2fsck/cryptsetup not available for LUKS2 offline test")
|
||||
return
|
||||
|
||||
with tempfile.TemporaryDirectory(prefix="geminux-luks-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\nwheel:x:10:root,user\nuser:x:10000:\n")
|
||||
with open(os.path.join(sysroot, "etc", "shadow"), "w", encoding="utf-8") as f:
|
||||
f.write("root:$6$oldsalt$old:::::::\nuser:$6$oldsalt$old:::::::\n")
|
||||
with open(os.path.join(sysroot, "home", "user", ".gitconfig"), "w", encoding="utf-8") as f:
|
||||
f.write("[pull]\n\trebase = false\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")
|
||||
enc_out = os.path.join(tmp, "enc-rootfs.img")
|
||||
subprocess.run(
|
||||
["mke2fs", "-t", "ext4", "-F", "-q", "-d", sysroot, orig_img, "8M"],
|
||||
check=True,
|
||||
)
|
||||
orig_sha = flash_mtk.sha256_file(orig_img)
|
||||
orig_bytes = os.path.getsize(orig_img)
|
||||
|
||||
res = subprocess.run(
|
||||
[
|
||||
os.path.join(BASE_DIR, "flash-mtk.sh"),
|
||||
"--customize-rootfs", enc_out,
|
||||
"--images-dir", img_dir,
|
||||
"--username", "luksuser",
|
||||
"--user-password", "uPw!77",
|
||||
"--root-password", "rPw!77",
|
||||
"--luks-password", "DiskPass#2026",
|
||||
],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
assert res.returncode == 0, f"encrypted customize-rootfs failed: {res.stdout}\n{res.stderr}"
|
||||
assert flash_mtk.sha256_file(orig_img) == orig_sha, "Source rootfs image was mutated!"
|
||||
|
||||
assert subprocess.run(["cryptsetup", "isLuks", "--disable-locks", enc_out]).returncode == 0
|
||||
assert subprocess.run(
|
||||
["cryptsetup", "open", "--test-passphrase", "--disable-locks", "--key-file", "-", enc_out],
|
||||
input=b"DiskPass#2026",
|
||||
).returncode == 0
|
||||
assert subprocess.run(
|
||||
["cryptsetup", "open", "--test-passphrase", "--disable-locks", "--key-file", "-", enc_out],
|
||||
input=b"WrongPass",
|
||||
).returncode != 0
|
||||
|
||||
# Verify interactive PTY unlock (simulating PID 1 initramfs prompt on /dev/tty1)
|
||||
mfd, sfd = pty.openpty()
|
||||
pty_proc = subprocess.Popen(
|
||||
["cryptsetup", "open", "--test-passphrase", "--disable-locks", enc_out],
|
||||
stdin=sfd, stdout=sfd, stderr=sfd, close_fds=True, start_new_session=True,
|
||||
)
|
||||
os.close(sfd)
|
||||
prompt_buf = b""
|
||||
while b":" not in prompt_buf:
|
||||
prompt_buf += os.read(mfd, 256)
|
||||
os.write(mfd, b"DiskPass#2026\n")
|
||||
pty_rc = pty_proc.wait(timeout=10)
|
||||
os.close(mfd)
|
||||
assert pty_rc == 0, f"Interactive PTY passphrase check failed rc={pty_rc}"
|
||||
|
||||
vk_file = os.path.join(tmp, "vk.bin")
|
||||
dump = subprocess.check_output(
|
||||
[
|
||||
"cryptsetup", "luksDump", "--disable-locks", "--dump-volume-key",
|
||||
"--volume-key-file", vk_file, "--batch-mode", "--key-file", "-", enc_out,
|
||||
],
|
||||
input="DiskPass#2026".encode("utf-8"),
|
||||
text=False,
|
||||
).decode("utf-8")
|
||||
m_off = re.search(r"Payload offset:\s*(\d+)", dump)
|
||||
assert m_off, dump
|
||||
payload_offset = int(m_off.group(1)) * 512
|
||||
assert os.path.getsize(enc_out) >= payload_offset + orig_bytes
|
||||
|
||||
with open(vk_file, "rb") as vf:
|
||||
vk64 = vf.read()
|
||||
dec_img = os.path.join(tmp, "dec-rootfs.img")
|
||||
_xts_decrypt_ext4(enc_out, vk64, payload_offset, orig_bytes, dec_img)
|
||||
|
||||
e2 = subprocess.run(["e2fsck", "-fn", dec_img], capture_output=True, text=True)
|
||||
assert e2.returncode == 0, f"Decrypted ext4 failed e2fsck: {e2.stdout}\n{e2.stderr}"
|
||||
pw_txt = subprocess.check_output(["debugfs", "-R", "cat /etc/passwd", dec_img], text=True)
|
||||
assert "luksuser:x:10000:10000::/home/luksuser:/bin/bash" in pw_txt, pw_txt
|
||||
st = subprocess.run(
|
||||
["debugfs", "-R", "stat /home/luksuser/.gitconfig", dec_img],
|
||||
capture_output=True, text=True, check=True,
|
||||
)
|
||||
assert "Type: regular" in st.stdout, st.stdout
|
||||
print("[PASS] Offline LUKS2 encryption, PTY passphrase unlock, and XTS-256 ext4 decryption verified")
|
||||
|
||||
|
||||
def test_cli_help():
|
||||
res = subprocess.run(
|
||||
[os.path.join(BASE_DIR, "flash-mtk.sh"), "--help"],
|
||||
@@ -439,9 +739,26 @@ def test_cli_help():
|
||||
check=False,
|
||||
)
|
||||
assert res.returncode == 0, res.stderr
|
||||
assert "--only-backup" in res.stdout and "--flash-full" in res.stdout
|
||||
assert "--reboot" in res.stdout and "--poweroff" in res.stdout and "--no-reboot" in res.stdout
|
||||
assert "--wait-timeout" in res.stdout
|
||||
for flag in (
|
||||
"--only-backup",
|
||||
"--flash-full",
|
||||
"--flash-rootfs-only",
|
||||
"--customize-rootfs",
|
||||
"--username",
|
||||
"--user-password",
|
||||
"--ask-user-password",
|
||||
"--root-password",
|
||||
"--ask-root-password",
|
||||
"--use-default-credentials",
|
||||
"--encrypt",
|
||||
"--luks-password",
|
||||
"--ask-luks-password",
|
||||
"--reboot",
|
||||
"--poweroff",
|
||||
"--no-reboot",
|
||||
"--wait-timeout",
|
||||
):
|
||||
assert flag in res.stdout, f"Missing CLI option {flag} in --help"
|
||||
print("[PASS] flash-mtk.sh --help verified")
|
||||
|
||||
|
||||
@@ -453,6 +770,9 @@ def main():
|
||||
test_finish_da_session()
|
||||
test_fast_preloader_handshake()
|
||||
test_xflash_shutdown_wire_packet()
|
||||
test_sha512_crypt_and_username_validation()
|
||||
test_account_customization_ext4()
|
||||
test_luks2_encryption_offline()
|
||||
test_cli_help()
|
||||
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){pad, 472, cw, 40},
|
||||
"AW9120 LED Strip Indicator", -1, true, GEMUI_ALIGN_LEFT, t->fg_bright);
|
||||
int lw = (cw - 36) / 4;
|
||||
static const char *leds[4] = {"Off", "Cyan Pulse", "Green OK", "Amber Warn"};
|
||||
static const char *leds[4] = {"Off", "Cyan", "Green OK", "Amber Warn"};
|
||||
for (int i = 0; i < 4; i++) {
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + i * (lw + 12), 518, lw, 76},
|
||||
leds[i], HIT_LED, i, false, false, false);
|
||||
@@ -195,9 +195,9 @@ static void on_ptr(gemui_app_t *app, int type, int x, int y, unsigned int btn, v
|
||||
gemui_show_toast(app, "Updated power profile", 1600);
|
||||
gemui_request_redraw(app);
|
||||
} else if (hit->id == HIT_LED) {
|
||||
static const char *lcmds[4] = {"off", "rgb 0 40 60", "rgb 0 64 16", "rgb 64 40 0"};
|
||||
gemui_unix_cmd("/run/geminux/leds.sock", lcmds[hit->val], NULL, 0);
|
||||
gemui_show_toast(app, "Updated AW9120 LED state", 1400);
|
||||
static const char *lcmds[4] = {"off", "rgb 0 40 64", "rgb 0 64 8", "rgb 160 16 0"};
|
||||
int lrc = gemui_unix_cmd("/run/geminux/leds.sock", lcmds[hit->val], NULL, 0);
|
||||
gemui_show_toast(app, lrc == 0 ? "Updated AW9120 LED strip" : "LED daemon unavailable", 1400);
|
||||
} else if (hit->id == HIT_LOCK) {
|
||||
const char *cmd[] = {"geminux-lock", NULL};
|
||||
gemui_spawn_detached(cmd);
|
||||
|
||||
@@ -171,6 +171,7 @@ static void handle_client(ccci_ctx_t *ctx, int cfd) {
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
ccci_ctx_t ctx;
|
||||
memset(&ctx, 0, sizeof(ctx));
|
||||
ctx.ctl_fd = ctx.fs_fd = ctx.rpc_fd = -1;
|
||||
|
||||
@@ -126,15 +126,13 @@ static int read_charging_state(void) {
|
||||
char p[320], typ[32] = {0}, st[32] = {0};
|
||||
snprintf(p, sizeof(p), "/sys/class/power_supply/%s/type", de->d_name);
|
||||
if (read_sysfs_line(p, typ, sizeof(typ)) != 0) continue;
|
||||
if (strcmp(typ, "Battery") != 0 && strcmp(typ, "USB") != 0) continue;
|
||||
if (strcmp(typ, "Battery") != 0) continue;
|
||||
|
||||
snprintf(p, sizeof(p), "/sys/class/power_supply/%s/status", de->d_name);
|
||||
if (read_sysfs_line(p, st, sizeof(st)) != 0) continue;
|
||||
if (strcmp(st, "Charging") == 0) {
|
||||
state = 1;
|
||||
break;
|
||||
} else if (strcmp(st, "Full") == 0) {
|
||||
state = 2;
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
@@ -145,9 +143,12 @@ static void sync_charging_led(int *last_state, bool force) {
|
||||
int st = read_charging_state();
|
||||
if (!force && *last_state == st) return;
|
||||
*last_state = st;
|
||||
if (st == 1) apply_strip_rgb(32, 16, 0, false);
|
||||
else if (st == 2) apply_strip_rgb(0, 32, 0, false);
|
||||
else apply_strip_rgb(0, 0, 0, true);
|
||||
if (st == 1) {
|
||||
apply_strip_rgb(0, 0, 0, false);
|
||||
write_single_cover_led(6, 128, 12, 0);
|
||||
} else {
|
||||
apply_strip_rgb(0, 0, 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
static void disarm_timer(int tmr_fd) {
|
||||
@@ -158,6 +159,7 @@ static void disarm_timer(int tmr_fd) {
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
mkdir("/run/geminux", 0755);
|
||||
|
||||
sigset_t mask;
|
||||
@@ -205,6 +207,7 @@ int main(void) {
|
||||
}
|
||||
|
||||
int last_chg_state = -1;
|
||||
bool manual_override = false;
|
||||
sync_charging_led(&last_chg_state, true);
|
||||
|
||||
struct epoll_event events[8];
|
||||
@@ -231,18 +234,23 @@ int main(void) {
|
||||
int idx = 0, rr = 0, gg = 0, bb = 0, ms = 0;
|
||||
if (strcmp(cmd, "off") == 0) {
|
||||
disarm_timer(tmr_fd);
|
||||
manual_override = true;
|
||||
apply_strip_rgb(0, 0, 0, true);
|
||||
} else if (strcmp(cmd, "auto") == 0) {
|
||||
disarm_timer(tmr_fd);
|
||||
manual_override = false;
|
||||
sync_charging_led(&last_chg_state, true);
|
||||
} else if (sscanf(cmd, "rgb %d %d %d", &rr, &gg, &bb) == 3) {
|
||||
disarm_timer(tmr_fd);
|
||||
manual_override = true;
|
||||
apply_strip_rgb(rr, gg, bb, false);
|
||||
} else if (sscanf(cmd, "led %d %d %d %d", &idx, &rr, &gg, &bb) == 4) {
|
||||
if (idx >= 1 && idx <= 6) {
|
||||
manual_override = true;
|
||||
write_single_cover_led(idx, rr, gg, bb);
|
||||
}
|
||||
} else if (sscanf(cmd, "pulse %d %d %d %d", &rr, &gg, &bb, &ms) == 4) {
|
||||
manual_override = false;
|
||||
apply_strip_rgb(rr, gg, bb, false);
|
||||
if (ms > 0 && tmr_fd >= 0) {
|
||||
struct itimerspec its;
|
||||
@@ -255,12 +263,13 @@ int main(void) {
|
||||
}
|
||||
}
|
||||
}
|
||||
dprintf(cfd, "OK\n");
|
||||
send(cfd, "OK\n", 3, MSG_NOSIGNAL);
|
||||
close(cfd);
|
||||
}
|
||||
} else if (fd == tmr_fd) {
|
||||
uint64_t exp = 0;
|
||||
while (read(tmr_fd, &exp, sizeof(exp)) > 0) {}
|
||||
manual_override = false;
|
||||
sync_charging_led(&last_chg_state, true);
|
||||
} else if (fd == uev_fd) {
|
||||
char ubuf[1024];
|
||||
@@ -271,7 +280,7 @@ int main(void) {
|
||||
ps_event = true;
|
||||
}
|
||||
}
|
||||
if (ps_event) {
|
||||
if (ps_event && !manual_override) {
|
||||
sync_charging_led(&last_chg_state, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,6 +206,7 @@ static int bind_modem_socket(modem_ctx_t *ctx) {
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
modem_ctx_t ctx;
|
||||
memset(&ctx, 0, sizeof(ctx));
|
||||
ctx.srv_fd = -1;
|
||||
|
||||
@@ -193,7 +193,8 @@ static void lock_x11_session(void) {
|
||||
if (access("/tmp/.X11-unix/X0", F_OK) != 0) return;
|
||||
if (is_lock_running()) return;
|
||||
|
||||
struct passwd *pw = getpwnam("user");
|
||||
struct passwd *pw = getpwuid(10000);
|
||||
if (!pw) pw = getpwnam("user");
|
||||
if (!pw) return;
|
||||
|
||||
int pfd[2];
|
||||
@@ -373,6 +374,7 @@ static int setup_uevent_socket(void) {
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
powerd_ctx_t ctx;
|
||||
memset(&ctx, 0, sizeof(ctx));
|
||||
ctx.saved_brightness = 128;
|
||||
|
||||
+80
-14
@@ -1,18 +1,57 @@
|
||||
#!/bin/sh
|
||||
# Geminux initramfs init (normal boot + off-mode charger guard + safe rootfs e2fsck/resize)
|
||||
# Geminux initramfs init (off-mode charger guard + optional LUKS2 FDE unlock + safe rootfs e2fsck/resize)
|
||||
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
|
||||
export DM_DISABLE_UDEV=1
|
||||
|
||||
mkdir -p /proc /sys /dev /dev/pts /run /mnt/root
|
||||
mkdir -p /proc /sys /dev /dev/pts /dev/mapper /run /run/cryptsetup /mnt/root
|
||||
mount -t proc proc /proc
|
||||
mount -t sysfs sysfs /sys
|
||||
mount -t devtmpfs devtmpfs /dev
|
||||
mkdir -p /dev/pts
|
||||
mkdir -p /dev/pts /dev/mapper /run/cryptsetup
|
||||
chmod 0700 /run/cryptsetup
|
||||
mount -t devpts devpts /dev/pts 2>/dev/null || true
|
||||
|
||||
if [ ! -c /dev/mapper/control ] && [ -r /sys/class/misc/device-mapper/dev ]; then
|
||||
IFS=: read -r maj min < /sys/class/misc/device-mapper/dev
|
||||
mknod /dev/mapper/control c "$maj" "$min" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
if command -v loadkmap >/dev/null 2>&1 && [ -f /etc/gemini-us.kmap ]; then
|
||||
loadkmap < /etc/gemini-us.kmap >/dev/tty1 2>/dev/null || \
|
||||
loadkmap < /etc/gemini-us.kmap 2>/dev/null || true
|
||||
fi
|
||||
|
||||
set_console_quiet() {
|
||||
echo 3 > /proc/sys/kernel/printk 2>/dev/null || true
|
||||
}
|
||||
|
||||
tty_msg() {
|
||||
if [ -c /dev/tty1 ]; then
|
||||
printf '%s\n' "$1" > /dev/tty1 2>/dev/null || echo "$1"
|
||||
else
|
||||
echo "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
ensure_dm_node() {
|
||||
name="$1"
|
||||
[ -b "/dev/mapper/$name" ] && return 0
|
||||
for dmp in /sys/class/block/dm-*; do
|
||||
[ -r "$dmp/dm/name" ] || continue
|
||||
if [ "$(cat "$dmp/dm/name" 2>/dev/null)" = "$name" ]; then
|
||||
dmdev="$(basename "$dmp")"
|
||||
if [ -b "/dev/$dmdev" ]; then
|
||||
ln -sf "/dev/$dmdev" "/dev/mapper/$name"
|
||||
return 0
|
||||
elif [ -r "$dmp/dev" ]; then
|
||||
IFS=: read -r maj min < "$dmp/dev"
|
||||
mknod "/dev/mapper/$name" b "$maj" "$min" 2>/dev/null && return 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
set_console_quiet
|
||||
|
||||
is_charger_mode() {
|
||||
@@ -63,15 +102,17 @@ find_root_dev() {
|
||||
echo /dev/disk/by-partlabel/linux
|
||||
return 0
|
||||
fi
|
||||
for p in /proc/cmdline; do
|
||||
:
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
emergency_shell() {
|
||||
tty_msg "[geminux-init] ERROR: $1"
|
||||
tty_msg "[geminux-init] Dropping to initramfs emergency shell."
|
||||
echo "[geminux-init] ERROR: $1"
|
||||
echo "[geminux-init] Dropping to initramfs emergency shell."
|
||||
if [ -c /dev/tty1 ]; then
|
||||
exec /bin/sh -i </dev/tty1 >/dev/tty1 2>&1
|
||||
fi
|
||||
exec /bin/sh
|
||||
}
|
||||
|
||||
@@ -79,19 +120,39 @@ if is_charger_mode; then
|
||||
run_offmode_charger
|
||||
fi
|
||||
|
||||
ROOT_DEV=""
|
||||
tty_msg "[geminux] Booting Geminux initramfs..."
|
||||
|
||||
RAW_ROOT_DEV=""
|
||||
i=0
|
||||
while [ "$i" -lt 60 ]; do
|
||||
ROOT_DEV="$(find_root_dev || true)"
|
||||
[ -n "$ROOT_DEV" ] && break
|
||||
RAW_ROOT_DEV="$(find_root_dev || true)"
|
||||
[ -n "$RAW_ROOT_DEV" ] && break
|
||||
usleep 250000 2>/dev/null || sleep 1
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
[ -n "$ROOT_DEV" ] || emergency_shell "PARTLABEL=linux root block device not found"
|
||||
[ -n "$RAW_ROOT_DEV" ] || emergency_shell "PARTLABEL=linux root block device not found"
|
||||
|
||||
ROOT_DEV="$RAW_ROOT_DEV"
|
||||
if command -v cryptsetup >/dev/null 2>&1 && cryptsetup isLuks "$RAW_ROOT_DEV" >/dev/null 2>&1; then
|
||||
[ -c /dev/tty1 ] || emergency_shell "LUKS2 encrypted rootfs detected but /dev/tty1 unavailable"
|
||||
printf '\n=======================================================\n' > /dev/tty1 2>/dev/null || true
|
||||
printf ' Geminux Full-Disk Encryption (LUKS2)\n' > /dev/tty1 2>/dev/null || true
|
||||
printf ' Unlocking %s ...\n' "$RAW_ROOT_DEV" > /dev/tty1 2>/dev/null || true
|
||||
printf '=======================================================\n\n' > /dev/tty1 2>/dev/null || true
|
||||
while ! ensure_dm_node geminux_root; do
|
||||
if cryptsetup open --allow-discards "$RAW_ROOT_DEV" geminux_root </dev/tty1 >/dev/tty1 2>&1; then
|
||||
ensure_dm_node geminux_root && break
|
||||
fi
|
||||
printf '\n[geminux-init] Incorrect passphrase or unlock error; please try again.\n\n' > /dev/tty1 2>/dev/null || true
|
||||
sleep 1
|
||||
done
|
||||
ROOT_DEV="/dev/mapper/geminux_root"
|
||||
tty_msg "[geminux] Unlocked PARTLABEL=linux; checking root filesystem..."
|
||||
fi
|
||||
|
||||
if command -v e2fsck >/dev/null 2>&1; then
|
||||
e2fsck -p "$ROOT_DEV" >/dev/null 2>&1 || {
|
||||
e2fsck -p "$ROOT_DEV" </dev/null >/dev/null 2>&1 || {
|
||||
rc=$?
|
||||
[ "$rc" -le 1 ] || echo "[geminux-init] Warning: e2fsck returned $rc on $ROOT_DEV"
|
||||
}
|
||||
@@ -105,12 +166,16 @@ if [ ! -f /mnt/root/var/lib/geminux/.rootfs-resized ]; then
|
||||
fi
|
||||
umount /mnt/root
|
||||
|
||||
if [ "$NEEDS_RESIZE" = "1" ] && command -v resize2fs >/dev/null 2>&1; then
|
||||
if [ "$NEEDS_RESIZE" = "1" ]; then
|
||||
tty_msg "[geminux] First boot: expanding ext4 filesystem to full partition (~15-30s)..."
|
||||
if command -v resize2fs >/dev/null 2>&1; then
|
||||
echo "[geminux-init] Expanding $ROOT_DEV to fill full partition..."
|
||||
resize2fs -f "$ROOT_DEV" >/dev/null 2>&1 || true
|
||||
resize2fs -f "$ROOT_DEV" </dev/null >/dev/null 2>&1 || true
|
||||
if command -v e2fsck >/dev/null 2>&1; then
|
||||
e2fsck -p "$ROOT_DEV" >/dev/null 2>&1 || true
|
||||
e2fsck -p "$ROOT_DEV" </dev/null >/dev/null 2>&1 || true
|
||||
fi
|
||||
fi
|
||||
tty_msg "[geminux] Filesystem expansion complete; starting Geminux..."
|
||||
fi
|
||||
|
||||
mount -t ext4 -o rw,noatime,commit=60 "$ROOT_DEV" /mnt/root || \
|
||||
@@ -123,6 +188,7 @@ fi
|
||||
|
||||
[ -x /mnt/root/sbin/init ] || emergency_shell "/sbin/init missing on $ROOT_DEV"
|
||||
|
||||
unset DM_DISABLE_UDEV
|
||||
umount /dev/pts 2>/dev/null || true
|
||||
mount --move /dev /mnt/root/dev
|
||||
mount --move /sys /mnt/root/sys
|
||||
|
||||
+66
-33
@@ -1,15 +1,23 @@
|
||||
#!/bin/sh
|
||||
# Geminux recovery initramfs init (USB NCM/RNDIS gadget 172.16.42.1 + interactive repair)
|
||||
# Geminux recovery initramfs init (USB NCM/RNDIS gadget 172.16.42.1 + LUKS2-aware repair)
|
||||
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
|
||||
export DM_DISABLE_UDEV=1
|
||||
|
||||
mkdir -p /proc /sys /dev /dev/pts /run /tmp /mnt/linux /sys/kernel/config
|
||||
mkdir -p /proc /sys /dev /dev/pts /dev/mapper /run /run/cryptsetup /tmp /mnt/linux /sys/kernel/config
|
||||
chmod 0700 /run/cryptsetup
|
||||
mount -t proc proc /proc
|
||||
mount -t sysfs sysfs /sys
|
||||
mount -t devtmpfs devtmpfs /dev
|
||||
mkdir -p /dev/pts
|
||||
mkdir -p /dev/pts /dev/mapper /run/cryptsetup
|
||||
chmod 0700 /run/cryptsetup
|
||||
mount -t devpts devpts /dev/pts 2>/dev/null || true
|
||||
mount -t configfs configfs /sys/kernel/config 2>/dev/null || true
|
||||
|
||||
if [ ! -c /dev/mapper/control ] && [ -r /sys/class/misc/device-mapper/dev ]; then
|
||||
IFS=: read -r maj min < /sys/class/misc/device-mapper/dev
|
||||
mknod /dev/mapper/control c "$maj" "$min" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
setup_usb_gadget() {
|
||||
G=/sys/kernel/config/usb_gadget/geminux
|
||||
[ -d /sys/kernel/config/usb_gadget ] || return 0
|
||||
@@ -33,17 +41,6 @@ setup_usb_gadget() {
|
||||
ip addr add 172.16.42.1/24 dev usb0 2>/dev/null || true
|
||||
}
|
||||
|
||||
find_root_dev() {
|
||||
for p in /sys/class/block/*/uevent; do
|
||||
[ -f "$p" ] || continue
|
||||
if grep -q '^PARTNAME=linux$' "$p" 2>/dev/null; then
|
||||
devname="$(basename "$(dirname "$p")")"
|
||||
[ -b "/dev/$devname" ] && echo "/dev/$devname" && return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
setup_usb_gadget
|
||||
|
||||
cat <<'EOF' > /dev/tty1 2>/dev/null || true
|
||||
@@ -52,40 +49,76 @@ cat <<'EOF' > /dev/tty1 2>/dev/null || true
|
||||
=======================================================
|
||||
USB Gadget IP : 172.16.42.1/24
|
||||
Commands:
|
||||
check-fs : Run e2fsck -fy on PARTLABEL=linux
|
||||
mount-root : Mount PARTLABEL=linux at /mnt/linux
|
||||
unlock-root : Unlock LUKS2 PARTLABEL=linux -> /dev/mapper/geminux_root
|
||||
check-fs : Run e2fsck -fy on root (unlocks LUKS2 if needed)
|
||||
mount-root : Mount root at /mnt/linux (unlocks LUKS2 if needed)
|
||||
reboot : Reboot normally
|
||||
=======================================================
|
||||
EOF
|
||||
|
||||
cat <<'EOF' > /bin/unlock-root
|
||||
#!/bin/sh
|
||||
export DM_DISABLE_UDEV=1
|
||||
find_raw() {
|
||||
for p in /sys/class/block/*/uevent; do
|
||||
[ -f "$p" ] || continue
|
||||
if grep -q '^PARTNAME=linux$' "$p" 2>/dev/null; then
|
||||
echo "/dev/$(basename "$(dirname "$p")")"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
ensure_dm_node() {
|
||||
name="$1"
|
||||
[ -b "/dev/mapper/$name" ] && return 0
|
||||
for dmp in /sys/class/block/dm-*; do
|
||||
[ -r "$dmp/dm/name" ] || continue
|
||||
if [ "$(cat "$dmp/dm/name" 2>/dev/null)" = "$name" ]; then
|
||||
dmdev="$(basename "$dmp")"
|
||||
if [ -b "/dev/$dmdev" ]; then
|
||||
ln -sf "/dev/$dmdev" "/dev/mapper/$name"
|
||||
return 0
|
||||
elif [ -r "$dmp/dev" ]; then
|
||||
IFS=: read -r maj min < "$dmp/dev"
|
||||
mknod "/dev/mapper/$name" b "$maj" "$min" 2>/dev/null && return 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
d="${1:-$(find_raw || true)}"
|
||||
[ -n "$d" ] || { echo "PARTLABEL=linux not found"; exit 1; }
|
||||
if ensure_dm_node geminux_root; then
|
||||
echo "/dev/mapper/geminux_root"
|
||||
exit 0
|
||||
fi
|
||||
if command -v cryptsetup >/dev/null 2>&1 && cryptsetup isLuks "$d" >/dev/null 2>&1; then
|
||||
cryptsetup open --allow-discards "$d" geminux_root || exit 1
|
||||
ensure_dm_node geminux_root || true
|
||||
echo "/dev/mapper/geminux_root"
|
||||
else
|
||||
echo "$d"
|
||||
fi
|
||||
EOF
|
||||
|
||||
cat <<'EOF' > /bin/check-fs
|
||||
#!/bin/sh
|
||||
for p in /sys/class/block/*/uevent; do
|
||||
if grep -q '^PARTNAME=linux$' "$p" 2>/dev/null; then
|
||||
d="/dev/$(basename "$(dirname "$p")")"
|
||||
exec e2fsck -fy "$d"
|
||||
fi
|
||||
done
|
||||
echo "PARTLABEL=linux not found"
|
||||
exit 1
|
||||
t="$(/bin/unlock-root)" || exit 1
|
||||
exec e2fsck -fy "$t"
|
||||
EOF
|
||||
|
||||
cat <<'EOF' > /bin/mount-root
|
||||
#!/bin/sh
|
||||
mkdir -p /mnt/linux
|
||||
for p in /sys/class/block/*/uevent; do
|
||||
if grep -q '^PARTNAME=linux$' "$p" 2>/dev/null; then
|
||||
d="/dev/$(basename "$(dirname "$p")")"
|
||||
exec mount -t ext4 "$d" /mnt/linux
|
||||
fi
|
||||
done
|
||||
echo "PARTLABEL=linux not found"
|
||||
exit 1
|
||||
t="$(/bin/unlock-root)" || exit 1
|
||||
exec mount -t ext4 "$t" /mnt/linux
|
||||
EOF
|
||||
|
||||
chmod +x /bin/check-fs /bin/mount-root
|
||||
chmod +x /bin/unlock-root /bin/check-fs /bin/mount-root
|
||||
|
||||
if command -v loadkmap >/dev/null 2>&1 && [ -f /etc/gemini-us.kmap ]; then
|
||||
loadkmap < /etc/gemini-us.kmap >/dev/tty1 2>/dev/null || \
|
||||
loadkmap < /etc/gemini-us.kmap 2>/dev/null || true
|
||||
fi
|
||||
|
||||
|
||||
@@ -981,7 +981,8 @@ int gemui_unix_cmd(const char *sock_path, const char *cmd, char *resp, size_t re
|
||||
return -1;
|
||||
}
|
||||
size_t len = strlen(cmd);
|
||||
if (write(fd, cmd, len) < 0 || (len == 0 || cmd[len - 1] != '\n' ? write(fd, "\n", 1) < 0 : 0)) {
|
||||
if (send(fd, cmd, len, MSG_NOSIGNAL) < 0 ||
|
||||
((len == 0 || cmd[len - 1] != '\n') ? send(fd, "\n", 1, MSG_NOSIGNAL) < 0 : 0)) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
@@ -989,11 +990,14 @@ int gemui_unix_cmd(const char *sock_path, const char *cmd, char *resp, size_t re
|
||||
if (resp && resp_sz > 0) {
|
||||
size_t off = 0;
|
||||
while (off + 1 < resp_sz) {
|
||||
ssize_t n = read(fd, resp + off, resp_sz - 1 - off);
|
||||
ssize_t n = recv(fd, resp + off, resp_sz - 1 - off, 0);
|
||||
if (n <= 0) break;
|
||||
off += (size_t)n;
|
||||
}
|
||||
resp[off] = '\0';
|
||||
} else {
|
||||
char sink[64];
|
||||
while (recv(fd, sink, sizeof(sink), 0) > 0) {}
|
||||
}
|
||||
close(fd);
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user