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 ¶
const ReleaseSigningKeyID = "ed25519-2c27e77742d3c33a"
ReleaseSigningKeyID 是生产 Release 签名使用的受信 Ed25519 公钥 ID。
Variables ¶
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 ¶
ReleaseBinaryChecker 在替换前验证下载二进制实际报告的版本。 实现必须只在 archive、checksum 和签名都已通过后调用二进制。
type ReleaseFileReplacer ¶
ReleaseFileReplacer 抽象最终的同目录原子替换,供受控测试和平台实现复用。
type ReleaseInstaller ¶
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 ¶
func (f SourceDetectorFunc) Detect(info buildinfo.Info) (InstallSource, error)
Detect 调用底层函数。