Expand description
Over-the-air updates of a packaged app’s code (docs/dev/updater.md,
“Packages”): signed packages (.nshpkg) the app downloaded with
nsh/updater’s downloadPackage run instead of the bundle it shipped
with, when they are newer, verify against the roots its nsh.json
trusts and proved they run.
Everything lives in updates_dir, <data dir>/<app id>/updates/:
next.nshpkg: downloaded and verified, never run;trying.nshpkg:next.nshpkgonce a launch starts it, until it proves healthy (it then becomescurrent.nshpkg) or fails (it is deleted). Still there at a launch, the run before never proved healthy (the process crashed): it is deleted and the app goes back. A download during the trial writesnext.nshpkgwithout touching it;current.nshpkg: the package that last proved healthy;trust/: the trust store’s state (accepted builds, revocations);packages/: the running package’s extracted assets.
launch picks what a packaged app’s launcher runs; any failure there
runs the shipped bundle. A package runs with the shipped app’s id, URL
schemes and trusted paths, its own declared capabilities granted at most
what the shipped app declares, and nsh/updater reads the shipped
app’s update configuration (Bundle::updater_config).
Failures and fallbacks are warnings or errors, which packaged apps log on every platform: the app’s developer needs to see why a package does not run. What runs and what is installed are info, which they log on Android.
Structs§
- Launch
- What a packaged app’s launcher runs (
launch). - Package
Run - A package to run instead of the shipped bundle (
package_to_run).
Constants§
- CURRENT
- The package that proved healthy.
- DIR
- The directory of the state, in an app’s own data directory.
- NEXT
- A downloaded package, run at the next launch.
- TRYING
- A package started and not yet healthy.
Functions§
- launch
- Picks what a packaged app runs:
shipped, the bundle in its resources directoryresources(nsh, holdingassets/nsh-updater.json), or a newer signed package from its updates when itsnsh.jsontrusts package roots ("updater": { "packages": { "roots": [...] } }) andsupport_diris its engine’scrate::EngineConfig::support_dir. Never fails: any problem with a package is logged and the shipped bundle runs. - package_
to_ run launchfor a launcher that reads its resources itself (Android’s, from the APK):configis the shippednsh-updater.json, whichshippedgets as itsBundle::updater_config.None: the shipped bundle runs.- updates_
dir - The update state of app
app_idundersupport_dir(the directory each app has a directory of its own in, ascrate::EngineConfig::support_dir):<support_dir>/<app id>/updates, wherever the app’s data directory is. - verify_
download - Verifies a downloaded package as
launchwill (nsh/updater’sdownloadPackage): signed by a release key one ofrootscertifies, for appapp_id, newer thannewer_than(the running build) and the builds accepted before, for this runtime. Accepts nothing and extracts nothing;diris the app’supdates_dir. Returns its app.