update

package
v0.1.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package update holds what the updater of package golet and `golet build` share: the update manifest, signatures, versions, and the formats of archives and delta updates.

Index

Constants

View Source
const (
	MaxManifestSize = 1 << 20
	MaxArchiveSize  = 1 << 30
)

Limits of what an app downloads.

View Source
const VersionPlaceholder = "{version}"

VersionPlaceholder stands for the version in the feed of tagged releases.

Variables

View Source
var ErrNotPublished = errors.New("no release is published")

ErrNotPublished is returned by ResolveFeed when no release is tagged with the prefix of the feed.

View Source
var GitHubAPI = "https://api.github.com"

GitHubAPI is the GitHub REST API, which tests replace.

Functions

func ApplyDelta

func ApplyDelta(r io.ReaderAt, size int64, from, to, oldDir, newDir string) error

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

func Compare(a, b string) int

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 Diff

func Diff(old, new []byte) []byte

Diff returns the patch that turns old into new.

func ExtractArchive

func ExtractArchive(r io.Reader, dir string) error

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

func ManifestName(target string) string

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

func ParsePublicKey(s string) (ed25519.PublicKey, error)

ParsePublicKey decodes a public key.

func Patch

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

func RefreshDesktopEntry(dir, name string) error

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

func ReleaseNotes(changelog, version string) string

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

func ResolveFeed(ctx context.Context, feed string, get Getter) (string, error)

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

func TaggedFeed(repo, prefix, name string) string

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 Verify

func Verify(key ed25519.PublicKey, digest []byte, signature string) error

Verify checks the signature of the SHA-256 digest of an archive.

func WriteArchive

func WriteArchive(w io.Writer, dir string, entries []string) error

WriteArchive writes the entries of dir (files, directories and symbolic links, with their permissions) as a gzip compressed tar archive.

func WriteDelta

func WriteDelta(w io.Writer, from, to, oldDir, newDir string, entries []string) error

WriteDelta writes the delta that turns the app in oldDir, of version from, into the app in newDir, of version to: the entries of newDir, or all of it when entries is nil.

Types

type Archive

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

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 Getter

type Getter func(ctx context.Context, url string) (io.ReadCloser, error)

Getter gets a URL and returns the body of a successful response.

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 `golet 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.

func (*Manifest) Delta

func (m *Manifest) Delta(from string) *Delta

Delta returns the delta update of version from, or nil.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL