selfupdate

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MPL-2.0 Imports: 34 Imported by: 0

Documentation

Overview

Package selfupdate installs a selected Hikyo release over the current binary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArchiveName

func ArchiveName(version, goos, goarch string) (string, error)

ArchiveName is the signed binary archive name for one release platform.

func CachedReleaseDirectory

func CachedReleaseDirectory(stateDir string, identity releaseidentity.Identity) string

CachedReleaseDirectory is where the verified cache under stateDir keeps one release.

func CheckExecutable

func CheckExecutable(authorize func(path string) error) error

CheckExecutable reports whether the running executable passes the same resolution and ownership checks as an update, plus authorize.

func CleanupPrevious

func CleanupPrevious() error

CleanupPrevious is a no-op where replacement is one atomic rename.

func StagesNightlies

func StagesNightlies() bool

StagesNightlies reports whether nightly updates only stage verified evidence. On Linux the CLI binary may be a systemd server's executable, which only `sudo hikyo upgrade` may replace after its backup and restore proof. Other platforms have no supported server host, so their CLI replaces itself.

Types

type Config

type Config struct {
	StateDir          string
	TrustRootBase64   string
	RecoveryKeyBase64 string
	// TransientBundles lets the host coordinator discard superseded private
	// bundles while resolving a route. Manual staging keeps published locators.
	TransientBundles bool
}

Config carries the trust material stamped into published artifacts. Direct source builds leave it empty because their default update channel is off.

type Installer

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

Installer downloads, validates, and atomically replaces one Hikyo binary.

func NewInstaller

func NewInstaller(config Config) (*Installer, error)

NewInstaller constructs the production updater with Hikyo's restricted release-download client.

func (*Installer) Apply

func (i *Installer) Apply(ctx context.Context, status updatecheck.Status) error

Apply replaces the resolved current executable with the selected release.

func (*Installer) AssembleNightlyRoute

func (i *Installer) AssembleNightlyRoute(ctx context.Context, target PreparedNightly, sources []PreparedNightly) (_ string, err error)

AssembleNightlyRoute combines exact prepared source/route releases with the target under the current authenticated snapshot. Every flat directory is independently reverified. It does not infer edges or authorize execution; the caller must ask the resulting runtime bundle to plan the actual DB source.

func (*Installer) AssembleReleaseRoute

func (i *Installer) AssembleReleaseRoute(ctx context.Context, target PreparedNightly, sources []PreparedNightly) (_ string, err error)

AssembleReleaseRoute verifies a mixed stable/nightly route without selecting or executing a target. Each identity must already be exact prepared evidence.

func (*Installer) CheckReplaceable

func (i *Installer) CheckReplaceable() error

CheckReplaceable reports whether this process can replace the running executable, before any update state or download is written.

func (*Installer) PrepareNightly

func (i *Installer) PrepareNightly(ctx context.Context, status updatecheck.Status) (PreparedNightly, error)

PrepareNightly authenticates a selected immutable nightly, assembles its runtime evidence and extracts this platform's binary without installing it. A target older than the highest observed nightly is refused.

func (*Installer) PrepareNightlySource

func (i *Installer) PrepareNightlySource(ctx context.Context, status updatecheck.Status, expected releaseidentity.Identity) (PreparedNightly, error)

PrepareNightlySource fetches an exact source or route-hop identity selected from authenticated compatibility evidence. Older evidence is allowed, but the durable highest observed nightly and snapshot floor never decrease. The caller must still prove a route before executing any prepared binary.

func (*Installer) PrepareRelease

func (i *Installer) PrepareRelease(ctx context.Context, status updatecheck.Status) (PreparedNightly, error)

PrepareRelease prepares the selected immutable release without installing it. Stable selection deliberately does not follow latest: container callers bind the returned proof and executable digest to their own running build.

func (*Installer) PrepareReleaseSource

func (i *Installer) PrepareReleaseSource(ctx context.Context, status updatecheck.Status, expected releaseidentity.Identity) (PreparedNightly, error)

PrepareReleaseSource permits historical evidence only for an exact identity already selected from authenticated compatibility declarations.

func (*Installer) PruneNightlyCache

func (i *Installer) PruneNightlyCache(ctx context.Context, keep ...releaseidentity.Identity) error

PruneNightlyCache removes verified release directories, assembled bundles, extracted executables and abandoned staging directories that no kept identity references. Every full release is several hundred MiB, and a route with intermediate hops multiplies that, so the cache is trimmed after each completed upgrade. The trust state and lock files are never touched: the state carries the rollback floor and the highest observed release.

func (*Installer) PruneNightlyScratch

func (i *Installer) PruneNightlyScratch(ctx context.Context) error

PruneNightlyScratch keeps all verified releases and executables while an unfinished journal may still require their exact bytes to resume. Derived private bundles can be rebuilt from those retained releases.

func (*Installer) ReplaceWithPrepared

func (i *Installer) ReplaceWithPrepared(ctx context.Context, prepared PreparedNightly, authorize func(path string) error) error

ReplaceWithPrepared replaces the running executable with the binary a PrepareRelease call extracted in this process. The digest recorded at extraction is rechecked against the file, so a descriptor loaded from disk must go through VerifyCachedRelease first.

func (*Installer) VerifyCachedRelease

func (i *Installer) VerifyCachedRelease(ctx context.Context, prepared PreparedNightly, floor releaseidentity.SnapshotFloor) (PreparedNightly, error)

VerifyCachedRelease reauthenticates an offline prepared release without discovery or network requests. The descriptor's executable path and digest are untrusted hints: both are replaced by extraction of the signed archive. The caller still binds the returned identity and payload to its running build and enforces the installation's durable migration/admission gate.

type PreparedNightly

type PreparedNightly struct {
	Identity        releaseidentity.Identity
	Directory       string
	BundleDirectory string
	BinaryPath      string
	BinarySHA256    releaseidentity.Digest
}

PreparedNightly is authenticated public evidence and a separately extracted executable. Preparation never replaces the installed executable or admits a database upgrade; the host controller and runtime gate perform those steps.

type StagedNightly

type StagedNightly struct {
	Directory       string
	BundleDirectory string
}

StagedNightly reports a verified manual-upgrade download on Linux, never replacement of the running executable: it may be a server's, and installing a server also requires its local gate, backup/drill evidence and complete runtime bundle. Other platforms replace the CLI instead (see StagesNightlies).

func (*StagedNightly) Error

func (s *StagedNightly) Error() string

Jump to

Keyboard shortcuts

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