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.gzand.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 doctorwarns (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_URLsays otherwise. - STALE_
MS - Baseline: how old
update.jsonmay 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, elseRELEASES_URL) and records the answer inupdate.json; a failure is recorded too (the earlierlatestkept). Off withBORG_UPDATE_CHECK=off: then it does nothing and says so. - checked
- The last check’s result; none before the first.
- checked_
at checkedfor the storehome(path_for).- doctor_
check borg doctor’s line on the release: WARN when a newer one exists or the check has failed for longer thanFAILING_WARN_MS, ok otherwise.- is_
version - Whether
vis a version as borg writes one: it reads as one (parse), holds only version characters ([A-Za-z0-9.+-]) and at mostVERSION_CHARSof them. A release tag becomes part of a download URL and a path; a member’s hello (protocol.rsPeerVersion::clean) is shown to drones. - main
borg update [--check] [--quiet] [--json]; returns the exit code: 0 current (or installed),EXIT_NEWERwhen--checkfinds a newer release, 1 when the check or the install failed, 2 usage.- maybe_
check - At a prompt: when
update.jsonis missing or older thanSTALE_MSand no check started withinCHECKING_MS, startsborg update --check --quietdetached (its own session, no terminal, never waited for). Returns the record read, so the notice reads the file once. Off withBORG_UPDATE_CHECK=off. - member_
lines - The members of the collective at
storeby version, newest first, each older one with what it misses (protocol.rsNOTES), then the members nothing syncs with, each named once: a mismatch is newer than the version record of the last session that completed (asborg doctor,borg topandborg webtell it). Empty withoutmesh/. - newer
- Whether version
ais newer thanb: numericx.y.z(a missing part is 0, a leadingvis 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:
checkedthe last release check (maybe_check),storethe routed collective’s store (itsmesh/read only when it exists),shownthe session’s marker of the states already said. None when nothing is new. - on
- Whether the release check runs (
BORG_UPDATE_CHECK=offturns it off). - path
$BORG_HOME/update.json, in the root store when BORG_HOME is a collective’s (collective.rsroot_of): one check per machine, whichever collective’s hook ran it.- path_
for pathfor the storehome(one of a collective’s or the root):borg webreads 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.