Skip to main content

Module updates

Module updates 

Source
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.nshpkg once a launch starts it, until it proves healthy (it then becomes current.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 writes next.nshpkg without 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).
PackageRun
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 directory resources (nsh, holding assets/nsh-updater.json), or a newer signed package from its updates when its nsh.json trusts package roots ("updater": { "packages": { "roots": [...] } }) and support_dir is its engine’s crate::EngineConfig::support_dir. Never fails: any problem with a package is logged and the shipped bundle runs.
package_to_run
launch for a launcher that reads its resources itself (Android’s, from the APK): config is the shipped nsh-updater.json, which shipped gets as its Bundle::updater_config. None: the shipped bundle runs.
updates_dir
The update state of app app_id under support_dir (the directory each app has a directory of its own in, as crate::EngineConfig::support_dir): <support_dir>/<app id>/updates, wherever the app’s data directory is.
verify_download
Verifies a downloaded package as launch will (nsh/updater’s downloadPackage): signed by a release key one of roots certifies, for app app_id, newer than newer_than (the running build) and the builds accepted before, for this runtime. Accepts nothing and extracts nothing; dir is the app’s updates_dir. Returns its app.