Documentation
¶
Overview ¶
Package update implements the signed, fail-closed CodeSampleX binary updater. It deliberately uses only the Go standard library so the updater does not add another executable supply-chain dependency of its own.
Index ¶
- Constants
- Variables
- func AcknowledgeActivation(home, currentVersion string) error
- func AdoptStandalone(home, executable string) error
- func AutoEnabled(mode, policy string) bool
- func BootstrapLauncher(ctx context.Context, root, staged, legacy, currentVersion string) (launcher.Active, error)
- func CompareVersions(a, b string) (int, error)
- func EmbeddedPublicKey() (ed25519.PublicKey, error)
- func InstallPath(home string) string
- func IsCanonicalReleaseVersion(v string) bool
- func OwnsExecutable(home, executable string) (bool, error)
- func Rollback(home, executable string) (string, error)
- func SaveState(home string, st State) error
- func StableExecutable(home, executable string) (string, error)
- func StatePath(home string) string
- func WithLock(home string, fn func() error) error
- type Asset
- type Client
- type Envelope
- type Install
- type Manifest
- type Result
- type State
Constants ¶
const ( ManifestSchema = 1 DefaultChannel = "stable" DefaultManifestURL = "https://github.com/r2cuerdame/CodeSampleX/releases/latest/download/csx-update-stable.json" )
Variables ¶
var ErrPolicyDisabled = errors.New("update: automatic update policy was disabled")
var PublicKeyBase64 string
PublicKeyBase64 is stamped into release binaries from the protected release signing secret. Development builds intentionally have no update trust root.
Functions ¶
func AcknowledgeActivation ¶
AcknowledgeActivation clears a restart notice only from a newly launched binary that matches the installed target (or the first process after a rollback). It never removes the preserved previous executable.
func AdoptStandalone ¶
func AutoEnabled ¶
func BootstrapLauncher ¶
func BootstrapLauncher(ctx context.Context, root, staged, legacy, currentVersion string) (launcher.Active, error)
BootstrapLauncher is the one-time Windows installer bridge. It verifies the signed stable manifest with the key embedded in the payload, then lets the shared launcher commit code durably promote that running staged payload.
func CompareVersions ¶
CompareVersions compares strict numeric release versions, ignoring one leading v. It rejects ranges, aliases, and prerelease text.
func EmbeddedPublicKey ¶
func InstallPath ¶
func OwnsExecutable ¶
func StableExecutable ¶
Types ¶
type Asset ¶
type Asset struct {
OS string `json:"os"`
Arch string `json:"arch"`
URL string `json:"url"`
Size int64 `json:"size"`
SHA256 string `json:"sha256"`
MinLauncherVersion string `json:"minLauncherVersion,omitempty"`
}
func CurrentAsset ¶
type Client ¶
type Client struct {
Home string
CurrentVersion string
Executable string
ManifestURL string
Channel string
PublicKey ed25519.PublicKey
HTTP *http.Client
Now func() time.Time
SelfTest func(context.Context, string, string) error
Replace func(string, string, string) error
ValidateTarget func(string) error
SyncDir func(string) error
LoadState func(string) (State, error)
SaveState func(string, State) error
CheckApplySupport func() error
Preflight func() error
Automatic bool
// contains filtered or unexported fields
}
type Install ¶
type Install struct {
Schema int `json:"schema"`
Kind string `json:"kind"`
ExecutablePath string `json:"executablePath"`
InstallRoot string `json:"installRoot,omitempty"`
LauncherPath string `json:"launcherPath,omitempty"`
}
func LoadInstall ¶
func ResolveInstall ¶
ResolveInstall uses the per-profile marker when present, then falls back to the stable launcher's verified environment. The latter is install-scoped, so a second CSX_HOME/profile still resolves the same trusted launcher.
type Manifest ¶
type Manifest struct {
Schema int `json:"schema"`
Channel string `json:"channel"`
Sequence uint64 `json:"sequence"`
Version string `json:"version"`
PublishedAt time.Time `json:"publishedAt"`
ExpiresAt time.Time `json:"expiresAt"`
MinUpdaterVersion string `json:"minUpdaterVersion,omitempty"`
Assets []Asset `json:"assets"`
}
type State ¶
type State struct {
Schema int `json:"schema"`
HighestSequence uint64 `json:"highestSequence,omitempty"`
HighestVersion string `json:"highestVersion,omitempty"`
LastCheck time.Time `json:"lastCheck,omitempty"`
NextCheck time.Time `json:"nextCheck,omitempty"`
ConsecutiveFailures int `json:"consecutiveFailures,omitempty"`
PendingRestart string `json:"pendingRestart,omitempty"`
PreviousPath string `json:"previousPath,omitempty"`
LastError string `json:"lastError,omitempty"`
}