Skip to content

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.

  • 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_misc registered for aarch64)
  • 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 set BUSYBOX_ARM64=/path/to/busybox): on an arm64 host, install busybox-static; on x86_64, download busybox-static:arm64 from Ubuntu Ports / Debian arm64 and extract /usr/bin/busybox (see the exact GPG-verified download step in .github/workflows/ci.yml).
  • mkbootimg and unpack_bootimg: Automatically staged into out/<device>/kernel/mkbootimg/ by kernel/build.sh on Kleaf builds (grapheneos-6.1 / 6.18). On mainline or standalone initramfs/build.sh runs, install Android mkbootimg or pass MKBOOTIMG=... and UNPACK_BOOTIMG=....
  • Rootless builds supported via mmdebstrap --mode=unshare (requires unprivileged user namespaces + /etc/subuid), or BOOTSTRAP_MODE=root under sudo
  1. Build the pinned kernel + headless.fragment + signed modules

    Terminal window
    kernel/build.sh raven

    For grapheneos-6.1 (raven / oriole), this shallow-clones the pinned GrapheneOS/kernel_pixel_6.1 commit (kernel/VERSIONS.env), updates common/ack, applies multi-repo patches via kernel/apply_patches.py, builds with Kleaf/Bazel (--defconfig_fragment=//common/ack:headless_defconfig --notrim --nokmi_symbol_list_strict_mode --nokmi_symbol_list_violations_check), compiles scripts/sign-file.c, signs every .ko module, and stages outputs in out/raven/kernel/.

  2. Package matched Android boot images (boot.img, vendor_boot.img, dtbo.img)

    Terminal window
    initramfs/build.sh raven

    Resolves the strict transitive depmod closure of devices/raven/modules.boot + USB NIC/ACM modules, builds the BusyBox Stage 1 initramfs, validates image sizes against <PART>_PARTITION_SIZE, checks headers with unpack_bootimg, and outputs boot.img, vendor_boot.img, dtbo.img, boot-manifest.json, and modules-<kver>.tar.zst under out/raven/boot/.

  3. Build the secret-free Debian 13 arm64 + Docker rootfs & OTA system bundle

    Terminal window
    rootfs/build.sh raven

    Compiles the pure-C arm64 hardware shims/workers (tools/{tpu,camera,gpu,sensors,gnss}/build.sh on gs101), bootstraps Debian trixie + pinned Docker CE (verifying Docker’s GPG key SHA-256), strips SSH host keys and /etc/machine-id, packages headless-phone-system-raven.tar.zst via rootfs/build_system_bundle.py, pre-seeds /var/lib/headless-phone/installed-system-manifest.json, and writes rootfs-raven.ext4 + sparse userdata-raven.simg under out/raven/rootfs/.

(Substitute oriole for Pixel 6, or any custom profile under devices/<codename>/.)

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.
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.
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.
Terminal window
# 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)
  • 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 /vendor or super binaries.