Why PiGo Needs a Dedicated OS Image Builder
The whole philosophy behind the PiGo Handheld is simplicity: snap the Raspberry Pi Zero or Zero 2 W onto the carrier PCB, click the 3D-printed shell together, insert a microSD card, and start playing. That experience falls apart immediately if users have to flash stock Raspberry Pi OS, connect an HDMI monitor and USB keyboard, enable SSH, compile Device Tree overlays, and configure Wayland by hand.
pi-gen-pigo
eliminates all of that manual setup. It is a tailored fork of the official
RPI-Distro/pi-gen build system that produces clean, minimal, ready-to-flash
PiGo OS .img files from scratch — completely reproducibly.
Purpose: Automated, Minimal, Repeatable Releases
Instead of taking a manually tweaked SD card and cloning it with dd (which
invariably leaks Wi-Fi credentials, SSH host keys, log clutter, and undocumented hacks),
pi-gen-pigo builds every PiGo OS release cleanly from Debian
(trixie) packages in a staged chroot pipeline:
- Zero Desktop Bloat: Builds on top of Raspberry Pi OS Lite and skips all desktop, browser, and office stages.
-
Clean First-Boot State: Every generated image is free of personal state
and boots directly into
pigogui's first-boot setup wizard. -
Docker & Native Support: Can be built either directly on a Debian host
via
build.shor inside an isolated container viabuild-docker.sh.
How the Code Is Structured
pi-gen organizes OS image generation into sequential numbered stages, where each
stage builds upon the root filesystem produced by the previous one. What makes
pi-gen-pigo remarkably clean to maintain is how little it diverges from upstream
pi-gen:
1. Base Raspberry Pi OS Lite Stages (stage0 – stage2)
-
stage0: Bootstraps a minimal Debian ARM root filesystem usingdebootstrapand configures APT repositories and kernel/firmware packages. -
stage1: Turns the bootstrap into a minimally bootable Raspberry Pi system with essential networking and filesystem tools. -
stage2: Adds standard Raspberry Pi OS Lite tweaks (01-sys-tweaks,02-net-tweaks,03-set-timezone,04-cloud-init). Crucially,stage2/SKIP_IMAGESis present sopi-gendoes not waste time exporting an intermediate vanilla Lite image.
2. The Custom PiGo Stage (stage2a/)
Right after stage2 finishes, pi-gen-pigo inserts a lean custom
stage called stage2a containing just two files:
-
stage2a/EXPORT_IMAGE: Tells the build system to package the resulting root filesystem into the final flashable.imgfile using theexport-image/scripts (partitioning, filesystem creation,zerofreeshrinking, and compression). -
stage2a/prerun.sh: Delegates the entire PiGo customization topigo-configin a single line:
curl https://raw.githubusercontent.com/daviel/pigo-config/main/update.sh | sh
3. Skipping Heavy Desktop Stages (stage3 – stage5)
Upstream pi-gen includes stage3 (X11/Wayland desktop),
stage4 (desktop apps and VNC), and stage5 (LibreOffice and extras).
In pi-gen-pigo, all three directories carry both SKIP and
SKIP_IMAGES marker files so they are bypassed completely. This keeps build times
short and ensures the resulting SD card image stays compact enough for small microSD cards.
4. Containerized Build Tooling (Dockerfile & build-docker.sh)
Because cross-building ARM images requires qemu-user-static,
binfmt-support, debootstrap, parted,
dosfstools, e2fsprogs, and zerofree, the repository
ships a ready-made Dockerfile and build-docker.sh wrapper. You can
clone the repo, drop in a config file with your IMG_NAME, and let
Docker produce the finished image in deploy/.
Role in the PiGo Handheld Ecosystem
pi-gen-pigo is the factory pipeline of PiGo OS. By keeping
stage2a as a thin hook into pigo-config, the architecture avoids
duplicating configuration logic across two repositories:
-
pigo-configremains the single source of truth for hardware overlays, Sway, systemd units, and package selection. -
pi-gen-pigohandles Debian bootstrapping, QEMU ARM emulation, partitioning, and SD card image assembly.
Whenever a new improvement lands in pigo-config, pigogui, or
uinput-pigo-mapper, rebuilding with pi-gen-pigo immediately
produces a fresh, up-to-date PiGo OS image ready for anyone to flash and play.

