Building from Source
Every official release artifact is built reproducibly from source using three scripts — kernel/build.sh, initramfs/build.sh, and rootfs/build.sh — plus rootfs/build_system_bundle.py for on-device OTA bundles.
Host Requirements (Linux)
Section titled “Host Requirements (Linux)”- Linux x86_64 or arm64 host (Ubuntu 24.04 / Debian 13 recommended)
- For cross-building arm64 on x86_64:
gcc-aarch64-linux-gnu,qemu-user-static(binfmt_miscregistered foraarch64) - Packages:
git,python3,python3-yaml,zstd,lz4,cpio,mmdebstrap,e2fsprogs,android-sdk-libsparse-utils,libssl-dev,curl - Static arm64 BusyBox at
/opt/headless-phone/arm64/busybox(or setBUSYBOX_ARM64=/path/to/busybox): on an arm64 host, installbusybox-static; on x86_64, downloadbusybox-static:arm64from Ubuntu Ports / Debian arm64 and extract/usr/bin/busybox(see the exact GPG-verified download step in.github/workflows/ci.yml). mkbootimgandunpack_bootimg: Automatically staged intoout/<device>/kernel/mkbootimg/bykernel/build.shon Kleaf builds (grapheneos-6.1/6.18). Onmainlineor standaloneinitramfs/build.shruns, install Androidmkbootimgor passMKBOOTIMG=...andUNPACK_BOOTIMG=....- Rootless builds supported via
mmdebstrap --mode=unshare(requires unprivileged user namespaces +/etc/subuid), orBOOTSTRAP_MODE=rootundersudo
Full 3-Stage Local Build
Section titled “Full 3-Stage Local Build”-
Build the pinned kernel +
headless.fragment+ signed modulesTerminal window kernel/build.sh ravenFor
grapheneos-6.1(raven/oriole), this shallow-clones the pinnedGrapheneOS/kernel_pixel_6.1commit (kernel/VERSIONS.env), updatescommon/ack, applies multi-repo patches viakernel/apply_patches.py, builds with Kleaf/Bazel (--defconfig_fragment=//common/ack:headless_defconfig --notrim --nokmi_symbol_list_strict_mode --nokmi_symbol_list_violations_check), compilesscripts/sign-file.c, signs every.komodule, and stages outputs inout/raven/kernel/. -
Package matched Android boot images (
boot.img,vendor_boot.img,dtbo.img)Terminal window initramfs/build.sh ravenResolves the strict transitive
depmodclosure ofdevices/raven/modules.boot+ USB NIC/ACM modules, builds the BusyBox Stage 1 initramfs, validates image sizes against<PART>_PARTITION_SIZE, checks headers withunpack_bootimg, and outputsboot.img,vendor_boot.img,dtbo.img,boot-manifest.json, andmodules-<kver>.tar.zstunderout/raven/boot/. -
Build the secret-free Debian 13 arm64 + Docker rootfs & OTA system bundle
Terminal window rootfs/build.sh ravenCompiles the pure-C arm64 hardware shims/workers (
tools/{tpu,camera,gpu,sensors,gnss}/build.shongs101), bootstraps Debiantrixie+ pinned Docker CE (verifying Docker’s GPG key SHA-256), strips SSH host keys and/etc/machine-id, packagesheadless-phone-system-raven.tar.zstviarootfs/build_system_bundle.py, pre-seeds/var/lib/headless-phone/installed-system-manifest.json, and writesrootfs-raven.ext4+ sparseuserdata-raven.simgunderout/raven/rootfs/.
(Substitute oriole for Pixel 6, or any custom profile under devices/<codename>/.)
Build Environment Variables
Section titled “Build Environment Variables”kernel/build.sh
Section titled “kernel/build.sh”| Variable | Default | Description |
|---|---|---|
BUILD_MODE |
custom |
custom applies headless.fragment + patches; baseline builds unmodified upstream kernel for hardware A/B comparison. |
LTO_MODE |
thin (6.1) / none (6.18) |
Kleaf LTO mode (thin, full, none). |
CI_JOBS |
min(nproc, 8) |
Parallel build jobs. |
BUILD_WORKDIR |
/tmp/headless-build |
Working checkout directory. |
KERNEL_SRC_DIR |
(auto) | Reuse an existing local kernel checkout. |
OUT_DIR |
<repo>/out/<device> |
Output root directory. |
KLEAF_LOCAL |
1 |
Enabled (1) by default, passing --config=local --spawn_strategy=processwrapper-sandbox,local (works cleanly in containers/CI); set 0 to disable local Kleaf sandboxing overrides. |
CROSS_COMPILE / LLVM |
Auto | Cross-compiler prefix or LLVM toggle for mainline backend. |
initramfs/build.sh
Section titled “initramfs/build.sh”| Variable | Default | Description |
|---|---|---|
SHELL_MODE |
0 |
Set 1 to append headless.shell=1 so Stage 1 drops straight into the USB CDC ACM BusyBox recovery shell without mounting userdata. |
BUSYBOX_ARM64 |
/opt/headless-phone/arm64/busybox |
Path to static arm64 BusyBox binary. |
OS_VERSION / OS_PATCH_LEVEL |
17.0.0 / 2026-11 |
Android boot header OS version & security patch metadata. |
MKBOOTIMG / UNPACK_BOOTIMG |
Auto-discovered | Override Android mkbootimg tool paths. |
rootfs/build.sh
Section titled “rootfs/build.sh”| Variable | Default | Description |
|---|---|---|
INSTALL_DOCKER |
1 |
Set 0 to build a slim Debian rootfs without Docker Engine. |
BOOTSTRAP_MODE |
auto |
auto (root if UID 0 else unshare), unshare, or root. |
ROOTFS_SIZE |
2048M |
Initial ext4 image size (expanded online to fill userdata on first boot). |
DEFAULT_USER / DEFAULT_PASS |
pixel / headless |
Default admin credentials (override at flash time via cloud-init). |
BUILD_{TPU,CAMERA,GPU,SENSORS,GNSS}_RUNTIME |
1 on gs101, 0 otherwise |
Toggle compiling pure-C arm64 bionic shims & workers. |
HEADLESS_VERSION / GITHUB_SHA |
Auto from git | Version metadata embedded into installed-system-manifest.json and headless-phone-system-<device>.tar.zst. |
Running the Test Suite
Section titled “Running the Test Suite”# Python unit & fault-injection suite (runs on Linux, WSL, and Windows)python3 -m unittest discover -s tests -p "test_*.py" -v
# WebUSB installer unit, WASM ext4/e2fsck, Functions, Playwright OPFS & build(cd web && pnpm run typecheck && pnpm run test && pnpm run build && pnpm run test:browser)
# Documentation site check, static build & link validation(cd docs-site && pnpm run check && pnpm run build)Licensing & Complete Corresponding Source
Section titled “Licensing & Complete Corresponding Source”- Original repository files:
AGPL-3.0-only - Kernel patches (
kernel/patches/):GPL-2.0-only - Published releases: Every CI run and GitHub Release uploads matching source archives alongside binary assets (
kernel-source-<device>.tar.zst,busybox-source-<device>.tar.zst,rootfs-debian-source-<device>.tar,SOURCES-AND-LICENSES-*.txt) and never redistributes proprietary Android/vendororsuperbinaries.