MAOS.git
Publicgit clone https://git.maproj.org/MAOS.gitMAOS.git / docs / BUILD_RUNBOOK.md
| 1 | # MAOS build runbook — Pixel 7 Pro (cheetah) |
| 2 | |
| 3 | Build and publish MAOS for the **Pixel 7 Pro (`cheetah`)** on GrapheneOS base tag |
| 4 | **`2026110700`** from a Windows machine. The whole pipeline (install deps, sync source, |
| 5 | extract vendor files, apply the MAOS overlay, generate/use signing keys, build, sign, and |
| 6 | publish OTA + web-installer artifacts) is automated by **`build-maos.sh`**. This runbook is |
| 7 | just the three things you do by hand: **set up WSL2**, **create the encrypted keystore**, |
| 8 | and **run the script**. |
| 9 | |
| 10 | --- |
| 11 | |
| 12 | ## 1. Set up WSL2 (Windows) |
| 13 | |
| 14 | In an **Administrator** PowerShell: |
| 15 | |
| 16 | ```powershell |
| 17 | wsl --install -d Ubuntu-24.04 |
| 18 | wsl --update |
| 19 | ``` |
| 20 | |
| 21 | > Use **Ubuntu 24.04 LTS** (a GrapheneOS-supported build OS). 25.10 ("resolute") may work |
| 22 | > but isn't supported. |
| 23 | |
| 24 | Reboot, launch Ubuntu, create your Linux user, then create `C:\Users\<you>\.wslconfig`: |
| 25 | |
| 26 | ```ini |
| 27 | [wsl2] |
| 28 | memory=96GB |
| 29 | processors=32 |
| 30 | swap=32GB |
| 31 | # Share the host network stack so WSL inherits working connectivity behind a |
| 32 | # corporate VPN / IPv4-only ISP (otherwise apt/git/repo can't reach the internet). |
| 33 | networkingMode=mirrored |
| 34 | dnsTunneling=true |
| 35 | autoProxy=true |
| 36 | firewall=true |
| 37 | ``` |
| 38 | |
| 39 | Apply it: `wsl --shutdown` in PowerShell, then reopen Ubuntu. Sanity-check networking: |
| 40 | |
| 41 | ```bash |
| 42 | curl -4 -sS -o /dev/null -w '%{http_code}\n' https://github.com # expect 200 |
| 43 | ``` |
| 44 | |
| 45 | The WSL virtual disk grows on `C:` (needs ~400 GB free). Always work inside your Linux home |
| 46 | (`~`, ext4) — **never** `/mnt/c` (AOSP needs a case-sensitive filesystem). |
| 47 | |
| 48 | --- |
| 49 | |
| 50 | ## 2. Get the build script |
| 51 | |
| 52 | The overlay repo is private, so authenticate git once, then clone it for the script: |
| 53 | |
| 54 | ```bash |
| 55 | sudo apt update && sudo apt install -y git |
| 56 | git config --global credential.helper store |
| 57 | git clone https://github.com/vayun-mathur/MAOS.git ~/MAOS # prompts for GitHub creds once |
| 58 | ``` |
| 59 | |
| 60 | --- |
| 61 | |
| 62 | ## 3. One-time Cloudflare R2 setup (for publishing) |
| 63 | |
| 64 | Needed only for the `publish` phase. |
| 65 | |
| 66 | 1. Create an R2 bucket (e.g. `maos-ota`). |
| 67 | 2. R2 → Settings → **Custom Domains** → attach `ota.maproj.org` (Cloudflare issues TLS). |
| 68 | 3. R2 → Manage API Tokens → create a token with **Object Read & Write** on the bucket. |
| 69 | 4. Add a bucket **CORS policy** so the installer page (`ma.vayunmathur.com`) can fetch images: |
| 70 | ```json |
| 71 | [ |
| 72 | { |
| 73 | "AllowedOrigins": ["https://ma.vayunmathur.com"], |
| 74 | "AllowedMethods": ["GET", "HEAD"], |
| 75 | "AllowedHeaders": ["range"], |
| 76 | "ExposeHeaders": ["content-length", "content-range", "accept-ranges", "etag"], |
| 77 | "MaxAgeSeconds": 3600 |
| 78 | } |
| 79 | ] |
| 80 | ``` |
| 81 | 5. Add a **Cache Rule** that bypasses cache for the channel-metadata files (paths not ending |
| 82 | in `.zip`) so devices never see a stale build pointer. |
| 83 | |
| 84 | --- |
| 85 | |
| 86 | ## 4. Configure the environment |
| 87 | |
| 88 | In the Ubuntu shell (add to `~/.bashrc` to persist), set the passphrase for the encrypted |
| 89 | keystore and your R2 credentials: |
| 90 | |
| 91 | ```bash |
| 92 | export MAOS_KEYS_PASSPHRASE='<a strong passphrase you choose>' # unlocks the keystore |
| 93 | export R2_ACCOUNT_ID='<cloudflare account id>' |
| 94 | export R2_ACCESS_KEY_ID='<r2 token key id>' |
| 95 | export R2_SECRET_ACCESS_KEY='<r2 token secret>' |
| 96 | ``` |
| 97 | |
| 98 | Optional: |
| 99 | |
| 100 | ```bash |
| 101 | # export MODERN_APPS_SRC=/path/to/Modern-Apps # else the 28 APKs are downloaded from GitHub |
| 102 | # export MAOS_BUILD_VARIANT=userdebug # debuggable build (default: user) |
| 103 | ``` |
| 104 | |
| 105 | Device, tag, and OTA channel are **command-line flags** on the script (not env vars), |
| 106 | defaulting to `cheetah` / `2026110700` / `stable`. The AOSP checkout (`~/maos`) and the R2 |
| 107 | bucket (`maos`) are fixed; the release build number defaults to today's UTC date + `00` |
| 108 | (override with `MAOS_BUILD_NUMBER`). The build variant defaults to `user`; set |
| 109 | `MAOS_BUILD_VARIANT=userdebug` only for debugging. |
| 110 | |
| 111 | The keystore is written to `~/maos-keys/maos.keys.tar.gz.scrypt` (scrypt + AES-256, |
| 112 | encrypted with your passphrase). **Back that file up and keep the passphrase safe** — losing |
| 113 | either permanently breaks OTA/verified boot for every installed device. |
| 114 | |
| 115 | --- |
| 116 | |
| 117 | ## 5. Create the encrypted keystore + build |
| 118 | |
| 119 | Run the pipeline. The first run generates the signing keys and encrypts them into the |
| 120 | keystore automatically (the `keys` phase), then builds, signs, and publishes: |
| 121 | |
| 122 | ```bash |
| 123 | ~/MAOS/build-maos.sh all # Pixel 7 Pro (cheetah), tag 2026110700 |
| 124 | # other devices/tags/channels via flags: |
| 125 | # ~/MAOS/build-maos.sh -d panther -t 2026110700 -c beta all |
| 126 | ``` |
| 127 | |
| 128 | Phases run in order: `deps → sync → vendor → overlay → keys → build → release → publish`. |
| 129 | It's **resumable** — rerun `all`, or run phases individually, e.g.: |
| 130 | |
| 131 | ```bash |
| 132 | ~/MAOS/build-maos.sh deps sync vendor overlay # prep (long: ~150 GB sync) |
| 133 | ~/MAOS/build-maos.sh keys # create the encrypted keystore |
| 134 | ~/MAOS/build-maos.sh build release publish # build → sign → upload |
| 135 | ``` |
| 136 | |
| 137 | How the keys are handled each run: the encrypted keystore is decrypted **only into RAM** |
| 138 | (`/dev/shm`), symlinked in for signing, and shredded on exit — the private keys never touch |
| 139 | disk in the clear. |
| 140 | |
| 141 | When `publish` finishes, the OTA is live at |
| 142 | `https://ota.maproj.org/cheetah-<channel>` and the web installer can flash the build |
| 143 | from `https://ma.vayunmathur.com/os/install`. |
| 144 | |
| 145 | --- |
| 146 | |
| 147 | ## 6. Test the release |
| 148 | |
| 149 | Before publishing, run the endpoint liveness probes in |
| 150 | [`endpoints.md`](endpoints.md) (SUPL/PSDS/Private-DNS have no standard-mode |
| 151 | fallback in Settings, so a missing maproj service is ship-blocking) and |
| 152 | record the results there. |
| 153 | |
| 154 | - **Web installer:** open `https://ma.vayunmathur.com/os/install` in Chrome/Edge with the |
| 155 | Pixel 7 Pro in bootloader mode; it auto-detects "Pixel 7 Pro (cheetah)", then |
| 156 | Unlock → Download → Flash → Lock. |
| 157 | - **Sideload the full OTA** (validates signing end-to-end): |
| 158 | ```bash |
| 159 | adb reboot recovery # choose "Apply update from ADB" |
| 160 | adb sideload ~/maos/releases/$BUILD/release-cheetah-$BUILD/cheetah-ota_update-$BUILD.zip |
| 161 | ``` |
| 162 | - **In-app Updater:** install an older build, let it update from your server. |
| 163 | |
| 164 | --- |
| 165 | |
| 166 | ## Notes / caveats |
| 167 | |
| 168 | - **Bootloader re-locking** with your own keys needs the device to trust your AVB key. The |
| 169 | `publish` phase's factory-image prep should include flashing `avb_custom_key` (from your |
| 170 | keystore's `avb_pkmd.bin`) before the lock step; for a production release, pass a |
| 171 | `plan.json` mirroring the factory image's own `flash-all` sequence. Locking with a wrong |
| 172 | image can hard-brick the device. |
| 173 | - **Rebranding/attestation:** MAOS build.prop identity is set automatically. Auditor / remote |
| 174 | attestation and stock Play Integrity won't pass on a self-signed fork (expected). |
| 175 | - **Updating to a newer GrapheneOS tag:** set `TAG=<new>` and rerun the phases. Reuse the |
| 176 | **same** keystore — regenerating keys forces a factory reset and breaks OTA continuity. |
| 177 | - **Corporate machine/network:** if this is a work machine, a full AOSP build pulls ~150 GB |
| 178 | through that network and stores your personal signing keys locally — confirm that's within |
| 179 | acceptable-use, or use a personal machine / cloud Linux VM. |