Skip to main content

Module updates

Module updates 

Source
Expand description

Looking for a newer GitPoulpi release (the updates-and-install design, slice A).

Everything here is pure except check, which asks GET /repos/<owner>/<name>/releases through an HttpTransport (so the tests never open a socket) and UpdateState, the small JSON file that keeps the last answer and the version the user chose to skip.

Traps:

  • /releases/latest never returns a pre-release, so the channel cannot be honoured through it: the list is fetched and filtered here.
  • Semver, not string, order: 0.10.0 is newer than 0.9.0, and a pre-release (0.2.0-rc.1) is older than its release (0.2.0).
  • The sources (GitHub, NuGet, manifest) live in sources; they all end in newest_after_pinned, so semver, channel and pin rules exist once.
  • A private repository answers 404 without a token; that is a normal “no answer”, never a user-facing error (the caller logs one line).

Modules§

notices
Security notices (the security-hardening design, item 7): the signed security.json a release publishes, and which of its notices name the running version.
signing
Release signatures (the security-hardening design, item 4): the check every file GitPoulpi fetches from a release goes through before it is trusted.
sources
Where an update check asks (the install-channels design, section 1.5).

Structs§

Asset
One downloadable file of a release.
CheckParams
What one check needs.
Release
A published release, as far as the notice needs it.
UpdateState
What is kept between runs (<data dir>/updates.json): when the host was last asked, what it said, and the version the user chose to skip.
Version
A semantic version: major.minor.patch[-pre][+build], a leading v tolerated. Build metadata is ignored, as semver says.

Constants§

API_ENV
Env var that points the check at another API root (tests: a loopback server). Unset: https://api.github.com. Test builds refuse every non-loopback host anyway (http::external_host_refusal).
CHECK_INTERVAL_SECS
A day, in seconds: the throttle between two checks.
DOWNLOAD_HOSTS
The hosts a release download may touch, the first request and every redirect: GitHub’s release pages and the CDN its asset links redirect to. Anything else is refused (a tampered release JSON must not send the updater to a host of its choosing). Loopback joins them only while API_ENV is set, which is how tests point the whole flow at a fake server.

Functions§

api_base
The API root the check talks to.
check
Asks GitHub (the base API root) for the releases and returns the newer one, if any. Kept for the callers that predate sources::SourceSpec.
download_host_allowed
Whether url is https on one of the DOWNLOAD_HOSTS (or loopback while testing).
download_host_allowed_with
download_host_allowed plus extra hosts: the policy’s download_base (a mirror), given as a URL or a bare host. The mirror is allowed only when the caller passes it; it is never a global. Matching is on the host alone (no suffix match: mirror.example.evil is not mirror.example) and the scheme must still be https.
newest_after
The newest release allowed by channel that is newer than running; None when the running build is up to date (or newer: a dev build).
newest_after_pinned
The one filter every check source ends in: allowed by channel, within pin, newer than running, then the highest by semver.
parse_releases
Reads the /releases answer: drafts and tags that are not a version are dropped. target picks the asset.
pick_assets
The archive and checksum of version for target among assets.
version_of_tag
The version a release tag names: releases/v0.2.0 (this repository’s rule), or a bare v0.2.0 / 0.2.0. Any other prefix is not a release.
within_pin
Whether version is at or below pin: "1.4" (or "1") is any 1.4.x (any 1.x), "1.4.2" is at most 1.4.2. An unreadable pin allows nothing: an administrator’s typo must not lift the ceiling.