updater

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package updater discovers, verifies, and applies p-track releases.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDevelopmentBuild  = errors.New("updates are unavailable for development builds")
	ErrInvalidRelease    = errors.New("invalid GitHub release")
	ErrNoUpdate          = errors.New("no newer release is available")
	ErrUnsupportedTarget = errors.New("unsupported update target")
)
View Source
var (
	ErrInstallRefused       = errors.New("update installation refused")
	ErrPendingStageMismatch = errors.New("pending update belongs to another verified stage")
)
View Source
var ErrInvalidStage = errors.New("invalid staged update")

Functions

func CompareVersions

func CompareVersions(left, right string) (int, error)

CompareVersions compares two strict release versions (with optional leading v) and returns -1, 0, or 1. Development and prerelease strings are rejected.

func RecoverPendingApply

func RecoverPendingApply(ctx context.Context, stageRoot string) (bool, error)

RecoverPendingApply resolves a crash-interrupted Linux replacement. It only cleans a verified new target or an unchanged original; ambiguous state is preserved for manual recovery.

func ValidateStage

func ValidateStage(stage StagedUpdate) error

ValidateStage revalidates the durable record, package digest, size, paths, archive payload, and machine type immediately before installation.

func ValidateStageContext

func ValidateStageContext(ctx context.Context, stage StagedUpdate) error

ValidateStageContext is ValidateStage with cancellation for hashing and executable parsing before an install attempt.

Types

type ApplyAction

type ApplyAction string

ApplyAction describes the bounded host action completed for an update.

const (
	ApplyInstalled       ApplyAction = "installed-restart-required"
	ApplyOpenedInstaller ApplyAction = "opened-native-installer"
	ApplyRevealedArchive ApplyAction = "revealed-verified-archive"
)

type ApplyResult

type ApplyResult struct {
	Version         string      `json:"version"`
	Action          ApplyAction `json:"action"`
	RestartRequired bool        `json:"restartRequired"`
	ManualInstall   bool        `json:"manualInstall"`
	CleanupPending  bool        `json:"cleanupPending"`
}

ApplyResult contains no filesystem paths or remote URLs.

type Asset

type Asset struct {
	Name        string
	DownloadURL string
	SizeBytes   int64
}

Asset is one exact packaged GitHub Release asset selected by the host.

type Candidate

type Candidate struct {
	Version     string
	Tag         string
	PageURL     string
	PublishedAt time.Time
	Notes       string
	Package     Asset
	Checksums   Asset
}

Candidate is a newer stable release and the two assets required to stage it.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client performs bounded discovery against p-track's fixed GitHub repository.

func NewClient

func NewClient() *Client

NewClient returns a production release-discovery client. Redirects are not accepted for metadata; release asset redirects are handled during staging.

func (*Client) Check

func (c *Client) Check(ctx context.Context, currentVersion string, target Target) (Candidate, error)

Check returns a strictly newer stable release for target. It accepts only p-track's exact packaged asset names and checksum manifest.

func (*Client) Stage

func (c *Client) Stage(
	ctx context.Context,
	candidate Candidate,
	target Target,
	baseDir string,
	progress ProgressFunc,
) (stage StagedUpdate, err error)

Stage downloads the exact candidate package into a new private directory, verifies checksums.txt, validates the archive layout and machine type, and persists a bounded recovery record. Any failure removes the partial stage.

type Installer

type Installer struct {
	// contains filtered or unexported fields
}

Installer applies or hands off a verified stage using fixed host commands.

func NewInstaller

func NewInstaller() *Installer

NewInstaller returns the production platform installer.

func (*Installer) Apply

func (i *Installer) Apply(ctx context.Context, stage StagedUpdate) (ApplyResult, error)

Apply revalidates the stage and dispatches only to the running host target.

type Progress

type Progress struct {
	Asset      string
	Downloaded int64
	Total      int64
}

Progress reports bounded download progress. Asset is either "checksums" or "package"; paths and URLs are deliberately omitted.

type ProgressFunc

type ProgressFunc func(Progress)

ProgressFunc receives staging progress on the caller's goroutine.

type StageKind

type StageKind string

StageKind identifies the verified payload preserved for installation.

const (
	StageDarwinDMG   StageKind = "darwin-dmg"
	StageLinuxBinary StageKind = "linux-binary"
	StageWindowsZIP  StageKind = "windows-zip"
)

type StagedUpdate

type StagedUpdate struct {
	Root             string
	AssetPath        string
	PayloadPath      string
	StatePath        string
	Version          string
	AssetName        string
	GOOS             string
	GOARCH           string
	SHA256           string
	SizeBytes        int64
	PayloadSHA256    string
	PayloadSizeBytes int64
	Kind             StageKind
}

StagedUpdate contains only private local paths and verified release facts.

func LoadStage

func LoadStage(root string) (StagedUpdate, error)

LoadStage reconstructs and validates a durable stage after process restart.

func LoadStageContext

func LoadStageContext(ctx context.Context, root string) (StagedUpdate, error)

LoadStageContext reloads and validates a durable stage with cancellation.

type Target

type Target struct {
	GOOS   string
	GOARCH string
}

Target is a host-selected operating system and architecture pair. It must never be populated from frontend or release metadata.

Jump to

Keyboard shortcuts

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