Skip to main content

Module update

Module update 

Source
Expand description

Whether a newer borg is released, and borg update [--check] [--quiet] [--json], which installs it.

The check (check) asks GitHub for the latest release (curl, as vectors.rs fetches its model: the hook binary carries no HTTP stack) and writes $BORG_HOME/update.json (the root store’s, see path): {checked_ms, latest, error}. The prompt hook starts it detached, at most once a day and never twice within CHECKING_MS (maybe_check); the hook itself never waits on the network. BORG_UPDATE_CHECK=off turns both off (tests run with it); BORG_RELEASES_URL names another release feed (a file:// fixture in the tests).

The notice (notice): at a prompt, the drone hears once per session per state that a newer release exists, that nothing syncs with a member on a newer mesh protocol (protocol.rs mismatches), or that a member runs a newer borg the release feed has too. It tells the engineer and offers borg update; the drone runs it on their yes. Nobody configures anything.

The install (main) follows where this borg lives (install.rs bin): under $CARGO_HOME/bin it runs cargo install for the three crates; elsewhere, on a target scripts/install.sh serves, it downloads the release tarball beside the binaries, checks its sha256 and renames each binary into place; anything else (a target/ build, another OS) gets the commands printed and nothing changed. Then the new borg refreshes the harnesses already wired (borg install <h> --apply) and runs borg doctor.

Structs§

Checked
What the last release check found (update.json).

Constants§

CHECKING_MS
Guard: how long a started check (update.checking) keeps other prompts from starting one: at most one curl per machine per 10 minutes, even when every check fails.
DOWNLOAD_URL
Protocol: where release tarballs are, as scripts/install.sh names them, unless BORG_DOWNLOAD_URL (install.sh’s mirror variable) says otherwise: <base>/v<X>/borg-v<X>-<target>.tar.gz and .sha256.
EXIT_NEWER
Protocol: borg update --check’s exit code when a newer release exists (0: current, 1: the check failed).
FAILING_WARN_MS
Baseline: how long the check may keep failing before borg doctor warns (3 days): one offline day or a GitHub hiccup is no news, a check that never works is.
RELEASES_URL
Protocol: GitHub’s latest-release endpoint for borg (scripts/install.sh reads the same), unless BORG_RELEASES_URL says otherwise.
STALE_MS
Baseline: how old update.json may be before a prompt starts another check (clock::DAY_MS): a release a day late is news enough, and an idle prompt reads one small file.
VERSION
This borg’s version.
VERSION_CHARS
Guard: the longest version string borg reads (a release tag, a member’s hello): longer than any release name, short enough that no text rides along.

Functions§

check
Asks the release feed (BORG_RELEASES_URL, else RELEASES_URL) and records the answer in update.json; a failure is recorded too (the earlier latest kept). Off with BORG_UPDATE_CHECK=off: then it does nothing and says so.
checked
The last check’s result; none before the first.
checked_at
checked for the store home (path_for).
doctor_check
borg doctor’s line on the release: WARN when a newer one exists or the check has failed for longer than FAILING_WARN_MS, ok otherwise.
is_version
Whether v is a version as borg writes one: it reads as one (parse), holds only version characters ([A-Za-z0-9.+-]) and at most VERSION_CHARS of them. A release tag becomes part of a download URL and a path; a member’s hello (protocol.rs PeerVersion::clean) is shown to drones.
main
borg update [--check] [--quiet] [--json]; returns the exit code: 0 current (or installed), EXIT_NEWER when --check finds a newer release, 1 when the check or the install failed, 2 usage.
maybe_check
At a prompt: when update.json is missing or older than STALE_MS and no check started within CHECKING_MS, starts borg update --check --quiet detached (its own session, no terminal, never waited for). Returns the record read, so the notice reads the file once. Off with BORG_UPDATE_CHECK=off.
member_lines
The members of the collective at store by version, newest first, each older one with what it misses (protocol.rs NOTES), then the members nothing syncs with, each named once: a mismatch is newer than the version record of the last session that completed (as borg doctor, borg top and borg web tell it). Empty without mesh/.
newer
Whether version a is newer than b: numeric x.y.z (a missing part is 0, a leading v is ignored), a pre-release (-rc.1) below its release, pre-releases by their dot-separated parts (numbers numerically, below words). Build metadata (+…) does not count. False when either does not read as a version.
notice
What the drone hears at a prompt (module doc), each state once per session: checked the last release check (maybe_check), store the routed collective’s store (its mesh/ read only when it exists), shown the session’s marker of the states already said. None when nothing is new.
on
Whether the release check runs (BORG_UPDATE_CHECK=off turns it off).
path
$BORG_HOME/update.json, in the root store when BORG_HOME is a collective’s (collective.rs root_of): one check per machine, whichever collective’s hook ran it.
path_for
path for the store home (one of a collective’s or the root): borg web reads it for any store.
release_line
One line on the release check: the latest release and when it was checked, or why there is none.
sha256_file
The hex sha256 of the file at path.