SPB Git

Repository Public BSD-3-Clause

README.md 7.2 KB 107 lines markdown

1# package-builder — `orix-package`23macOS command-line tool that generates signing keys, assembles and signs `.orixmap` region packages from component4files, verifies and inspects them, and generates the static distribution catalog. Depends only on5`Packages/ORIXMapPackage` (the format has a single implementation, shared with the app) and `ORIXGeoCore`.67Targets: `PackageBuilderKit` (library: `PMTilesHeader`, `SigningKeys`, `CatalogGenerator`, `CommandLineTool`, `Fixtures`)8and the executable `orix-package`. No argument-parsing dependency. Specifications: `docs/ORIXMAP_FORMAT.md`,9`docs/CATALOG_API.md`.1011## Commands1213```sh14cd Infrastructure/package-builder && swift build -c release      # .build/release/orix-package1516# 1. Key (once per key; development keys go under data/dev-signing/, which is git-ignored)17orix-package keygen --out data/dev-signing --label "development (not for production)"18#    → orixmap-<keyid>.key (mode 600), .pub, .trust.json; prints the Swift and JSON snippets for the app trust store1920# 2. Build + sign (zoom range and bounds are read from the PMTiles v3 header; --bbox overrides the bounds)21orix-package build --region ca-qc-montreal --name-en "Greater Montréal" --name-fr "Grand Montréal" \22  --data-version 2026.11.24 --data-timestamp 2026-11-24T00:00:00Z \23  --map data/build/montreal.pmtiles --search data/build/montreal/search.sqlite \24  --routing data/build/routing/montreal.orixgraph \25  --licences Infrastructure/package-builder/licences-osm.json \26  --key data/dev-signing/orixmap-<keyid>.key --out data/package-builder/ca-qc-montreal-2026.11.24.orixmap27#    optional: --terrain f.pmtiles  --bbox minLon,minLat,maxLon,maxLat  --languages en,fr  --name es="…"28#              --search-format N --routing-format N (component format versions, default 1)  --min-app-version 1.029#              --builder tile-builder=0.3.1 (repeatable)  --build-date 2026-11-25T08:00:00Z30#    key: --key <file> or environment variable ORIX_PACKAGE_SIGNING_KEY_FILE=<file>3132# 3. Check33orix-package verify  file.orixmap --trust data/dev-signing/orixmap-<keyid>.trust.json    # or the .pub file34orix-package inspect file.orixmap [--trust …] [--json]     # header, manifest, component table; --json = signed manifest bytes3536# 4. Publish into a distribution directory and (re)generate catalog.json, regions/<id>.json, regions/<id>/versions.json37orix-package publish file.orixmap --dir <dist> --trust <trust>38orix-package catalog --dir <dist> --trust <trust>                                   # regenerate after manual changes39orix-package catalog --dir <dist> --trust <trust> --latest ca-qc-montreal=2026.11.10  # rollback of "latest" (kept in pins.json)40orix-package catalog --dir <dist> --trust <trust> --unpin ca-qc-montreal4142# Development helpers43orix-package install file.orixmap --store <dir> --trust <trust>   # what the phone does (RegionStore), on this Mac44orix-package fixture --kind pmtiles|blob --size <bytes> --out <file>   # synthetic test data, not a map45./bench.sh <key> <trust> <work dir>                               # the measurements below46```4748Exit status: 0 success, 1 failure (message on stderr), 2 usage.4950Private key handling: the file must be a regular file (symbolic links refused), owned by the current user, with no51group/other permission (`chmod 600`); anything else is refused before reading. `keygen` creates the directory with mode52700 and the key with `O_EXCL` and mode 600, and never overwrites. Expected location on the build node:53`~/.config/orix-maps/signing/`. **The production key does not exist yet**: it is to be generated on the build node.54The key under `data/dev-signing/` is a development key (id `92853604e9033917`) — do not put it in a release trust store.5556`build` checks: PMTiles magic `PMTiles` + version 3 for `--map` and `--terrain`, every header section inside the file57(overflow-safe), `min_zoom ≤ max_zoom ≤ 30`, tile type MVT for `--map`; then everything `PackageManifest.validate`58checks. It hashes each component, lays the file out, signs, writes to a temporary file and renames; while copying it59re-hashes each component and fails if a file changed since it was hashed.6061`catalog` fully verifies every package under `files/`, refuses misplaced or unexpected files, and writes62`versions.json` → `<id>.json` → `catalog.json` (last), each atomically. See `docs/CATALOG_API.md` §7 for the63publication and rollback procedure, and `docs/ORIXMAP_FORMAT.md` §5.1 for key rotation.6465## End-to-end run on real components (2026-11-25)6667Components produced by the other builders were present in `data/build/` when this was run: `montreal.pmtiles`68(96 370 599 B, zoom 0–15), `montreal/search.sqlite` (40 460 288 B), `routing/montreal.orixgraph` (99 315 712 B). They69were taken as they were at 03:33 (their builders may still be iterating; component format versions were recorded as 170for search and routing, the default — to be confirmed by their owners).7172| Step | Result |73|---|---|74| `build` | 236 150 784 B, overhead 4 185 B, 0.19 s |75| `/usr/bin/time -l orix-package verify` | 0.081 s, max RSS 9.27 MB, peak footprint 3.87 MB |76| `inspect --trust` | signature valid, layout valid, preamble 1 521 B |77| `/usr/bin/time -l orix-package install` | 0.133 s, max RSS 13.4 MB, peak footprint 5.93 MB; installed files identical to the sources (`cmp`) |78| `publish` | `data/package-builder/dist/` with `catalog.json`, `regions/ca-qc-montreal.json`, `regions/ca-qc-montreal/versions.json`, `files/…` |7980Left in place (git-ignored): `data/package-builder/ca-qc-montreal-2026.11.24.orixmap` and `data/package-builder/dist/`,81a ready-to-serve **development** distribution signed with the development key.8283Synthetic measurements (`./bench.sh`, same machine: Mac17,6, M5 Max, release build, warm cache):8485| Package | build | verify (3 runs) | install (3 runs) | peak footprint verify / install |86|---|---:|---:|---:|---:|87| 50 MB | 0.04 s | 0.018 / 0.018 / 0.018 s | 0.053 / 0.048 / 0.046 s | 3.87 MB / 5.9 MB |88| 300 MB | 0.23 s | 0.105 / 0.106 / 0.106 s | 0.157 / 0.153 / 0.153 s | 3.87 MB / 5.9 MB |8990## Tests9192`swift test` — **8 tests in 3 suites, all passing** (2026-11-25): PMTiles header reader (valid archive, every93rejection, 20 000 random inputs), signing keys (modes, loose permissions, symbolic links, garbage), and the command94driven in-process end to end (keygen → fixture → build → verify → inspect → install; bad inputs; publish → catalog →95rollback pin → unpin → corrupted / misplaced / stray artefacts → region withdrawal).9697## Known limits / Not done9899- `catalog` re-verifies (re-hashes) every published package on each run: linear in the size of the distribution.100- Only the PMTiles **header** is read: directories, metadata and tiles are not validated. The search and routing101  components are opaque to the builder (no check of the SQLite schema or of the graph magic).102- `--search-format` / `--routing-format` are given by the caller; nothing reads them from the files.103- `fixture` files are structurally valid but empty of map content (zero tiles).104- No production key, no deployment to the node, no upload: `publish` works on a local directory.105- Keys are raw base64 files; no hardware token / Secure Enclave / passphrase.106- File headers are left to the repository header tool (`docs/CONVENTIONS.md`).107
Files main
Menu

Theme