plat/pkg.rs#
Source: lib/plat/pkg.rs
pkg -- the package the running program comes from, and what its package system offers for
updates (lib/update builds on it; docs/UPDATES.md "Packages")
packaged() -> Packaged Msix(full name) (GetCurrentPackageFullName), Flatpak(app id)
(/.flatpak-info; $FLATPAK_ID), AppImage(file) ($APPIMAGE, an
absolute path), Snap ($SNAP), else Plain
msix_updates() -> Result<MsixUpdates, String> (Windows, in an MSIX package) the App
Installer file the package came from (Package
.GetAppInstallerInfo: its address) and, with one, whether it
offers a newer version (Package.CheckUpdateAvailabilityAsync);
WinRT through raw COM (win_winrt.rs)
FlatpakMonitor (Linux, in a Flatpak) the portal's update monitor
(linux_flatpak.rs): create(), poll(ms) -> UpdateAvailable,
update(progress, cancel) -> the newest version installed
flatpak_spawn_latest(args) (Linux) the app's newest installed version started with args
(the portal's Spawn, LATEST_VERSION) -> its pid
restart_appimage(args) -> i32 (Linux) the AppImage file started again with args (its
runtime unpacks the image that is now there): 0 / -1
app_bundle_follows(old, new) (macOS) the bundle at new may replace the app bundle at old:
its signature checks (strict, the whole bundle) against the
old one's designated requirement, or, the old one signed ad
hoc, it carries the same identifier (apple_bundle.rs) -> Err(why)
app_bundle_swap(a, b) -> bool (macOS) two folders exchanged in one step (RENAME_SWAP)
Elsewhere (web, Android) packaged() is Plain and the rest answers "not available".
enum Packagedwhere the running program comes fromPlain-- a program file of its own: a setup, a .deb or .rpm, a portable copyAppImage(String)-- an AppImage: the .AppImage file (the program runs from a copy its runtime unpacked)Flatpak(String)-- a Flatpak: the app id (the program's folder is the read-only /app)Msix(String)-- an MSIX package: its full name (the install folder is read-only)Snap-- a Snap (snapd updates it)
fn packaged() -> Packagedthe package the running program comes fromstruct MsixUpdateswhat App Installer knows about the running MSIX package (msix_updates)appinstaller: String-- the address of the .appinstaller file the package was installed from ("": none -- the Store, Add-AppxPackage, a developer registration)availability: u32-- Package.CheckUpdateAvailabilityAsync with an .appinstaller: 0 unknown, 1 no updates, 2 available, 3 required, 4 error; without one 0
fn msix_updates() -> Result<MsixUpdates, String>the App Installer file of the running MSIX package and whether it offers an update (Windows 10 1809 and later) -> Err: not in a package, or WinRT failed (its HRESULT)struct FlatpakUpdateUpdateAvailable of the Flatpak portal: the commits of the running, the installed and the remote version (an installed one newer than the running one: restart to use it)running: Stringlocal: Stringremote: String
struct FlatpakMonitor(not Linux) there is no Flatpak portal: create() fails
impl FlatpakMonitor
fn create() -> Result<FlatpakMonitor, String>fn poll(&mut self, _ms: i32) -> Option<FlatpakUpdate>fn update(&mut self, _progress: &mut dyn FnMut(u32, u32, u32), _cancel: &dyn Fn() -> bool) -> Result<(), String>fn flatpak_spawn_latest(args: &[&str]) -> Result<u32, String>start this app's newest installed Flatpak version with args (the portal's Spawn with LATEST_VERSION; the same program inside it) -> its pidfn app_bundle_follows(old: &str, new: &str) -> Result<(), String>(macOS) whether the app bundle atnewmay replace the one atold(lib/update, kind "app"): its signature checks, strict and for the whole bundle, against the old bundle's designated requirement (a team's signature: the same identifier and team); an old bundle signed ad hoc asks only for a valid signature and the same identifier. Elsewhere: Err (no app bundles)fn app_bundle_swap(a: &str, b: &str) -> bool(macOS) the folders a and b exchanged in one step (renamex_np, RENAME_SWAP): an app bundle is never missing while an update replaces it -> it worked (elsewhere: false)fn restart_appimage(args: &[&str]) -> i32start the running AppImage's file ($APPIMAGE) again with args: its runtime unpacks the image the file holds now (after an update) and runs it -> 0, -1 when not an AppImage or no process could be started