Documentation
¶
Overview ¶
Package update holds what the updater of package mygo and `mygo build` share: the update manifest, signatures, versions, and the formats of archives and delta updates.
Index ¶
- Constants
- Variables
- func ApplyDelta(r io.ReaderAt, size int64, from, to, oldDir, newDir string) error
- func Compare(a, b string) int
- func Diff(old, new []byte) []byte
- func ExtractArchive(r io.Reader, dir string) error
- func ManifestName(target string) string
- func ParsePrivateKey(s string) (ed25519.PrivateKey, error)
- func ParsePublicKey(s string) (ed25519.PublicKey, error)
- func Patch(w io.Writer, size int64, old io.ReaderAt, oldSize int64, patch io.ReaderAt, ...) error
- func RefreshDesktopEntry(dir, name string) error
- func ReleaseNotes(changelog, version string) string
- func ResolveFeed(ctx context.Context, feed string, get Getter) (string, error)
- func Sign(key ed25519.PrivateKey, digest []byte) string
- func TaggedFeed(repo, prefix, name string) string
- func Verify(key ed25519.PublicKey, digest []byte, signature string) error
- func WriteArchive(w io.Writer, dir string, entries []string) error
- func WriteDelta(w io.Writer, from, to, oldDir, newDir string, entries []string) error
- type Archive
- type Delta
- type Getter
- type Manifest
Constants ¶
const ( MaxManifestSize = 1 << 20 MaxArchiveSize = 1 << 30 )
Limits of what an app downloads.
const VersionPlaceholder = "{version}"
VersionPlaceholder stands for the version in the feed of tagged releases.
Variables ¶
var ErrNotPublished = errors.New("no release is published")
ErrNotPublished is returned by ResolveFeed when no release is tagged with the prefix of the feed.
var GitHubAPI = "https://api.github.com"
GitHubAPI is the GitHub REST API, which tests replace.
Functions ¶
func ApplyDelta ¶ added in v0.1.15
ApplyDelta makes in newDir, which must not exist, the app that the delta of size bytes read from r makes of the app in oldDir. The delta must update version from to version to, and every file it makes must have the size and SHA-256 its index gives.
func Compare ¶
Compare compares versions such as 1.2.3 and 1.3.0-beta.1 like semantic versioning does: numbers numerically, a pre-release before its release.
func ExtractArchive ¶
ExtractArchive unpacks an archive of WriteArchive into dir. It refuses entries outside dir, links pointing out of it and anything but files, directories and symbolic links.
func ManifestName ¶
ManifestName is the file name of the manifest of target.
func ParsePrivateKey ¶
func ParsePrivateKey(s string) (ed25519.PrivateKey, error)
ParsePrivateKey decodes a private key.
func ParsePublicKey ¶
ParsePublicKey decodes a public key.
func Patch ¶ added in v0.1.15
func Patch(w io.Writer, size int64, old io.ReaderAt, oldSize int64, patch io.ReaderAt, patchSize int64) error
Patch writes to w the file of size bytes that patch makes of old, a file of oldSize bytes. Patches come from signed updates, but a damaged one fails cleanly: it cannot make more than size bytes, bytes read out of old count as zeros, as in bspatch, and the caller checks the file made.
func RefreshDesktopEntry ¶ added in v0.1.16
RefreshDesktopEntry registers again the desktop entry and MIME package of the Linux app in dir, whose executable is name, as install.sh does, when install.sh registered them: when the user's entry runs the app in dir.
func ReleaseNotes ¶
ReleaseNotes returns the section of a Markdown changelog under the "## <version>" heading, or "## [<version>]" as in Keep a Changelog (a date or other text may follow the version), or "" when there is none.
func ResolveFeed ¶ added in v0.1.19
ResolveFeed returns the URL of the manifest that feed names: feed itself, or for a feed of tagged releases (TaggedFeed) the manifest of the newest release with the tag's prefix that is neither a draft nor a prerelease, as the GitHub API lists them, newest first.
func Sign ¶
func Sign(key ed25519.PrivateKey, digest []byte) string
Sign signs the SHA-256 digest of an archive.
func TaggedFeed ¶ added in v0.1.19
TaggedFeed returns the feed of the manifest name in the newest release of the GitHub repository repo ("owner/name") tagged prefix and a version.
func WriteArchive ¶
WriteArchive writes the entries of dir (files, directories and symbolic links, with their permissions) as a gzip compressed tar archive.
Types ¶
type Archive ¶ added in v0.1.15
type Archive struct {
Version string `json:"version"`
URL string `json:"url"`
Size int64 `json:"size"`
Signature string `json:"signature"`
}
Archive is the archive of an earlier version.
type Delta ¶ added in v0.1.15
type Delta struct {
From string `json:"from"`
URL string `json:"url"`
Size int64 `json:"size"`
Signature string `json:"signature"`
}
Delta is a delta update of the app of version From, signed like the archive.
type Manifest ¶
type Manifest struct {
Version string `json:"version"`
// Notes are the release notes, in Markdown.
Notes string `json:"notes,omitempty"`
// Date is when the version was built, in RFC 3339 format.
Date string `json:"date,omitempty"`
// URL of the archive, its size in bytes and the Ed25519 signature of
// its SHA-256 digest, in base64.
URL string `json:"url"`
Size int64 `json:"size"`
Signature string `json:"signature"`
// Deltas update earlier versions with smaller downloads (delta.go).
Deltas []Delta `json:"deltas,omitempty"`
// Previous are the archives of the versions before, newest first,
// which `mygo build` makes the deltas of the next version from.
Previous []Archive `json:"previous,omitempty"`
}
Manifest describes the latest version of an app for one target (such as darwin-arm64), published as update-<target>.json next to the archive.