Documentation
¶
Overview ¶
Package installer 安装已校验的 release 二进制,并持有签名信任根。
包的组成:ReleaseInstaller 与 ReleaseInstallerOptions 负责下载、校验和替换 可执行文件,SourceDetector 与 InstallSource 识别安装来源, NewFileReleaseCache 提供私有缓存;缓存权限与待处理更新清理也由本包负责。
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(cachePath string) release.ReleaseCache
NewFileReleaseCache 返回以私有权限原子替换的 release 元数据缓存。
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" )
InstallSourceDevelopment 等值是 InstallSource 的全部取值,对应本工具支持的安装渠道。
func DetectInstallSource ¶
func DetectInstallSource(info version.Info) (InstallSource, error)
DetectInstallSource 根据构建信息和当前可执行文件识别安装来源。
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
EnablePublicReleaseSources bool
}
ReleaseInstallerOptions 配置下载传输与信任根。 TrustedKeys 只允许 Ed25519 公钥;私钥绝不能进入生产组装或此 API。
type SourceDetector ¶
type SourceDetector interface {
Detect(version.Info) (InstallSource, error)
}
SourceDetector 识别当前可执行文件的安装渠道。
type SourceDetectorFunc ¶
type SourceDetectorFunc func(version.Info) (InstallSource, error)
SourceDetectorFunc 让函数可以作为 SourceDetector 使用。
func (SourceDetectorFunc) Detect ¶
func (f SourceDetectorFunc) Detect(info version.Info) (InstallSource, error)
Detect 调用底层函数。