installer

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 26 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 installer installs a verified release binary and owns the trust root, install-source detection, cache file permissions, and pending-update cleanup.

Index

Constants

View Source
const ReleaseSigningKeyID = "ed25519-2c27e77742d3c33a"

ReleaseSigningKeyID 是生产 Release 签名使用的受信 Ed25519 公钥 ID。

Variables

View Source
var ReleaseSigningPublicKey = [...]byte{
	0xee, 0xb2, 0xe2, 0xef, 0xdd, 0x60, 0xb0, 0x61,
	0x6c, 0x0f, 0x61, 0x2b, 0xef, 0x59, 0xe1, 0xe5,
	0x55, 0x40, 0x5f, 0xf8, 0xab, 0xc0, 0xdb, 0xeb,
	0x59, 0x5c, 0x09, 0xdb, 0x9a, 0x78, 0xb1, 0x44,
}

ReleaseSigningPublicKey 是生产 Release 签名使用的受信 Ed25519 公钥。

Functions

func CleanupPendingWindowsUpdate

func CleanupPendingWindowsUpdate() error

CleanupPendingWindowsUpdate 删除 ReplaceFileW 留下的旧可执行文件。非 Windows 不创建 该备份,因此没有任何文件操作;调用方应在启动 CLI 前调用并把失败展示给用户。

func NewFileReleaseCache

func NewFileReleaseCache(cacheDir, cachePath string) release.ReleaseCache

NewFileReleaseCache 建立 release 包的存储端口:以私密权限原子写入 cache 文件。 cachePath 是包含固定文件名的完整目标路径。

Types

type InstallSource

type InstallSource string

InstallSource 表示当前二进制可由哪个安装渠道更新。

const (
	InstallSourceDevelopment    InstallSource = "development"
	InstallSourceHomebrewStable InstallSource = "homebrew-stable"
	InstallSourceHomebrewBeta   InstallSource = "homebrew-beta"
	InstallSourceGoInstall      InstallSource = "go-install"
	InstallSourceRelease        InstallSource = "release"
)

func DetectInstallSource

func DetectInstallSource(info buildinfo.Info) (InstallSource, error)

DetectInstallSource 根据构建信息和当前可执行文件识别安装来源。

type ReleaseBinaryChecker

type ReleaseBinaryChecker interface {
	Check(context.Context, string, string) error
}

ReleaseBinaryChecker 在替换前验证下载二进制实际报告的版本。 实现必须只在 archive、checksum 和签名都已通过后调用二进制。

type ReleaseFileReplacer

type ReleaseFileReplacer interface {
	Replace(string, string) error
}

ReleaseFileReplacer 抽象最终的同目录原子替换,供受控测试和平台实现复用。

type ReleaseInstaller

type ReleaseInstaller interface {
	Install(context.Context, release.Release) error
}

ReleaseInstaller 安装已核验的 Release。

func NewReleaseInstaller

func NewReleaseInstaller(options ReleaseInstallerOptions) ReleaseInstaller

NewReleaseInstaller 建立 Release 自更新器。未配置 trusted key 时仍返回实例, 这样 --check 不受影响;真正安装会明确报出缺少信任根,而不是假装更新成功。

type ReleaseInstallerOptions

type ReleaseInstallerOptions struct {
	HTTPClient                 *http.Client
	TrustedKeys                map[string]ed25519.PublicKey
	ExecutablePath             func() (string, error)
	GOOS                       string
	GOARCH                     string
	BinaryChecker              ReleaseBinaryChecker
	Replacer                   ReleaseFileReplacer
	EnablePublicReleaseSources bool
}

ReleaseInstallerOptions 允许生产组装与受控测试分别注入信任根和系统依赖。 TrustedKeys 只允许 Ed25519 公钥;私钥绝不能进入生产组装或此 API。

type SourceDetector

type SourceDetector interface {
	Detect(buildinfo.Info) (InstallSource, error)
}

SourceDetector 识别当前可执行文件的安装渠道。

type SourceDetectorFunc

type SourceDetectorFunc func(buildinfo.Info) (InstallSource, error)

SourceDetectorFunc 让函数可以作为 SourceDetector 使用。

func (SourceDetectorFunc) Detect

Detect 调用底层函数。

Jump to

Keyboard shortcuts

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