updates

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 22 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 updates finds a newer version of the app for the backends whose platforms have no updater of their own (updater.Check): in the app's appcast, the RSS feed in Sparkle's format that nsgo build writes, on Linux and Android, and in the App Store on iOS. macOS and Windows hand the same appcast to Sparkle and WinSparkle instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AndroidStore

func AndroidStore(installer string) string

AndroidStore names the store that installed an Android app, which updates it, from installer, the installing package: com.android.vending for Google Play. It is "" for an APK the user installed through the system's package installer, or adb did, and for none known. An installer it does not know is a store, so an app never sends a store's users to its own downloads, which stores forbid.

func Answer

func Answer(id uint32, find func(context.Context) driver.Update, dispatch func(driver.Event))

Answer runs find off the main thread and dispatches what it found as the EventUpdate answering request id.

func Download

func Download(ctx context.Context, update driver.Update, dir string, progress func(driver.UpdateDownloadProgress)) (string, error)

Download streams an appcast package to a temporary file in dir, verifies its size, SHA-256 and Ed25519 signature directly from the streamed file, and atomically moves it into place. Partial or unverified files are removed on any error or cancellation.

func Find

func Find(ctx context.Context, c Config) driver.Update

Find reads c's appcast and answers with its newest item when that is newer than the running build.

func FindInAppStore

func FindInAppStore(ctx context.Context, c Config, country string) driver.Update

FindInAppStore asks the App Store of country, an ISO 3166 code or "" for the United States', for the app by its bundle ID, and answers with its version there when that is newer than the running one. An app the store does not list there has none newer.

func FindInMacAppStore

func FindInMacAppStore(ctx context.Context, c Config, country string) driver.Update

FindInMacAppStore asks Apple's lookup API for a Mac app, whose entity differs from the iPhone and iPad software returned by the default lookup.

func FindMatching

func FindMatching(ctx context.Context, c Config, match func(Item) bool) driver.Update

FindMatching reads c's appcast and answers with its newest release when that is newer than the running build. Among items of the newest build, it selects the first signed item match accepts (or the first signed item when match is nil) as the downloadable package; when none matches or the appcast is unsigned, Download is left empty so the updater offers the release's page.

func LinuxInstallCommand

func LinuxInstallCommand(pkgPath string) ([]string, error)

LinuxInstallCommand returns the privileged package-manager command for a Debian or Arch package staged at pkgPath.

func LinuxOwnershipCommand

func LinuxOwnershipCommand(download, exe string) ([]string, bool)

LinuxOwnershipCommand returns the package-manager query command that checks whether the package manager matching download owns exe.

func LinuxSelfUpdatable

func LinuxSelfUpdatable(ctx context.Context, exe, appImage, download string) bool

LinuxSelfUpdatable reports whether download can replace the running Linux app: an AppImage when appImage is non-empty, or a Debian/Arch package when its package manager owns exe and the app is not running from an AppImage.

func Newer

func Newer(a, b string) bool

Newer reports whether version a is newer than b, as Sparkle compares them: run by run, of digits, compared as numbers, of periods and of anything else, compared as text. A number is newer than text and a period. Where one version has more runs, the next one makes it older when it is text (1.0b1 before 1.0) and newer otherwise (1.0.1 after 1.0).

func NotesText

func NotesText(description string) string

NotesText is an appcast item's description, HTML as nsgo build writes it from -release-notes' Markdown, as the plain text the updater's prompt shows: a line for each paragraph, heading and list item, list items behind "• ", runs of spaces made one and blank lines between blocks dropped.

func ReplaceAppImage

func ReplaceAppImage(stagedPath, targetPath string) error

ReplaceAppImage atomically replaces the running AppImage at targetPath with the verified staged file at stagedPath, preserving permissions with executable bits set. If any step fails, the temporary file is removed and targetPath stays unchanged.

func WinSparkleLanguage

func WinSparkleLanguage(tag string) string

WinSparkleLanguage maps the catalog language an app shows to the name WinSparkle's win_sparkle_set_lang takes for a translation WinSparkle 0.9.4 ships, or to "en" for English, the language its own strings are written in. An empty result, for an app without catalogs or a language WinSparkle does not translate, leaves WinSparkle to follow the Windows UI language, as it does when no language is set: once one is set, WinSparkle shows English rather than that default when it lacks the translation.

The names are in lower case, as zh_cn: wxWidgets lists the translations WinSparkle.dll holds by their resource names, which it lowers, and compares the language set with them case-sensitively, so zh_CN, as the translation's file is named, finds none and shows English.

Types

type Config

type Config struct {
	// App and ID are the app's name and identifier.
	App, ID string
	// Version is the running version as users see it, and Build the one
	// an appcast item's sparkle:version is compared with: the build
	// number, else Version.
	Version, Build string
	// Feed is this target's appcast, and Key the public EdDSA key its
	// downloads are signed with, in base64.
	Feed, Key string
	// Automatic has the app check on its own: WinSparkle on its schedule,
	// and nsgo.Run once a day as the app starts elsewhere.
	Automatic bool
	// Channel and Development distinguish intentionally disabled builds.
	Channel     string
	Development bool
	// PageOnly means this installation cannot install the appcast package.
	PageOnly bool
	// Store is what installed the app and updates it in nsgo.yaml's
	// place, as the backend finds as the app starts: Google Play or
	// another store on Android, Flatpak or Snap on Linux, TestFlight on
	// iOS. Store installs read no appcast; Google Play supports manual native checks.
	Store string
}

Config is how the app updates, as the nsgo tool sets it from nsgo.yaml's updates; nsgo.Run gives it to the backend.

func LinuxConfig

func LinuxConfig(c Config) Config

LinuxConfig resolves Debian-package ownership before the first view. The generated Linux appcast offers a .deb; other installations offer its page. A timed-out or unavailable package manager is treated as an unowned copy.

func (Config) Checks

func (c Config) Checks(appStore bool) bool

Checks reports whether the app has anything to check, appStore for iOS, which asks the App Store, and elsewhere its appcast.

func (Config) PlayUpdates

func (c Config) PlayUpdates() bool

PlayUpdates reports whether a manual check may enter Google's native update flow. Play keeps its own automatic schedule; other stores and disabled or development builds never enter this SDK or fall back to an appcast.

func (Config) State

func (c Config) State(appStore bool) driver.UpdaterState

State resolves build and installation facts without network I/O.

type Item

type Item struct {
	// Version is what users see (sparkle:shortVersionString, else
	// sparkle:version) and Build what is compared (sparkle:version).
	Version, Build string
	// Link is the release's page, else its download.
	Link string
	// Notes are the release's notes as plain text, "" without any.
	Notes string
	// Download and its integrity metadata name the package itself.
	Download, Signature, SHA256 string
	Size                        int64
}

Item is a release an appcast lists.

func ParseAppcast

func ParseAppcast(data []byte) (Item, error)

ParseAppcast reads an appcast's newest release: its first item of the highest build that names one and a page or download.

func ParseAppcastItems

func ParseAppcastItems(data []byte) ([]Item, error)

ParseAppcastItems reads all items of an appcast's newest release: every item of the highest build that names a build and a page or download, in feed order. Linux appcasts list one item per package format for the same build.

type LinuxPackageKind

type LinuxPackageKind uint8

LinuxPackageKind identifies a self-updatable Linux package format.

const (
	LinuxPackageNone LinuxPackageKind = iota
	LinuxPackageDeb
	LinuxPackageArch
	LinuxPackageAppImage
)

func LinuxPackageFormat

func LinuxPackageFormat(nameOrURL string) LinuxPackageKind

LinuxPackageFormat classifies a package file path or download URL by suffix.

Jump to

Keyboard shortcuts

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