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/latestnever 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.0is newer than0.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 innewest_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.jsona 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.
- Check
Params - What one check needs.
- Release
- A published release, as far as the notice needs it.
- Update
State - 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 leadingvtolerated. 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_ENVis 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
baseAPI root) for the releases and returns the newer one, if any. Kept for the callers that predatesources::SourceSpec. - download_
host_ allowed - Whether
urlishttpson one of theDOWNLOAD_HOSTS(or loopback while testing). - download_
host_ allowed_ with download_host_allowedplusextrahosts: the policy’sdownload_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.evilis notmirror.example) and the scheme must still behttps.- newest_
after - The newest release allowed by
channelthat is newer thanrunning;Nonewhen 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, withinpin, newer thanrunning, then the highest by semver. - parse_
releases - Reads the
/releasesanswer: drafts and tags that are not a version are dropped.targetpicks the asset. - pick_
assets - The archive and checksum of
versionfortargetamongassets. - version_
of_ tag - The version a release tag names:
releases/v0.2.0(this repository’s rule), or a barev0.2.0/0.2.0. Any other prefix is not a release. - within_
pin - Whether
versionis at or belowpin:"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.