Skip to main content

Module upgrade_package

Module upgrade_package 

Source
Expand description

The launcher’s half of upgrading a .deb or .rpm install from the app (docs/specs/SPEC_LINUX_PACKAGE_UPGRADE_AND_REPOSITORY_2026_10_24.md §3.1, phase 3g-1).

Installing a package takes root, and AgentMux never runs as root. So instead of the usual “quit, then run the installer”, the user is asked for permission first, while AgentMux is still open: pkexec starts the package’s own helper (/opt/agentmux/bin/agentmux-install-update, scripts/agentmux-install-update.sh), the desktop shows its password prompt, and the helper checks the file itself and prints READY. Only then does the launcher quit; the helper waits for it to be gone, installs, and a small waiter, started before any of that and kept running after the launcher exits, starts AgentMux again whether the install worked or not, so the old version runs rather than none.

If the password is refused, can’t be asked for, or the file fails its checks, nothing quits: the reason is left for srv (INSTALL_RESULT_FILE) and the panel says it.

Structs§

PackageUpgrade
A package that the user’s password can install.

Constants§

DISMISSED 🔒
pkexec exits with this when the user dismissed the password prompt, and with NOT_AUTHORIZED when it couldn’t authorise the command (no prompt to show, or not allowed).
GO_BACK_ARG 🔒
What to hand the helper in place of a file when it is to install the version the last upgrade replaced.
GO_BACK_AUTHORIZE_WITHIN 🔒
How long going back waits for the helper’s READY: it prints that only once it has downloaded the old release (its download may take up to 900 s) and checked it, and the user’s password prompt comes before all of that. Stopping the wait early would leave the helper without the waiter that starts AgentMux again.
GO_BACK_WITHIN 🔒
How long after an upgrade going back is still offered: after that, what the new version did to its data is too much to leave behind.
HELPER_NAME
The helper’s name in INSTALL_BIN.
INSTALL_BIN
Where a package puts AgentMux’s programs.
NOT_AUTHORIZED 🔒
START_COMMAND
The command that starts the installed AgentMux (the package’s wrapper).
STATE_DIR
The helper’s record of the last upgrade it did (from= and to= lines), readable by anyone: what “go back” is offered from.
WAITER 🔒
What the waiter runs: pkexec <helper> <file> <version> <launcher pid>, with the helper’s output in files the launcher and the waiter read (the files are opened here, as the user, so root never needs a path in the user’s folders). Arguments: pkexec, helper, file, version, launcher pid, out, err, result, the command that starts AgentMux.

Statics§

WAITER_GROUP 🔒
The waiter’s process group while the password prompt is open (0 when none).

Functions§

authorize
Ask for permission to install up (the desktop’s password prompt, through polkit) and have its helper check the file. true once the helper is waiting for AgentMux to quit: the waiter then carries on without the launcher. false (with the reason left for srv, unless the user simply said no) when nothing will be installed, so AgentMux keeps running.
authorize_with 🔒
check
Check what srv names to install against this install: installer is the release’s package for version, as downloaded into this version’s updates/<version>/ and whole by sha256, and this launcher is the installed one (own_dir is bin_dir) with the install helper beside it.
dismiss
Close the password prompt (and with it the waiter), as “Not now”.
go_back_question
What the dialog asks when the new version could not be kept running.
go_back_version
Whether the last upgrade the helper did replaced version with own_version (the running one) not long before now: then going back to it is on offer. record is the helper’s last-upgrade file: from= and to= lines.
last_reason 🔒
The last line the helper left on stderr, without its prefix.
leave_result 🔒
Leave error for srv, which shows it in the version panel.
offer_go_back
The new version could not be kept running (why finishes “AgentMux X ___”): offer to go back to the version the last upgrade replaced. true once the helper has accepted and is waiting for this launcher to exit: the caller exits, and the waiter starts the old version. Only for a .deb/.rpm install, one upgrade from the app ago (the helper’s record), and the user’s yes.
package_file_name
The release’s file for version, by package kind.
question
What the dialog asks before the password is: the user agrees to quit, then the desktop asks for the password.
read_result 🔒
The reason an earlier try left (see leave_result).