garage44.eu/jeroen/pinnacle

logclone: git clone https://garage44.eu/jeroen/pinnacle.git

.. /docs/store.md

raw

The Store and its package sources

How an app gets from a build to a device.

What the Store reads

A package source is a folder of plain files served over HTTP or HTTPS:

catalog                  a line an app: name|title|version|size|description|rights
packages/<name>.ppk      the app's package, signed
blobs/<sha256>           the app's files, named by their SHA-256

The Store reads every source in turn: /settings/store-url on the system disk (the source cargo xtask serves beside QEMU, or a bundle's start), then each line of /settings/store-sources. A source that does not answer is left out; an app two sources offer comes from the first.

A package (pkg/) is a small signed archive: the app's manifest and files, a line a file — <sha256> <size> <path>, the path within the app's folder (program, assets/shaders/sky.wesl). Its publisher signs the whole archive with Ed25519. The Store installs it only when a key in /settings/trusted-keys made that signature, and only when its manifest asks for no more rights than the catalog showed before Install was tapped. Then it fetches each file from blobs/, a megabyte at a time onto the disk, and checks its size and SHA-256 against the list; a file that does not match is removed and nothing is installed. The manifest is written last: until it is there, the app is not on the home screen.

An installed app keeps its list (/apps/<name>/files). When the catalog offers another version the Store shows Update, fetches only the files whose hash changed, and removes the ones the new version no longer has.

Updates by themselves

The updates service (programs/src/bin/updates.rs, started with the rest of the system once the data is open) looks at the same catalogs a minute after the start, then every six hours, and when Settings → Updates asks (Look now). Settings offers three choices, kept in /settings/updates:

ChoiceWhat a new version leads to
Not looked for (off)Nothing: no catalog is fetched.
Told (tell, the default)A notification naming the apps the Store can update, once a version.
Installed by themselves (install)The app brought up to date by the same install the Store does, then a notification saying so.

Installing by itself is only for a version that asks for no more than the installed one may do (its catalog rights within the installed manifest's, and its signed manifest within its catalog rights, as for any install): one that asks for more is told, and installed from the Store, where its rights show before the tap. An app that is running is not changed under it: the service asks the display server (RUNNING) and tries again five minutes later. What the last look found is in /settings/updates-last, and Settings shows it. cargo xtask updates-demo shows it. The system is updated beside the apps: updates.md.

The sources a system has

SourceWho signsWhat it offers
http://10.0.2.2:<port>/ — cargo xtask's own (serve), or a bundle's startThis checkout's development key, target/publisher.key, made once and never committedCalculator and Paint, built from this checkout
https://pinnacle-os.eu/store/pinnacle/ (a PC's: …/pinnacle/pc/)The hosted Store's key, keys/store-publisher.pubCalculator and Paint from main, published after every landing (midas deploy pinnacle-apps)
https://pinnacle-os.eu/store/cartopolis/ (ARM only)The hosted Store's keyCartopolis's client (midas deploy pinnacle-store, when asked)
https://pinnacle-os.eu/store/flitz/ (ARM only)The hosted Store's keyFlitz, the web browser (midas deploy flitz-store, from jeroen/flitz's main after every landing)

An app two sources offer comes from the first, so on a development system the checkout's own Calculator and Paint stand in front of main's.

Every system disk cargo xtask makes trusts both keys. The hosted key's secret half is only on the server that serves pinnacle-os.eu, readable by the user pinnacle-sign alone; it never reaches a build node.

Publishers and their keys

Every key belongs to one publisher (pkg/src/trust.rs). /settings/trusted-keys names each: <key> <publisher>, and registry after it for a key that may vouch for others. A disk cargo xtask makes has two, both registries: this-checkout (the development key) and pinnacle (the hosted Store's).

The hosted Store's list is keys/publishers in this repository: admitting a publisher is a landing that adds its key there, and taking a key back one that adds revoked. cargo xtask package-apps writes it as packages/publishers.ppa, issued as the version, and the server signs it with the apps; it is at https://pinnacle-os.eu/store/pinnacle/packages/publishers.ppk. The development source serves a list of its own, which the self-check reads: it admits friend and admits and takes back leaky, and their packages beside it (friendly, leaked) open as friend's and are refused.

A publisher sends its public key the way it likes (it is public); its secret half stays with it, and its packages are signed as the Store's are (openssl pkeyutl -sign -rawin over the archive, PSIG appended), served from a source of its own or from a folder at pinnacle-os.eu.

Publishing on pinnacle-os.eu

Caddy serves /data/pinnacle-store at https://pinnacle-os.eu/store/, a folder per publisher. A midas deploy target fills one folder:

  1. On a build node the target's steps build the app and write an unsigned package source: catalog, packages/<name>.ppa (the archive without its signature) and blobs/. For this repository's apps that is tools/deploy/store.sh (cargo xtask package-apps, ARM's and a PC's in pc/); for Cartopolis cargo xtask package-cartopolis <its checkout> <out> <version>, run by Cartopolis's deploy/build/pinnacle-store.sh; for Flitz cargo xtask package-flitz, run by Flitz's deploy/pinnacle-store.sh.
  2. On the server, as pinnacle-sign, the target's prepare signs each archive with OpenSSL (openssl pkeyutl -sign -rawin, the same Ed25519 signature pkg makes: its test a_package_signed_by_openssl_opens), appends PSIG and the signature to make <name>.ppk, and removes the .ppa.
  3. Its checks verify each signature against the key and each blob's name against its SHA-256; then midas replaces the folder.

A version is whatever string the catalog and manifest say; the Store offers an update when it differs from the installed one. This repository's apps use the number of commits on main; Cartopolis its build number (as its server and APK do).

Limits