18. Updates#
lib/update (UPDATES.md) brings signed updates with a rollback to any app. The
app builds an update::Config (its id, version -- rt::app_version!(), the version= of its
PACKAGE -- the address of update.json and the Ed25519
public keys of its publisher, as hex constants in the code), calls update::startup(&cfg) first
in ui::main! and update::healthy(&cfg) once it works:
ui::main!({
if let update::Startup::RolledBack(v) = update::startup(&update_config()) {
// version v did not start and was rolled back: tell the user
}
ui::launch(&DESC, App::default(), &style::STYLE)
});
update::Updater::new(cfg)--start_check()/start_download()run on a thread and wake the UI (UIC_WAKE);status()has the phase (Available,Downloadingwithdone/total,Ready,Failedwith the error) for a dialog or a status line;cancel();apply()puts the update in place now and restarts the program.- A downloaded update is put in place by the next
startup(), which restarts into it. The new version runs on trial untilhealthy(); a start that finds the trial still open restores the old files and restarts the old version, which learns of it throughStartup::RolledBack. - Everything is checked against the signature (
tools/update_manifest.pywrites and signs the channel,tools/package.py --update DIRdoes it per style); the downloads go through the app'snet.connectrules. Putting files in place needs a writable program folder (fs.write $EXE/**inPERMISSIONS); programs in system folders usepackageupdates. - The same calls follow the way the program is installed (
update::install(&cfg), aplat::pkg::Packaged): an AppImage replaces its.AppImagefile with the channel'sappimageentry (trial and rollback as above; a signed AppImage only takes one signed with the same key; a folder the user cannot write isError::ReadOnly;fs.write $APPIMAGE/**), a Flatpak checks and installs through the Flatpak portal (Kind::Flatpak;apply()starts the new version), and an MSIX package or a Snap answersCheck::Managed(..): App Installer, the Store or snapd update it (UPDATES.md, "Packages"). On macOS a program in an app bundle takes the channel'sappentry: the wholeNAME.appis replaced in one step after its signature checked against the installed one (UPDATES.md, "macOS app bundles"). - Windows and Linux on ARM64 (ARM64.md) are targets of their own in the channel,
windows-aarch64andlinux-aarch64(update::target()):tools/package.py APP --arch aarch64 --update DIRadds their files to the channel the x86-64 run wrote for the same version, so oneupdate.jsonserves both processors and each program takes its own entry.