Documentation
¶
Overview ¶
Package selfupdate resolves and downloads akari client releases from GitHub so the client can update itself in place.
It is the Go counterpart of the install scripts in scripts/: it resolves the latest published release, downloads the archive that matches a target OS and architecture, verifies it against the release SHA256SUMS, and extracts the binary. The client uses it for a fully native update with no shell or curl.
Index ¶
Constants ¶
const DefaultRepo = "jssblck/akari"
DefaultRepo is the GitHub owner/repo releases are pulled from. AKARI_REPO overrides it, matching the install scripts.
Variables ¶
This section is empty.
Functions ¶
func AssetName ¶
AssetName is the release archive filename for a binary and target, matching the names the release workflow produces: the version without a leading v, a .zip for Windows, and a .tar.gz everywhere else.
func CleanupOld ¶
func CleanupOld(target string)
CleanupOld is a no-op on Unix; only the Windows path leaves a stale file behind after an update.
func Replace ¶
Replace installs newPath at target, replacing the running binary.
On Unix a running executable's file can be replaced while it runs: the kernel keeps the old inode mapped for the live process, and the rename atomically swaps the directory entry so the next launch picks up the new binary. newPath must be on the same filesystem as target (the caller extracts it into target's directory) so the rename does not fail with a cross-device error.
func UpToDate ¶
UpToDate compares the running version against the latest release tag.
upToDate is true when current is the same as, or newer than, latest (so a build running a prerelease ahead of the latest stable is not told to downgrade). comparable is false when current is not a valid semver tag (a development build stamped with a commit SHA or "dev"), in which case upToDate is meaningless and callers should treat the build as updatable.
Types ¶
type Client ¶
type Client struct {
// Repo is the GitHub owner/repo to download from.
Repo string
// APIBaseURL is the base for the GitHub API. Overridable for testing.
APIBaseURL string
// DownloadBaseURL, when non-empty, is the base URL holding the archive and
// SHA256SUMS, overriding the per-tag GitHub release URL. It mirrors the
// AKARI_BASE_URL the install scripts honor, and lets tests point at a local
// server.
DownloadBaseURL string
// contains filtered or unexported fields
}
Client resolves and downloads release assets. The zero value is not usable; construct one with New.
func New ¶
func New() *Client
New builds a Client with the default GitHub endpoints, honoring the AKARI_REPO and AKARI_BASE_URL environment overrides the install scripts also respect.