Modern Apps git

MAOS.git

Public
git clone https://git.maproj.org/MAOS.git
main ▾

MAOS.git / installer / README.md

README.md6.9 KiBRenderedCodeRaw
1# MAOS web installer
2
3A browser-based flasher at **`https://ma.vayunmathur.com/os/install`**, in the style of
4GrapheneOS's `/install/web`. It talks fastboot to a connected Pixel over **WebUSB** and
5flashes the MAOS factory image — no `adb`/`fastboot` tools or command line needed.
6
7## Pieces
8
9| Where | What |
10| --- | --- |
11| `location_share_server/os_installer/` | The static front-end: `install.html`, `install.css`, `installer.js` (wizard), `fastboot.js` (WebUSB fastboot client). Served at `/os/install` on `ma.vayunmathur.com`. |
12| `MAOS/installer/prepare-factory.sh` | Build-host script: turns a release image into a `manifest.json` + per-partition images and uploads them to R2. For the **install zip** (preferred) it translates GrapheneOS's `script.txt` verbatim; for a legacy **factory zip** it builds a best-effort/`-P` plan and splits oversized images into sparse chunks. |
13| `MAOS/installer/script_to_manifest.py` | Translates an install zip's `script.txt` (GrapheneOS's verified flash sequence) into ordered manifest steps. |
14| `MAOS/installer/sparse_split.py` | Splits a raw image into multiple Android sparse images, each under the device's max-download-size (legacy factory-zip path only). |
15| R2 (`ota.maproj.org/factory/<device>/…`) | Hosts the manifest + images; the browser streams them directly. |
16
17## Flow
18
19```
20factory image ──prepare-factory.sh──▶ manifest.json + images ──▶ R2 (factory/<device>/latest/)
21 │
22 ma.vayunmathur.com/os/install ◀── static app served by server │
23 │ (WebUSB fastboot) │
24 ▼ ▼
25 Pixel in bootloader mode ◀────────── streams images from R2 ──────
26```
27
28The installer reads `factory/<device>/latest/manifest.json`, then for each step drives the
29device over WebUSB — `check-var` / `check-requirements` (verify), `flash` (to the active or
30inactive/"other" slot), `erase`, `run-cmd`, `toggle-active-slot` / `set-active`,
31`snapshot-update-cancel`, `reboot-bootloader`, `reboot` — streaming each referenced image
32straight from R2 and flashing it before fetching the next (so a multi-GB `super` never has
33to fit in memory at once).
34
35## Before you have any builds
36
37You don't need to upload anything: if `factory/<device>/latest/manifest.json` is missing
38(404), the installer detects the device, lets it connect/unlock, and shows **"No MAOS build
39is available for &lt;device&gt; yet"** when the user clicks Download.
40
41If you'd rather show an explicit message (e.g. a bucket-wide default), upload a stub
42`manifest.json` with `available: false`:
43
44```json
45{
46 "available": false,
47 "message": "MAOS builds aren't available yet — check back soon."
48}
49```
50
51Put it at `factory/<device>/latest/manifest.json` for a specific model. The installer treats
52either a 404 or `available: false` as "no build yet" (a friendly notice, not an error).
53
54## Publishing a build for the installer
55
56```bash
57# On the Linux build host, after producing a release (runbook step 8):
58export R2_ACCESS_KEY_ID=... R2_SECRET_ACCESS_KEY=... R2_ACCOUNT_ID=...
59installer/prepare-factory.sh -d cheetah -b "$BUILD" -f <device>-install-<build>.zip
60```
61
62This uploads to both `factory/<device>/<build>/` and `factory/<device>/latest/` (the
63installer defaults to `latest`). `build-maos.sh`'s `publish` phase runs this for you with the
64install zip.
65
66### The flash plan
67
68The correct, brick-safe flash sequence for a release is GrapheneOS's own — shipped as
69`script.txt` inside the **install zip** (`<device>-install-<build>.zip`), alongside the whole
70`super` already pre-split into `super_*.img`. When `prepare-factory.sh` sees a `script.txt`
71it translates it verbatim (`script_to_manifest.py`) into ordered manifest steps and copies
72the images as-is — no re-splitting, no invented plan. This is the default and what you should
73use for a real release.
74
75Supported step actions: `check-var`, `check-requirements`, `flash` (optional `slot:"other"`),
76`erase`, `run-cmd`, `toggle-active-slot`, `set-active`, `snapshot-update-cancel`,
77`reboot-bootloader`, `reboot`.
78
79#### Legacy factory-zip fallback
80
81If you only have a **factory zip** (no `script.txt`), `prepare-factory.sh` builds a
82partition→image map and either follows an explicit `-P plan.json` or emits a **best-effort**
83plan (and prints a warning). Oversized images (e.g. `super`) are split into sparse chunks
84with `sparse_split.py`. Treat the auto plan as a scaffold — pass `-P` mirroring that device's
85`flash-all` and validate on a device before publishing:
86
87```bash
88installer/prepare-factory.sh -d cheetah -b "$BUILD" -f factory.zip -P plan.json
89```
90
91`plan.json` is a JSON array of steps, e.g.:
92
93```json
94[
95 {"action":"flash","partition":"bootloader","image":"bootloader-cheetah-*.img"},
96 {"action":"reboot-bootloader"},
97 {"action":"flash","partition":"radio","image":"radio-cheetah-*.img"},
98 {"action":"reboot-bootloader"},
99 {"action":"flash","partition":"boot","image":"boot.img"},
100 {"action":"flash","partition":"init_boot","image":"init_boot.img"},
101 {"action":"flash","partition":"dtbo","image":"dtbo.img"},
102 {"action":"flash","partition":"vendor_boot","image":"vendor_boot.img"},
103 {"action":"flash","partition":"vbmeta","image":"vbmeta.img"},
104 {"action":"flash","partition":"super","image":"super.img"},
105 {"action":"erase","partition":"userdata"},
106 {"action":"reboot"}
107]
108```
109
110`image` names an entry from the factory image (top-level or inside `image-*.zip`). Any image
111over `-m` bytes (default 100 MiB, e.g. `super`) is auto-split into sparse chunks and expanded
112into multiple flash steps to the same partition.
113
114## Required: R2 CORS
115
116The installer page is served from `ma.vayunmathur.com` but fetches the manifest + images
117from `ota.maproj.org` (R2) — a cross-origin request. **The R2 bucket must send CORS
118headers allowing `https://ma.vayunmathur.com`**, or the browser blocks the downloads. In the
119R2 bucket settings, add a CORS policy like:
120
121```json
122[
123 {
124 "AllowedOrigins": ["https://ma.vayunmathur.com"],
125 "AllowedMethods": ["GET"],
126 "AllowedHeaders": ["range"],
127 "ExposeHeaders": ["content-length", "content-range", "accept-ranges"],
128 "MaxAgeSeconds": 3600
129 }
130]
131```
132
133## Browser support & safety
134
135- **Chromium desktop only** (Chrome/Edge). WebUSB isn't in Firefox/Safari.
136- Everything runs locally: images download from R2 to the browser and go to the device over
137 USB. Nothing is uploaded.
138- Re-locking the bootloader is offered only after a successful flash — locking over a bad
139 image can hard-brick the device.
140
141## Status / caveats
142
143The fastboot client and prep scripts are authored against the documented fastboot + sparse
144formats but have **not been validated end-to-end on a device** (that needs real hardware and
145a real MAOS factory image). Expect to iterate on the per-device flash plan and, if a device's
146`super` handling differs, on the sparse splitting. See the inline "verify on device" notes.