Expand description
Choosing the one published Linux archive that matches, proving it is the
one that was published, and putting the binary inside it at
/usr/local/bin/runner-manager without a moment in which that path holds
half a file.
§There is no download here, and that is the point
crates/app/src/cli/update.rs already fetches release assets, and it does
so under two controls worth keeping: the origin is either GitHub or a
loopback/local mirror, and SHA256SUMS is checked before anything is
installed. Re-implementing the fetch in this crate would mean a second
origin policy to keep in step with the first — which is the shape of an
unverified download path even when the first version of it is careful.
So this module takes an archive a caller already has plus the checksum document that describes it, and refuses to do anything with the archive until its SHA-256 matches. The orchestration layer supplies both from the existing update path. What is genuinely new here — and could not be borrowed — is everything after the digest matches, because the destination is inside another operating system.
§Exact version, not newest
select_exact_release differs from update’s selection in exactly one
way, and it is the important one: update looks for the newest published
archive, and this looks for the archive whose version is exactly the one
asked for. 02-target-architecture.md step 2 requires “the Linux release
artifact whose semantic version exactly matches the controlling Windows
binary”, because a WSL host running a different build from the Windows host
that manages it is a support matrix nobody wants and a bug report nobody
can read.
§Atomicity is a rename inside the distribution
Windows cannot atomically replace a file that lives in ext4 inside a WSL virtual disk, so the whole install happens there:
- the archive’s SHA-256 is verified on the Windows side, before a byte of it is piped anywhere;
- a
0700staging directory is created beside the destination, so the final step is a rename within one filesystem and is therefore atomic; - the archive is streamed into
taron the child’s stdin and the one wanted member is extracted; - the extracted binary is made executable and asked its own
--version, which must be exactly the version selected; - only then is it renamed onto the destination.
Every failure before step 5 leaves the destination exactly as it was —
03-security-and-lifecycle.md’s “old binary remains executable” row — and
the staging directory is removed on the way out either way.
Structs§
- Binary
Installer - Stages and installs one release binary inside a distribution.
- Installed
Binary - What was installed, once the rename succeeded.
- Linux
Binary Path - An absolute Linux path to a file, split into the parts the install needs.
- Published
Artifact - One release artifact: what it is called and what it must hash to.
- Release
Target - The published artifact for one operating system and architecture.
Constants§
- DEFAULT_
LINUX_ DESTINATION - Where the Linux binary lives, which is what
install.shand the Linux service registration already assume. - MAX_
ARCHIVE_ BYTES - The largest archive this will pipe into a distribution.
Functions§
- linux_
target - The published Linux archive for an architecture.
- parse_
semantic_ version X.Y.Z, as three numbers.- read_
verified_ archive - Reads an archive into memory and returns it only if it is the published one.
- select_
exact_ release - Finds the archive for
targetwhose version is exactlyversion. - sha256_
of_ file - The SHA-256 of a file, lower-case hex.
- version_
of_ asset - The version in
runner-manager-<X.Y.Z>-<target>.<extension>, when the name is exactly that and nothing else.