Add microSD /media/sdcard automount, user permissions, dosfstools PATH, and docs

This commit is contained in:
Luxferre committed 2026-11-23 15:17:26 +02:00
1 parent e01806f3c8
commit e3abc6d993
13 files changed
+483 -11

No files matched your search

+2 -2
View File
@@ -49,8 +49,8 @@ To keep Alpine Edge `aarch64` userspace freely updatable while locking all hardw
- `geminux-mpv` (`mpv v0.40.0`, `ffmpeg`, `ffprobe`, private `libplacebo`/FFmpeg shared libs, and `libgstlibav.so` built via [scripts/build-mpv.sh](file:///home/lux/proj/geminux/scripts/build-mpv.sh)) - `geminux-mpv` (`mpv v0.40.0`, `ffmpeg`, `ffprobe`, private `libplacebo`/FFmpeg shared libs, and `libgstlibav.so` built via [scripts/build-mpv.sh](file:///home/lux/proj/geminux/scripts/build-mpv.sh))
- `geminux-gdk-pixbuf` (pure-C zero-glycin `gdk-pixbuf 2.42.12` built via [scripts/build-webarchy.sh](file:///home/lux/proj/geminux/scripts/build-webarchy.sh)) - `geminux-gdk-pixbuf` (pure-C zero-glycin `gdk-pixbuf 2.42.12` built via [scripts/build-webarchy.sh](file:///home/lux/proj/geminux/scripts/build-webarchy.sh))
- `geminux-webarchy` (`webarchy` / `xwebarchy` browser built via [scripts/build-webarchy.sh](file:///home/lux/proj/geminux/scripts/build-webarchy.sh)) - `geminux-webarchy` (`webarchy` / `xwebarchy` browser built via [scripts/build-webarchy.sh](file:///home/lux/proj/geminux/scripts/build-webarchy.sh))
- `geminux-config` (includes `/etc/htoprc`, `/etc/skel/.config/htop/htoprc`, `/etc/skel/.lynx.cfg`, `/etc/skel/.apexrc`, `/etc/skel/.bashrc` with `GPG_TTY`) - `geminux-config` (includes `/etc/htoprc`, `/etc/skel/.config/htop/htoprc`, `/etc/skel/.lynx.cfg`, `/etc/skel/.apexrc`, `/etc/skel/.bashrc` with `GPG_TTY`, `/etc/profile.d/10-geminux-env.sh` adding `sbin` paths for `dosfstools`, and `/etc/init.d/geminux-sdcard` + `/etc/udev/rules.d/95-geminux-sdcard.rules` + `/usr/sbin/geminux-sdcard-mount` for boot/`eudev` hotplug automounting of `/dev/mmcblk1p1` or superfloppy `/dev/mmcblk1` into `/media/sdcard` with `UID 10000` + `plugdev` `0660`/`0775` permissions across `vfat`, `exfat`, and POSIX `ext4`/`ext3`/`ext2`)
3. `/etc/apk/world` pins all eleven 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). Verified automatically by an ELF binary Rust scan, `apk upgrade --simulate`, and 7 host Python unit suites in [scripts/check-rebuild.sh](file:///home/lux/proj/geminux/scripts/check-rebuild.sh). 3. `/etc/apk/world` pins all eleven 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). Verified automatically by an ELF binary Rust scan, `apk upgrade --simulate`, and 8 host Python unit suites in [scripts/check-rebuild.sh](file:///home/lux/proj/geminux/scripts/check-rebuild.sh).
4. `/etc/apk/protected_paths.d/geminux.list` shields Geminux configuration directories across upgrades. 4. `/etc/apk/protected_paths.d/geminux.list` shields Geminux configuration directories across upgrades.
## Pure-Linux flasher and eMMC layout ## Pure-Linux flasher and eMMC layout
+1 -1
View File
@@ -118,4 +118,4 @@ Perform these checks on physical hardware after the first boot:
- [ ] Confirm Glamor 3D acceleration via `glxinfo | grep -i renderer`. - [ ] 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). - [ ] 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`). - [ ] 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`).
- [ ] Test front camera preview/JPEG/AVI capture (`geminux-camera`), external HDMI output (`SiI9024`), lid-close S3 suspend, and `geminux-power-audit`. - [ ] Test front camera preview/JPEG/AVI capture (`geminux-camera`), external HDMI output (`SiI9024`), microSD card automount at `/media/sdcard` (`geminux-sdcard-mount status`), lid-close S3 suspend, and `geminux-power-audit`.
+2 -1
View File
@@ -63,7 +63,8 @@ geminux-apply-theme TokyoNight
- **Connectivity**: `geminux-net` manages Wi-Fi (`nmcli`, keeping the currently associated WLAN connection pinned at the top with a `Disconnect` control), 4G/CCCI state (`mmcli` + `/run/geminux/ccci.sock`), Bluetooth (`bluetoothctl` / `rfkill`), SiI9024 external HDMI output (`xrandr`), and the **`DNS` tab** (`geminux-dnsctl`, supporting router-provided Default DNS, Cloudflare, Google, RadicalDNS, Quad9, custom IPv4/IPv6 nameservers, and live DNS lookup testing). - **Connectivity**: `geminux-net` manages Wi-Fi (`nmcli`, keeping the currently associated WLAN connection pinned at the top with a `Disconnect` control), 4G/CCCI state (`mmcli` + `/run/geminux/ccci.sock`), Bluetooth (`bluetoothctl` / `rfkill`), SiI9024 external HDMI output (`xrandr`), and the **`DNS` tab** (`geminux-dnsctl`, supporting router-provided Default DNS, Cloudflare, Google, RadicalDNS, Quad9, custom IPv4/IPv6 nameservers, and live DNS lookup testing).
- **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/`. - **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`, resolving the desktop account dynamically from UID `10000` (`--username` or default `user`). `geminux-powerd` implements an input-driven screensaver: on battery it dims then triggers `geminux-lock` + suspend, while on AC / `performance` it triggers `geminux-lock` + backlight blanking (waking back onto the lock screen on key, touch, pointer, or power-button activity), timed strictly from the last active user input. - **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`, resolving the desktop account dynamically from UID `10000` (`--username` or default `user`). `geminux-powerd` implements an input-driven screensaver: on battery it dims then triggers `geminux-lock` + suspend, while on AC / `performance` it triggers `geminux-lock` + backlight blanking (waking back onto the lock screen on key, touch, pointer, or power-button activity), timed strictly from the last active user input.
- **CLI developer, media & security tools**: Zero-Rust `mpv` (`/etc/mpv/mpv.conf` with Panfrost X11 EGL + PipeWire) & `ffmpeg`/`ffprobe`, `mpg123`, `yt-dlp` (`yt-dlp-ejs-rt-quickjs`), `python3` & `pip3` (`py3-pip`), `gpg` (`gnupg` + `pinentry-curses` + `GPG_TTY`), `pass`, `bantam` (`geminux-bantam`, minimalist C++20 OpenAI-compatible terminal AI agent defaulting to `kilo-auto/free`; see [src/bantam/README.md](file:///home/lux/proj/geminux/src/bantam/README.md)), `lynx` (configured via `~/.lynx.cfg` with `http://frogfind.com` start page, UTF-8, vi keys, mouse support, and persistent sessions/cookies), `gsocket` (`gs-netcat` plus `gs-key`/`gs-enter`/`gs-deploy-cmd`), `dtach` (`dmux`), `ovault`, default `htop` layout (`/etc/htoprc` / `~/.config/htop/htoprc`), `/etc/skel/.apexrc` defaults (`EDITOR='nano -FEDSMAGic/max%_T2'`, `PAGER='less -RXF'`, `nn`, `pg`, `l`, `defalias`/`toalias`/`savealias`, `rw`/`ee`, `sshed`, `dl`, `gcm`/`gp`/`gpm`, `sloc`, and `doas`-aware `pkgadd`/`pkgdel`/`pkgsearch`/`sysup`/`sysclean`), and `/etc/skel/.gitconfig` are preinstalled. - **microSD card automount (`/media/sdcard`)**: Automatically checks (`fsck.fat -a`, `fsck.exfat -p`, `e2fsck -p`) and mounts `/dev/mmcblk1p1` (or unpartitioned superfloppy `/dev/mmcblk1`) at `/media/sdcard` on boot (`geminux-sdcard` OpenRC service) and `eudev` hotplug (`95-geminux-sdcard.rules` -> `/usr/sbin/geminux-sdcard-mount`), cleanly unmounting on card removal or shutdown. Normal desktop users (`UID 10000` in `plugdev` `GID 106`) receive full read/write access: `0660` `plugdev` nodes on `/dev/mmcblk1*`, `uid=10000,gid=106,fmask=0002,dmask=0002,allow_utime=0020` on `vfat`/`exfat` (plus `quiet` on `vfat`), and `10000:106` ownership + `02775` setgid `plugdev` (`u+rwX,g+rwX`, preserving `lost+found`) on writable `ext4`/`ext3`/`ext2` cards. Inspect or manage manually via `geminux-sdcard-mount status`, `geminux-sdcard-mount remove` (before physical eject), or `geminux-sdcard-mount add` (auto-escalating via `doas`), and format/label/repair FAT cards with `dosfstools` (`mkfs.vfat`, `fsck.vfat`, `fatlabel`, included in default shell `PATH`).
- **CLI developer, media & security tools**: Zero-Rust `mpv` (`/etc/mpv/mpv.conf` with Panfrost X11 EGL + PipeWire) & `ffmpeg`/`ffprobe`, `mpg123`, `yt-dlp` (`yt-dlp-ejs-rt-quickjs`), `python3` & `pip3` (`py3-pip`), `gpg` (`gnupg` + `pinentry-curses` + `GPG_TTY`), `pass`, `dosfstools` (`mkfs.vfat`, `fsck.vfat`, `fatlabel`), `bantam` (`geminux-bantam`, minimalist C++20 OpenAI-compatible terminal AI agent defaulting to `kilo-auto/free`; see [src/bantam/README.md](file:///home/lux/proj/geminux/src/bantam/README.md)), `lynx` (configured via `~/.lynx.cfg` with `http://frogfind.com` start page, UTF-8, vi keys, mouse support, and persistent sessions/cookies), `gsocket` (`gs-netcat` plus `gs-key`/`gs-enter`/`gs-deploy-cmd`), `dtach` (`dmux`), `ovault`, default `htop` layout (`/etc/htoprc` / `~/.config/htop/htoprc`), `/etc/skel/.apexrc` defaults (`EDITOR='nano -FEDSMAGic/max%_T2'`, `PAGER='less -RXF'`, `nn`, `pg`, `l`, `defalias`/`toalias`/`savealias`, `rw`/`ee`, `sshed`, `dl`, `gcm`/`gp`/`gpm`, `sloc`, and `doas`-aware `pkgadd`/`pkgdel`/`pkgsearch`/`sysup`/`sysclean`), and `/etc/skel/.gitconfig` are preinstalled.
## Maintaining Alpine Edge packages safely ## Maintaining Alpine Edge packages safely
+1 -1
View File
@@ -42,7 +42,7 @@ Closing the Gemini PDA clamshell (`SW_LID = 1`) suspends immediately to RAM (`me
- **Audio**: PipeWire uses `default.clock.min-quantum = 1024` and `quantum = 2048` (`10-geminux-power.conf`); WirePlumber suspends idle ALSA and BlueZ nodes after `3` seconds (`50-geminux-suspend.conf`) so audio DSP clocks gate quickly. - **Audio**: PipeWire uses `default.clock.min-quantum = 1024` and `quantum = 2048` (`10-geminux-power.conf`); WirePlumber suspends idle ALSA and BlueZ nodes after `3` seconds (`50-geminux-suspend.conf`) so audio DSP clocks gate quickly.
- **Bluetooth**: `bluetooth` OpenRC service is disabled from default boot (`AutoEnable=false` in `etc/bluetooth/main.conf`); users toggle Bluetooth on demand via `geminux-net`. - **Bluetooth**: `bluetooth` OpenRC service is disabled from default boot (`AutoEnable=false` in `etc/bluetooth/main.conf`); users toggle Bluetooth on demand via `geminux-net`.
- **Wi-Fi**: NetworkManager configures `wifi.powersave = 2` (`10-geminux-power.conf`) to keep CONSYS Wi-Fi awake while associated so GTK rekeys, ARP, and DNS never stall; the radio still powers down cleanly on Wi-Fi toggle-off or system S3 suspend. - **Wi-Fi**: NetworkManager configures `wifi.powersave = 2` (`10-geminux-power.conf`) to keep CONSYS Wi-Fi awake while associated so GTK rekeys, ARP, and DNS never stall; the radio still powers down cleanly on Wi-Fi toggle-off or system S3 suspend.
- **Storage**: `noatime,commit=60` in `etc/fstab` alongside `vm.dirty_writeback_centisecs=1500` reduces eMMC write amplification and wakes. - **Storage**: `noatime,commit=60` in `etc/fstab` alongside `vm.dirty_writeback_centisecs=1500` reduces eMMC write amplification and wakes; microSD mounts at `/media/sdcard` likewise mount with `noatime` and rely purely on `eudev` hotplug events (`95-geminux-sdcard.rules`) with zero background polling when idle or empty.
## Auditing on device ## Auditing on device
+4 -4
View File
@@ -1,6 +1,6 @@
# Geminux # 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, 11 landscape HiDPI applications (`libgemui.so`), the ported Webarchy ultrawide `GTK3`/`WebKit2GTK` browser (`geminux-webarchy`, right-side vertical tab bar), zero-Rust `mpv` + `ffmpeg` (`geminux-mpv`), `mpg123`, `yt-dlp`, `python3`/`pip`, `gpg` (`gnupg`), `pass`, the preinstalled `bantam` CLI AI agent (`geminux-bantam`, `kilo-auto/free` default), `lynx`, `gsocket`, and a pure-Linux MediaTek flasher with account provisioning and optional LUKS2 full-disk encryption. 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 ported Webarchy ultrawide `GTK3`/`WebKit2GTK` browser (`geminux-webarchy`, right-side vertical tab bar), zero-Rust `mpv` + `ffmpeg` (`geminux-mpv`), `mpg123`, `yt-dlp`, `python3`/`pip`, `gpg` (`gnupg`), `pass`, `dosfstools`, boot/hotplug `/media/sdcard` microSD automount (`geminux-sdcard` / `eudev`), the preinstalled `bantam` CLI AI agent (`geminux-bantam`, `kilo-auto/free` default), `lynx`, `gsocket`, and a pure-Linux MediaTek flasher with account provisioning and optional LUKS2 full-disk encryption.
## Key design goals ## Key design goals
@@ -22,7 +22,7 @@ Geminux is an Alpine Linux (`aarch64`, musl, OpenRC) distribution built specific
| 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) | | 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) |
| Web browser | Webarchy C++20 `GTK3` + `WebKit2GTK-4.1` ultrawide browser (right-side vertical tab bar, DPI-scaled `.Xresources` `SIGUSR1` theming) + pure-C `gdk-pixbuf 2.42.12` | [scripts/build-webarchy.sh](file:///home/lux/proj/geminux/scripts/build-webarchy.sh), [scripts/compile-gsettings-schemas.sh](file:///home/lux/proj/geminux/scripts/compile-gsettings-schemas.sh) | | Web browser | Webarchy C++20 `GTK3` + `WebKit2GTK-4.1` ultrawide browser (right-side vertical tab bar, DPI-scaled `.Xresources` `SIGUSR1` theming) + pure-C `gdk-pixbuf 2.42.12` | [scripts/build-webarchy.sh](file:///home/lux/proj/geminux/scripts/build-webarchy.sh), [scripts/compile-gsettings-schemas.sh](file:///home/lux/proj/geminux/scripts/compile-gsettings-schemas.sh) |
| UI & system daemons | `libgemui.so`, 11 landscape HiDPI apps (`geminux-net` DNS tab + active WLAN persistence), zero-poll C11 daemons (`geminux-dnsctl`, etc.) | [scripts/build-geminux-ui.sh](file:///home/lux/proj/geminux/scripts/build-geminux-ui.sh) | | UI & system daemons | `libgemui.so`, 11 landscape HiDPI apps (`geminux-net` DNS tab + active WLAN persistence), zero-poll C11 daemons (`geminux-dnsctl`, etc.) | [scripts/build-geminux-ui.sh](file:///home/lux/proj/geminux/scripts/build-geminux-ui.sh) |
| Media & CLI tools | Zero-Rust `mpv v0.40.0` (Panfrost X11 EGL + PipeWire), `ffmpeg`/`ffprobe`, `libgstlibav.so`, `mpg123`, `yt-dlp` (`quickjs`), `python3`/`pip3`, `gpg` (`gnupg`), `pass`, `bantam`, `lynx`, `gsocket`, `.apexrc`, default `htoprc` | [scripts/build-mpv.sh](file:///home/lux/proj/geminux/scripts/build-mpv.sh), [scripts/build-bantam.sh](file:///home/lux/proj/geminux/scripts/build-bantam.sh), [scripts/build-gsocket.sh](file:///home/lux/proj/geminux/scripts/build-gsocket.sh) | | Media & CLI tools | Zero-Rust `mpv v0.40.0` (Panfrost X11 EGL + PipeWire), `ffmpeg`/`ffprobe`, `libgstlibav.so`, `mpg123`, `yt-dlp` (`quickjs`), `python3`/`pip3`, `gpg` (`gnupg`), `pass`, `dosfstools` (`mkfs.vfat`/`fsck.vfat`/`fatlabel`), `bantam`, `lynx`, `gsocket`, `.apexrc`, default `htoprc` | [scripts/build-mpv.sh](file:///home/lux/proj/geminux/scripts/build-mpv.sh), [scripts/build-bantam.sh](file:///home/lux/proj/geminux/scripts/build-bantam.sh), [scripts/build-gsocket.sh](file:///home/lux/proj/geminux/scripts/build-gsocket.sh) |
| Local APK repository | 11 signed `@geminux` `.apk` packages + `APKINDEX.tar.gz` | [scripts/package-local-apks.sh](file:///home/lux/proj/geminux/scripts/package-local-apks.sh) | | Local APK repository | 11 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) | | 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) |
@@ -30,13 +30,13 @@ Geminux is an Alpine Linux (`aarch64`, musl, OpenRC) distribution built specific
- [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 - [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`, `bantam`, `webarchy`, `libgemui`, `geminux-apps`, and `geminux-daemons` - [src/](file:///home/lux/proj/geminux/src) — initramfs scripts, `st`, `dwm`, `dmenu`, `dunst-notify`, `bantam`, `webarchy`, `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 - [overlay/rootfs/](file:///home/lux/proj/geminux/overlay/rootfs) — OpenRC services (including `geminux-sdcard`), ALSA UCM2, XKB layout, console keymap, Xorg drop-ins, 21 `.xth` themes, PipeWire/WirePlumber, udev (`95-geminux-sdcard.rules` microSD automount to `/media/sdcard`), and NetworkManager configs
- [scripts/](file:///home/lux/proj/geminux/scripts) — cross-compilation builders, APK packager, rootfs bootstrapper, verification suite, and unit tests - [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) - [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 ## Verification status vs. on-device testing
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, Webarchy renderer profile & WebKit GSettings schema 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). 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, Webarchy renderer profile & WebKit GSettings schema tests, `dosfstools` & `/media/sdcard` automount 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).
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 (`geminux-net` DNS tab & associated WLAN persistence), Webarchy ultrawide Panfrost GPU rendering, 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). 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 (`geminux-net` DNS tab & associated WLAN persistence), Webarchy ultrawide Panfrost GPU rendering, 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).
@@ -3,5 +3,6 @@ permit nopass :wheel as root cmd /usr/bin/geminux-power-ctl
permit nopass :wheel as root cmd /usr/sbin/geminux-checkpw permit nopass :wheel as root cmd /usr/sbin/geminux-checkpw
permit nopass :wheel as root cmd /usr/sbin/geminux-tzctl permit nopass :wheel as root cmd /usr/sbin/geminux-tzctl
permit nopass :wheel as root cmd /usr/sbin/geminux-dnsctl permit nopass :wheel as root cmd /usr/sbin/geminux-dnsctl
permit nopass :wheel as root cmd /usr/sbin/geminux-sdcard-mount
permit nopass :wheel as root cmd /sbin/poweroff permit nopass :wheel as root cmd /sbin/poweroff
permit nopass :wheel as root cmd /sbin/reboot permit nopass :wheel as root cmd /sbin/reboot
+22
View File
@@ -0,0 +1,22 @@
#!/sbin/openrc-run
# Mount /dev/mmcblk1p1 into /media/sdcard at boot if present, and unmount cleanly on shutdown.
description="Geminux microSD card automount (/dev/mmcblk1p1 -> /media/sdcard)"
depend() {
need localmount
after udev udev-settle modules
}
start() {
ebegin "Checking microSD slot (/dev/mmcblk1p1 -> /media/sdcard)"
mkdir -p /media/sdcard
/usr/sbin/geminux-sdcard-mount add mmcblk1p1
eend $?
}
stop() {
ebegin "Unmounting /media/sdcard if mounted"
/usr/sbin/geminux-sdcard-mount stop
eend 0
}
@@ -5,6 +5,13 @@ export LANGUAGE=en_US.UTF-8
export SHELL=/bin/bash export SHELL=/bin/bash
export TERMINAL=st export TERMINAL=st
export EDITOR=nano export EDITOR=nano
for sbin_dir in /usr/local/sbin /usr/sbin /sbin; do
case ":${PATH:-}:" in
*":${sbin_dir}:"*) ;;
*) export PATH="${PATH:+$PATH:}${sbin_dir}" ;;
esac
done
unset sbin_dir
case ":${PATH:-}:" in case ":${PATH:-}:" in
*":$HOME/.local/bin:"*) ;; *":$HOME/.local/bin:"*) ;;
*) [ -n "${HOME:-}" ] && export PATH="${PATH:+$PATH:}$HOME/.local/bin" ;; *) [ -n "${HOME:-}" ] && export PATH="${PATH:+$PATH:}$HOME/.local/bin" ;;
@@ -0,0 +1,6 @@
# Automount /dev/mmcblk1p1 microSD card into /media/sdcard when present or hotplugged
SUBSYSTEM!="block", GOTO="geminux_sdcard_end"
KERNEL=="mmcblk1|mmcblk1p[0-9]*", GROUP="plugdev", MODE="0660"
ACTION=="add|change", KERNEL=="mmcblk1p1", RUN+="/usr/sbin/geminux-sdcard-mount add %k"
ACTION=="remove", KERNEL=="mmcblk1|mmcblk1p1", RUN+="/usr/sbin/geminux-sdcard-mount remove %k"
LABEL="geminux_sdcard_end"
+243
View File
@@ -0,0 +1,243 @@
#!/bin/sh
# Event-driven SD card automounter for Geminux (/dev/mmcblk1p1 -> /media/sdcard).
# Invoked by eudev (95-geminux-sdcard.rules) and OpenRC (geminux-sdcard).
set -eu
PATH="${PATH:-/usr/bin:/bin}:/usr/local/sbin:/usr/sbin:/sbin"
export PATH
DEV_ROOT="${GEMINUX_DEV_ROOT:-/dev}"
MNT_DIR="${GEMINUX_SDCARD_MNT:-/media/sdcard}"
PROC_MOUNTS="${GEMINUX_PROC_MOUNTS:-/proc/mounts}"
PASSWD_FILE="${GEMINUX_PASSWD_FILE:-/etc/passwd}"
GROUP_FILE="${GEMINUX_GROUP_FILE:-/etc/group}"
LOCK_DIR="${GEMINUX_LOCK_DIR:-/run/geminux-sdcard.lock}"
is_block_dev() {
[ -b "$1" ] || { [ "${GEMINUX_TEST_BLOCK:-0}" = "1" ] && [ -e "$1" ]; }
}
acquire_lock() {
lock_parent="$(dirname "$LOCK_DIR")"
mkdir -p "$lock_parent"
tries=0
while ! mkdir "$LOCK_DIR" 2>/dev/null; do
oldpid="$(cat "$LOCK_DIR/pid" 2>/dev/null || true)"
if [ -n "$oldpid" ] && ! kill -0 "$oldpid" 2>/dev/null; then
rm -rf "$LOCK_DIR"
continue
fi
tries=$((tries + 1))
[ "$tries" -ge 20 ] && return 1
usleep 100000 2>/dev/null || sleep 1
done
printf '%s\n' "$$" > "$LOCK_DIR/pid"
trap 'rm -rf "$LOCK_DIR"' EXIT INT TERM HUP
}
mounted_dev_at() {
[ -r "$PROC_MOUNTS" ] || return 0
awk -v mnt="$1" '$2 == mnt { print $1; exit }' "$PROC_MOUNTS" 2>/dev/null || true
}
resolve_target_dev() {
req="${1:-mmcblk1p1}"
cand="$DEV_ROOT/$req"
if is_block_dev "$cand"; then
printf '%s\n' "$cand"
return 0
fi
if [ "$req" = "mmcblk1p1" ] && is_block_dev "$DEV_ROOT/mmcblk1"; then
raw_type="$(blkid -o value -s TYPE "$DEV_ROOT/mmcblk1" 2>/dev/null || true)"
if [ -n "$raw_type" ]; then
printf '%s\n' "$DEV_ROOT/mmcblk1"
return 0
fi
fi
return 1
}
resolve_desktop_ids() {
ids=""
if [ -r "$PASSWD_FILE" ]; then
ids="$(awk -F: '$3 == 10000 { print $3 ":" $4; exit }' "$PASSWD_FILE" 2>/dev/null || true)"
fi
if [ -z "$ids" ]; then
ids="10000:10000"
fi
printf '%s\n' "$ids"
}
resolve_plugdev_gid() {
fallback_gid="$1"
gid=""
if [ -r "$GROUP_FILE" ]; then
gid="$(awk -F: '$1 == "plugdev" { print $3; exit }' "$GROUP_FILE" 2>/dev/null || true)"
fi
if [ -z "$gid" ]; then
gid="${fallback_gid:-106}"
fi
printf '%s\n' "$gid"
}
is_mounted_rw() {
mnt="$1"
[ -r "$PROC_MOUNTS" ] || return 1
awk -v target="$mnt" '
$2 == target {
n = split($4, opts, ",")
for (i = 1; i <= n; i++) {
if (opts[i] == "rw") {
found = 1
exit 0
}
}
}
END { exit (found ? 0 : 1) }
' "$PROC_MOUNTS"
}
ensure_posix_user_access() {
mnt="$1"
uid="$2"
gid="$3"
is_mounted_rw "$mnt" || return 0
chown "${uid}:${gid}" "$mnt" 2>/dev/null || true
chmod 02775 "$mnt" 2>/dev/null || true
find "$mnt" -mindepth 1 \( -path "${mnt}/lost+found" -prune \) -o \
\( ! -user "$uid" -o ! -group "$gid" \) -exec chown -h "${uid}:${gid}" {} + 2>/dev/null || true
find "$mnt" -mindepth 1 \( -path "${mnt}/lost+found" -prune \) -o \
\( \( -type d ! -perm -0770 \) -o \( ! -type d ! -type l ! -perm -0660 \) \) \
-exec chmod u+rwX,g+rwX {} + 2>/dev/null || true
}
do_add() {
req="${1:-mmcblk1p1}"
DEV_PATH="$(resolve_target_dev "$req" 2>/dev/null || true)"
if [ -z "$DEV_PATH" ]; then
return 0
fi
CUR_DEV="$(mounted_dev_at "$MNT_DIR")"
if [ "$CUR_DEV" = "$DEV_PATH" ]; then
return 0
fi
if [ -n "$CUR_DEV" ]; then
if ! is_block_dev "$CUR_DEV"; then
umount -l "$MNT_DIR" 2>/dev/null || true
else
return 0
fi
fi
FSTYPE="$(blkid -o value -s TYPE "$DEV_PATH" 2>/dev/null || true)"
if [ -z "$FSTYPE" ]; then
return 0
fi
mkdir -p "$MNT_DIR"
IDS="$(resolve_desktop_ids)"
DESK_UID="${IDS%%:*}"
DESK_GID="${IDS#*:}"
PLUGDEV_GID="$(resolve_plugdev_gid "$DESK_GID")"
case "$FSTYPE" in
vfat|fat|msdos)
if command -v fsck.fat >/dev/null 2>&1; then
fsck.fat -a "$DEV_PATH" >/dev/null 2>&1 || true
fi
opts_rw="rw,nosuid,nodev,noatime,uid=${DESK_UID},gid=${PLUGDEV_GID},fmask=0002,dmask=0002,allow_utime=0020,quiet,shortname=mixed,utf8,errors=remount-ro"
opts_ro="ro,nosuid,nodev,noatime,uid=${DESK_UID},gid=${PLUGDEV_GID},fmask=0222,dmask=0222,shortname=mixed,utf8"
mount -t vfat -o "$opts_rw" "$DEV_PATH" "$MNT_DIR" 2>/dev/null || \
mount -t vfat -o "$opts_ro" "$DEV_PATH" "$MNT_DIR"
;;
exfat)
modprobe exfat >/dev/null 2>&1 || true
if command -v fsck.exfat >/dev/null 2>&1; then
fsck.exfat -p "$DEV_PATH" >/dev/null 2>&1 || true
fi
opts_rw="rw,nosuid,nodev,noatime,uid=${DESK_UID},gid=${PLUGDEV_GID},fmask=0002,dmask=0002,allow_utime=0020,iocharset=utf8,errors=remount-ro"
opts_ro="ro,nosuid,nodev,noatime,uid=${DESK_UID},gid=${PLUGDEV_GID},fmask=0222,dmask=0222,iocharset=utf8"
mount -t exfat -o "$opts_rw" "$DEV_PATH" "$MNT_DIR" 2>/dev/null || \
mount -t exfat -o "$opts_ro" "$DEV_PATH" "$MNT_DIR"
;;
ext4|ext3|ext2)
if command -v e2fsck >/dev/null 2>&1; then
e2fsck -p "$DEV_PATH" </dev/null >/dev/null 2>&1 || true
fi
mount -t "$FSTYPE" -o "rw,nosuid,nodev,noatime" "$DEV_PATH" "$MNT_DIR" 2>/dev/null || \
mount -t "$FSTYPE" -o "ro,nosuid,nodev,noatime" "$DEV_PATH" "$MNT_DIR"
ensure_posix_user_access "$MNT_DIR" "$DESK_UID" "$PLUGDEV_GID"
;;
*)
mount -t "$FSTYPE" -o "rw,nosuid,nodev,noatime" "$DEV_PATH" "$MNT_DIR" 2>/dev/null || \
mount -t "$FSTYPE" -o "ro,nosuid,nodev,noatime" "$DEV_PATH" "$MNT_DIR"
ensure_posix_user_access "$MNT_DIR" "$DESK_UID" "$PLUGDEV_GID"
;;
esac
if command -v logger >/dev/null 2>&1; then
logger -t geminux-sdcard "Mounted $DEV_PATH ($FSTYPE) at $MNT_DIR" || true
fi
}
do_remove() {
CUR_DEV="$(mounted_dev_at "$MNT_DIR")"
[ -n "$CUR_DEV" ] || return 0
umount "$MNT_DIR" 2>/dev/null || umount -l "$MNT_DIR" 2>/dev/null || true
if command -v logger >/dev/null 2>&1; then
logger -t geminux-sdcard "Unmounted $MNT_DIR" || true
fi
}
do_stop() {
CUR_DEV="$(mounted_dev_at "$MNT_DIR")"
[ -n "$CUR_DEV" ] || return 0
sync
umount "$MNT_DIR" 2>/dev/null || umount -l "$MNT_DIR" 2>/dev/null || true
}
do_status() {
line=""
if [ -r "$PROC_MOUNTS" ]; then
line="$(awk -v mnt="$MNT_DIR" '$2 == mnt { print $0; exit }' "$PROC_MOUNTS" 2>/dev/null || true)"
fi
if [ -n "$line" ]; then
printf '%s\n' "$line"
elif is_block_dev "$DEV_ROOT/mmcblk1p1" || is_block_dev "$DEV_ROOT/mmcblk1"; then
printf 'present (not mounted)\n'
else
printf 'slot empty\n'
fi
}
ACTION="${1:-status}"
ARG="${2:-mmcblk1p1}"
if [ "${GEMINUX_TEST_BLOCK:-0}" != "1" ] && [ "$(id -u)" -ne 0 ] && [ "$ACTION" != "status" ]; then
if command -v doas >/dev/null 2>&1; then
exec doas /usr/sbin/geminux-sdcard-mount "$@"
fi
fi
case "$ACTION" in
add)
acquire_lock
do_add "$ARG"
;;
remove)
acquire_lock
do_remove
;;
stop)
acquire_lock
do_stop
;;
status)
do_status
;;
*)
echo "Usage: $0 {add|remove|stop|status} [devname]" >&2
exit 1
;;
esac
+4 -1
View File
@@ -158,12 +158,15 @@ if [ -e "$TARGET_ROOTFS/etc/init.d/geminux-usb-gadget" ]; then
fi fi
rm -f "$TARGET_ROOTFS/etc/runlevels/default/geminux-usb-gadget" rm -f "$TARGET_ROOTFS/etc/runlevels/default/geminux-usb-gadget"
for svc in geminux-hwinit geminux-ccci geminux-powerd geminux-leds bluetooth polkit; do for svc in geminux-hwinit geminux-sdcard geminux-ccci geminux-powerd geminux-leds bluetooth polkit; do
if [ -e "$TARGET_ROOTFS/etc/init.d/$svc" ]; then if [ -e "$TARGET_ROOTFS/etc/init.d/$svc" ]; then
mkdir -p "$TARGET_ROOTFS/etc/runlevels/default" mkdir -p "$TARGET_ROOTFS/etc/runlevels/default"
ln -sf "/etc/init.d/$svc" "$TARGET_ROOTFS/etc/runlevels/default/$svc" ln -sf "/etc/init.d/$svc" "$TARGET_ROOTFS/etc/runlevels/default/$svc"
fi fi
done done
mkdir -p "$TARGET_ROOTFS/media/sdcard"
chmod 0755 "$TARGET_ROOTFS/media/sdcard" 2>/dev/null || true
chmod 0755 "$TARGET_ROOTFS/usr/sbin/geminux-sdcard-mount" "$TARGET_ROOTFS/etc/init.d/geminux-sdcard" 2>/dev/null || true
for fdir in misc TTF OTF; do for fdir in misc TTF OTF; do
mkdir -p "$TARGET_ROOTFS/usr/share/fonts/$fdir" mkdir -p "$TARGET_ROOTFS/usr/share/fonts/$fdir"
+12 -1
View File
@@ -292,6 +292,16 @@ for req_rel in ("etc/pam.d/autologin", "etc/init.d/geminux-hwinit",
"usr/lib/dri/simpledrm_dri.so", "etc/runlevels/boot/geminux-usb-gadget", "usr/lib/dri/simpledrm_dri.so", "etc/runlevels/boot/geminux-usb-gadget",
"usr/share/X11/xkb/types/custom", "usr/sbin/dnsmasq", "usr/share/X11/xkb/types/custom", "usr/sbin/dnsmasq",
"etc/NetworkManager/conf.d/20-geminux-wifi.conf", "etc/shells", "etc/NetworkManager/conf.d/20-geminux-wifi.conf", "etc/shells",
"etc/udev/rules.d/95-geminux-sdcard.rules",
"etc/init.d/geminux-sdcard",
"etc/runlevels/default/geminux-sdcard",
"media/sdcard",
"sbin/fsck.fat",
"sbin/fsck.vfat",
"sbin/mkfs.fat",
"sbin/mkfs.vfat",
"sbin/fatlabel",
"usr/sbin/geminux-sdcard-mount",
"usr/sbin/geminux-wifi-nvram", "usr/sbin/geminux-tzctl", "usr/sbin/geminux-wifi-nvram", "usr/sbin/geminux-tzctl",
"usr/sbin/geminux-dnsctl", "usr/sbin/geminux-dnsctl",
"usr/bin/geminux-datetime", "usr/bin/geminux-datetime",
@@ -496,7 +506,7 @@ if readelf -Ws "$ROOTFS_DIR/usr/bin/Xorg" | grep -q systemd_logind_take_fd; then
fi fi
(cd "$IMAGES_DIR" && sha256sum -c SHA256SUMS) (cd "$IMAGES_DIR" && sha256sum -c SHA256SUMS)
echo "[8/8] Running all 7 Python unit/verification suites..." echo "[8/8] Running all 8 Python unit/verification suites..."
python3 "$BASE_DIR/scripts/test-flash-mtk-gpt.py" python3 "$BASE_DIR/scripts/test-flash-mtk-gpt.py"
python3 "$BASE_DIR/scripts/test-xkb-keymap.py" python3 "$BASE_DIR/scripts/test-xkb-keymap.py"
python3 "$BASE_DIR/scripts/test-theme-dunst-sync.py" python3 "$BASE_DIR/scripts/test-theme-dunst-sync.py"
@@ -504,6 +514,7 @@ python3 "$BASE_DIR/scripts/test-ccci-protocol.py"
python3 "$BASE_DIR/scripts/test-power-policy.py" python3 "$BASE_DIR/scripts/test-power-policy.py"
python3 "$BASE_DIR/scripts/test-webarchy-renderer.py" python3 "$BASE_DIR/scripts/test-webarchy-renderer.py"
python3 "$BASE_DIR/scripts/test-webkit-gsettings.py" python3 "$BASE_DIR/scripts/test-webkit-gsettings.py"
python3 "$BASE_DIR/scripts/test-sdcard-automount.py"
echo "============================================================" echo "============================================================"
echo "ALL GEMINUX CHECKS PASSED CLEANLY" echo "ALL GEMINUX CHECKS PASSED CLEANLY"
+178
View File
@@ -0,0 +1,178 @@
#!/usr/bin/env python3
"""Host unit test for dosfstools preinstall and /dev/mmcblk1p1 -> /media/sdcard automounting."""
import os
import pathlib
import stat
import subprocess
import sys
import tempfile
BASE = pathlib.Path(__file__).resolve().parent.parent
SCRIPT = BASE / "overlay/rootfs/usr/sbin/geminux-sdcard-mount"
INIT_SCRIPT = BASE / "overlay/rootfs/etc/init.d/geminux-sdcard"
UDEV_RULE = BASE / "overlay/rootfs/etc/udev/rules.d/95-geminux-sdcard.rules"
PACKAGES = BASE / "scripts/rootfs-packages.txt"
def make_stub(bin_dir, name, body):
p = bin_dir / name
p.write_text("#!/bin/sh\n" + body + "\n", encoding="utf-8")
p.chmod(0o755)
def run_mount(cmd_args, env):
return subprocess.run(
[str(SCRIPT)] + cmd_args, env=env,
capture_output=True, text=True, check=False,
)
def main():
for path in (SCRIPT, INIT_SCRIPT):
if not path.is_file():
raise SystemExit(f"missing {path}")
subprocess.run(["sh", "-n", str(path)], check=True)
if not (SCRIPT.stat().st_mode & stat.S_IXUSR):
raise SystemExit(f"{SCRIPT} is not executable")
if not (INIT_SCRIPT.stat().st_mode & stat.S_IXUSR):
raise SystemExit(f"{INIT_SCRIPT} is not executable")
pkgs = {
line.strip()
for line in PACKAGES.read_text(encoding="utf-8").splitlines()
if line.strip() and not line.lstrip().startswith("#")
}
if "dosfstools" not in pkgs:
raise SystemExit("scripts/rootfs-packages.txt is missing dosfstools")
rule_txt = UDEV_RULE.read_text(encoding="utf-8")
for needle in ('KERNEL=="mmcblk1|mmcblk1p[0-9]*", GROUP="plugdev", MODE="0660"',
'KERNEL=="mmcblk1p1"', "/usr/sbin/geminux-sdcard-mount add %k",
"/usr/sbin/geminux-sdcard-mount remove %k"):
if needle not in rule_txt:
raise SystemExit(f"95-geminux-sdcard.rules missing '{needle}'")
with tempfile.TemporaryDirectory(prefix="geminux-sdcard-test-") as tmp:
root = pathlib.Path(tmp)
bin_dir = root / "bin"
dev_dir = root / "dev"
mnt_dir = root / "media/sdcard"
run_dir = root / "run"
bin_dir.mkdir()
dev_dir.mkdir()
mnt_dir.mkdir(parents=True)
run_dir.mkdir()
mounts_file = root / "proc_mounts"
mounts_file.write_text("", encoding="utf-8")
passwd_file = root / "passwd"
passwd_file.write_text("root:x:0:0:root:/root:/bin/bash\nalice:x:10000:10000::/home/alice:/bin/bash\n", encoding="utf-8")
group_file = root / "group"
group_file.write_text("root:x:0:\nwheel:x:10:alice\nplugdev:x:106:alice\n", encoding="utf-8")
log_file = root / "calls.log"
fstype_file = root / "fstype"
fstype_file.write_text("vfat", encoding="utf-8")
make_stub(bin_dir, "blkid", f'cat "{fstype_file}"')
make_stub(bin_dir, "modprobe", f'echo "modprobe $*" >> "{log_file}"')
make_stub(bin_dir, "fsck.fat", f'echo "fsck.fat $*" >> "{log_file}"')
make_stub(bin_dir, "fsck.exfat", f'echo "fsck.exfat $*" >> "{log_file}"')
make_stub(bin_dir, "e2fsck", f'echo "e2fsck $*" >> "{log_file}"')
make_stub(bin_dir, "chown", f'echo "chown $*" >> "{log_file}"')
make_stub(bin_dir, "chmod", f'echo "chmod $*" >> "{log_file}"')
make_stub(bin_dir, "logger", "true")
make_stub(bin_dir, "mount", f'''
echo "mount $*" >> "{log_file}"
fs=""
opts=""
prev=""
for a in "$@"; do
if [ "$prev" = "-t" ]; then fs="$a"; fi
if [ "$prev" = "-o" ]; then opts="$a"; fi
prev="$a"
done
printf "%s %s %s %s 0 0\\n" "{dev_dir}/mmcblk1p1" "{mnt_dir}" "$fs" "$opts" > "{mounts_file}"
''')
make_stub(bin_dir, "umount", f'''
echo "umount $*" >> "{log_file}"
: > "{mounts_file}"
''')
env = os.environ.copy()
env["PATH"] = f"{bin_dir}:{env.get('PATH', '/usr/bin:/bin')}"
env["GEMINUX_DEV_ROOT"] = str(dev_dir)
env["GEMINUX_SDCARD_MNT"] = str(mnt_dir)
env["GEMINUX_PROC_MOUNTS"] = str(mounts_file)
env["GEMINUX_PASSWD_FILE"] = str(passwd_file)
env["GEMINUX_GROUP_FILE"] = str(group_file)
env["GEMINUX_LOCK_DIR"] = str(run_dir / "sdcard.lock")
env["GEMINUX_TEST_BLOCK"] = "1"
# 1. Empty slot: clean exit 0, zero mount calls
res = run_mount(["add", "mmcblk1p1"], env)
assert res.returncode == 0, res.stderr
assert not log_file.exists() or log_file.read_text(encoding="utf-8").strip() == ""
st = run_mount(["status"], env)
assert st.returncode == 0 and st.stdout.strip() == "slot empty", st.stdout
# Create mock /dev/mmcblk1p1
(dev_dir / "mmcblk1p1").write_text("", encoding="utf-8")
# 2. vfat card -> fsck.fat + mount with uid=10000,gid=106,0002 masks,quiet,utf8
res = run_mount(["add", "mmcblk1p1"], env)
assert res.returncode == 0, res.stderr
calls = log_file.read_text(encoding="utf-8")
assert f"fsck.fat -a {dev_dir}/mmcblk1p1" in calls, calls
assert ("uid=10000,gid=106,fmask=0002,dmask=0002,allow_utime=0020,quiet,"
"shortname=mixed,utf8") in calls and "-t vfat" in calls, calls
# 3. Repeated add while already mounted -> idempotent no-op
before = calls
res = run_mount(["add", "mmcblk1p1"], env)
assert res.returncode == 0
assert log_file.read_text(encoding="utf-8") == before
# 4. Remove -> umount
res = run_mount(["remove", "mmcblk1p1"], env)
assert res.returncode == 0
assert mounts_file.read_text(encoding="utf-8") == ""
# 5. exfat card -> modprobe exfat + fsck.exfat + mount with uid=10000,gid=106 (no quiet)
log_file.write_text("", encoding="utf-8")
fstype_file.write_text("exfat", encoding="utf-8")
res = run_mount(["add", "mmcblk1p1"], env)
assert res.returncode == 0, res.stderr
calls = log_file.read_text(encoding="utf-8")
assert "modprobe exfat" in calls and f"fsck.exfat -p {dev_dir}/mmcblk1p1" in calls, calls
assert ("-t exfat" in calls and
"uid=10000,gid=106,fmask=0002,dmask=0002,allow_utime=0020,iocharset=utf8" in calls), calls
assert ",quiet" not in calls, calls
res = run_mount(["stop"], env)
assert res.returncode == 0 and mounts_file.read_text(encoding="utf-8") == ""
# 6. ext4 card -> e2fsck -p + mount WITHOUT uid= or gid= + POSIX uid/gid/perms sync
(mnt_dir / "lost+found").mkdir(exist_ok=True)
(mnt_dir / "lost+found" / "orphan").write_text("x", encoding="utf-8")
(mnt_dir / "subdir").mkdir(exist_ok=True)
os.chmod(mnt_dir / "subdir", 0o755)
(mnt_dir / "note.txt").write_text("hi", encoding="utf-8")
os.chmod(mnt_dir / "note.txt", 0o644)
log_file.write_text("", encoding="utf-8")
fstype_file.write_text("ext4", encoding="utf-8")
res = run_mount(["add", "mmcblk1p1"], env)
assert res.returncode == 0, res.stderr
calls = log_file.read_text(encoding="utf-8")
assert f"e2fsck -p {dev_dir}/mmcblk1p1" in calls, calls
assert "-t ext4" in calls and "uid=" not in calls, calls
assert f"chown 10000:106 {mnt_dir}" in calls, calls
assert f"chmod 02775 {mnt_dir}" in calls, calls
assert f"chown -h 10000:106" in calls and "note.txt" in calls and "subdir" in calls, calls
assert "chmod u+rwX,g+rwX" in calls, calls
assert "lost+found" not in calls and "orphan" not in calls, calls
print("[PASS] dosfstools and /dev/mmcblk1p1 -> /media/sdcard automount verified")
return 0
if __name__ == "__main__":
sys.exit(main())