Documentation
¶
Overview ¶
Package updater discovers, verifies, and applies p-track releases.
Index ¶
- Variables
- func CompareVersions(left, right string) (int, error)
- func RecoverPendingApply(ctx context.Context, stageRoot string) (bool, error)
- func ValidateStage(stage StagedUpdate) error
- func ValidateStageContext(ctx context.Context, stage StagedUpdate) error
- type ApplyAction
- type ApplyResult
- type Asset
- type Candidate
- type Client
- type Installer
- type Progress
- type ProgressFunc
- type StageKind
- type StagedUpdate
- type Target
Constants ¶
This section is empty.
Variables ¶
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") )
var ( ErrInstallRefused = errors.New("update installation refused") ErrPendingStageMismatch = errors.New("pending update belongs to another verified stage") )
var ErrInvalidStage = errors.New("invalid staged update")
Functions ¶
func CompareVersions ¶
CompareVersions compares two strict release versions (with optional leading v) and returns -1, 0, or 1. Development and prerelease strings are rejected.
func RecoverPendingApply ¶
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 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 ¶
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.
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.