install

package
v1.7.8 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperationInstall      = "install"
	OperationUpdate       = "update"
	InstallModePortable   = "portable"
	InstallModeInstaller  = "installer"
	InstallModeRunAsset   = "run-asset"
	InstallActionRunAsset = "run-asset"
)

Variables

This section is empty.

Functions

func APICacheFilePath added in v1.5.1

func APICacheFilePath(cacheDir, rawURL string) string

func CacheFilePath

func CacheFilePath(cacheDir, url string) string

func CacheFilePathWithMeta added in v1.6.0

func CacheFilePathWithMeta(cacheDir, url string, meta CacheMeta) string

func Cast

func Cast[T any](value any) (T, error)

func ClientOptions added in v1.5.2

func ClientOptions(opts Options) client.Options

func DetectGUIInstallMode added in v1.5.2

func DetectGUIInstallMode(isGUI bool, fileName string) string

func Download

func Download(url string, out io.Writer, getbar func(size int64) io.Writer, opts Options) error

func DownloadFile added in v1.7.0

func DownloadFile(url, target string, getbar func(size int64) io.Writer, opts Options) (client.DownloadFileResult, error)

func Get

func Get(url string, disableSSL bool) (*http.Response, error)

func GetWithOptions

func GetWithOptions(url string, opts Options) (*http.Response, error)

func IsGitHubURL

func IsGitHubURL(s string) bool

func IsLocalFile

func IsLocalFile(s string) bool

func IsURL

func IsURL(s string) bool

func NewDownloadProgress added in v1.7.1

func NewDownloadProgress(out io.Writer, size int64) *progress.Progress

func NormalizeRepoTarget

func NormalizeRepoTarget(target string) (string, error)

func ProbeLastModified added in v1.7.2

func ProbeLastModified(url string, opts Options) string

func SelectExtractorAs

func SelectExtractorAs[T any](s *Service, url, tool string, opts *Options) (T, error)

func SetAPICacheNoticeWriter added in v1.6.1

func SetAPICacheNoticeWriter(writer io.Writer) io.Writer

func SetProxyNoticeWriter added in v1.6.1

func SetProxyNoticeWriter(writer io.Writer) io.Writer

func SetVerbose

func SetVerbose(enabled bool, writer io.Writer)

func TargetKindDisplayName added in v1.7.2

func TargetKindDisplayName(kind TargetKind) string

func VerboseEnabledForTest

func VerboseEnabledForTest() bool

Types

type Archive

type Archive interface {
	Next() (File, error)
	ReadAll() ([]byte, error)
}

func NewSevenZipArchive added in v1.5.1

func NewSevenZipArchive(data []byte, d DecompFn) (Archive, error)

func NewTarArchive

func NewTarArchive(data []byte, decompress DecompFn) (Archive, error)

func NewZipArchive

func NewZipArchive(data []byte, d DecompFn) (Archive, error)

type ArchiveExtractOptions added in v1.7.0

type ArchiveExtractOptions struct {
	StripComponents int
}

type ArchiveExtractor

type ArchiveExtractor struct {
	File       Chooser
	Ar         ArchiveFn
	Decompress DecompFn
}

func NewArchiveExtractor

func NewArchiveExtractor(file Chooser, ar ArchiveFn, decompress DecompFn) *ArchiveExtractor

func (*ArchiveExtractor) Extract

func (a *ArchiveExtractor) Extract(data []byte, multiple bool) (ExtractedFile, []ExtractedFile, error)

func (*ArchiveExtractor) ExtractAllTo added in v1.6.1

func (a *ArchiveExtractor) ExtractAllTo(data []byte, output string) ([]string, error)

func (*ArchiveExtractor) ExtractAllToWithOptions added in v1.7.0

func (a *ArchiveExtractor) ExtractAllToWithOptions(data []byte, output string, opts ArchiveExtractOptions) ([]string, error)

type ArchiveFn

type ArchiveFn func(data []byte, decomp DecompFn) (Archive, error)

type BinaryChooser

type BinaryChooser struct {
	Tool string
}

func NewBinaryChooser

func NewBinaryChooser(tool string) *BinaryChooser

func (*BinaryChooser) Choose

func (b *BinaryChooser) Choose(name string, dir bool, mode fs.FileMode) (bool, bool)

func (*BinaryChooser) String

func (b *BinaryChooser) String() string

type CacheMeta added in v1.6.0

type CacheMeta = client.CacheMeta

type Chooser

type Chooser interface {
	Choose(name string, dir bool, mode fs.FileMode) (direct bool, possible bool)
}

func NewFileChooser added in v1.5.1

func NewFileChooser(expr string) (Chooser, error)

type ConfirmFunc added in v1.5.2

type ConfirmFunc func(file string) (bool, error)

type DecompFn

type DecompFn func(r io.Reader) (io.Reader, error)

type DefaultInstallerLauncher added in v1.5.2

type DefaultInstallerLauncher struct {
	GOOS string
}

func (DefaultInstallerLauncher) LaunchInstaller added in v1.5.2

func (l DefaultInstallerLauncher) LaunchInstaller(path string, kind InstallerKind) error

type Detector

type Detector = detect.Detector

type DirectAllExtractor added in v1.6.1

type DirectAllExtractor interface {
	ExtractAllTo(data []byte, output string) ([]string, error)
}

type DirectAssetFinder

type DirectAssetFinder struct {
	URL string
}

func (*DirectAssetFinder) Find

func (f *DirectAssetFinder) Find() ([]string, error)

type DownloadResult added in v1.7.3

type DownloadResult = client.DownloadResult

func DownloadWithResult added in v1.7.3

func DownloadWithResult(url string, out io.Writer, getbar func(size int64) io.Writer, opts Options) (DownloadResult, error)

type ExtractedFile

type ExtractedFile struct {
	Name        string
	ArchiveName string

	Extract func(to string) error
	Dir     bool
	// contains filtered or unexported fields
}

func (ExtractedFile) Mode

func (e ExtractedFile) Mode() fs.FileMode

func (ExtractedFile) String

func (e ExtractedFile) String() string

type Extractor

type Extractor interface {
	Extract(data []byte, multiple bool) (ExtractedFile, []ExtractedFile, error)
}

func NewExtractor

func NewExtractor(filename string, tool string, chooser Chooser) Extractor

type File

type File struct {
	Name     string
	LinkName string
	Mode     fs.FileMode
	ModTime  time.Time
	Type     FileType
}

func (File) Dir

func (f File) Dir() bool

type FileType

type FileType byte
const (
	TypeNormal FileType = iota
	TypeDir
	TypeLink
	TypeSymlink
	TypeOther
)

type FilterChooser added in v1.7.2

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

func (*FilterChooser) Choose added in v1.7.2

func (f *FilterChooser) Choose(name string, dir bool, mode fs.FileMode) (bool, bool)

func (*FilterChooser) String added in v1.7.2

func (f *FilterChooser) String() string

type Finder

type Finder interface {
	Find() ([]string, error)
}

type GlobChooser

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

func NewGlobChooser

func NewGlobChooser(gl string) (*GlobChooser, error)

func (*GlobChooser) Choose

func (g *GlobChooser) Choose(name string, dir bool, mode fs.FileMode) (bool, bool)

func (*GlobChooser) String

func (g *GlobChooser) String() string

type HTTPGetterFunc

type HTTPGetterFunc func(url string) (*http.Response, error)

func NewHTTPGetter

func NewHTTPGetter(opts Options) HTTPGetterFunc

func (HTTPGetterFunc) Get

func (f HTTPGetterFunc) Get(url string) (*http.Response, error)

type InstallRunner

type InstallRunner struct {
	Service                *Service
	InstalledLoad          func() (map[string]string, map[string]string, error)
	Prompt                 PromptFunc
	ConfirmLaunchInstaller ConfirmFunc
	InstallerLauncher      InstallerLauncher
	AssetRunner            func(path string, args []string, stdout, stderr io.Writer) error
	Stdout                 io.Writer
	Stderr                 io.Writer
}

func NewRunner

func NewRunner(service *Service) *InstallRunner

func (*InstallRunner) Run

func (r *InstallRunner) Run(target string, opts Options) (RunResult, error)

type InstallerKind added in v1.5.2

type InstallerKind string
const (
	InstallerKindUnknown InstallerKind = ""
	InstallerKindMSI     InstallerKind = "msi"
	InstallerKindEXE     InstallerKind = "exe"
)

func DetectInstallerKind added in v1.5.2

func DetectInstallerKind(fileName string) InstallerKind

type InstallerLauncher added in v1.5.2

type InstallerLauncher interface {
	LaunchInstaller(path string, kind InstallerKind) error
}

type LiteralFileChooser

type LiteralFileChooser struct {
	File string
}

func (*LiteralFileChooser) Choose

func (l *LiteralFileChooser) Choose(name string, dir bool, mode fs.FileMode) (bool, bool)

func (*LiteralFileChooser) String

func (l *LiteralFileChooser) String() string

type MultiChooser added in v1.5.1

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

func (*MultiChooser) Choose added in v1.5.1

func (m *MultiChooser) Choose(name string, dir bool, mode fs.FileMode) (bool, bool)

func (*MultiChooser) String added in v1.5.1

func (m *MultiChooser) String() string

type Options

type Options struct {
	Tag                 string
	Prerelease          bool
	Operation           string
	CurrentVersion      string
	TargetVersion       string
	Name                string
	Verbose             bool
	Source              bool
	SourcePath          string
	Sys7zPath           string
	Output              string
	OutputExplicit      bool
	GuiTarget           string
	IsGUI               bool
	InstallMode         string
	CacheDir            string
	CacheName           string
	CacheVersion        string
	ProxyURL            string
	ProxyExclude        []string
	NoProxy             bool
	UserAgent           string
	APICacheEnabled     bool
	APICacheDir         string
	APICacheTime        int
	CacheMirror         cachemirror.Options
	GhproxyEnabled      bool
	GhproxyHostURL      string
	GhproxySupportAPI   bool
	GhproxyFallbacks    []string
	System              string
	ExtractFile         string
	All                 bool
	StripComponents     int
	Quiet               bool
	DownloadOnly        bool
	FallbackVersions    int
	ChunkConcurrency    int
	BatchConcurrency    int
	ChunkConcurrencySet bool
	BatchConcurrencySet bool
	UpgradeOnly         bool
	Asset               []string
	RenameFiles         map[string]string
	Hash                bool
	Verify              string
	URLTemplate         URLTemplateOptions
	DisableSSL          bool
}

type PromptFunc

type PromptFunc func(title, filterPrompt string, choices []string) (int, error)

type RateLimit

type RateLimit = client.RateLimit

func GetRateLimit

func GetRateLimit(opts Options) (RateLimit, error)

type RunResult

type RunResult struct {
	URL            string
	Tool           string
	Asset          string
	ExtractedFiles []string
	IsGUI          bool
	InstallMode    string
	InstallerFile  string
	Version        string
}

type Runner

type Runner interface {
	Run(target string, opts Options) (RunResult, error)
}

type Service

type Service struct {
	BinaryModTime            func(tool, output string) time.Time
	GitHubGetter             sourcegithub.HTTPGetter
	GitHubGetterFactory      func(opts Options) sourcegithub.HTTPGetter
	ForgeGetterFactory       func(opts Options) forge.HTTPGetter
	SourceForgeGetterFactory func(opts Options) sourcesf.HTTPGetter
	TemplateGetterFactory    func(opts Options) urltemplate.HTTPGetter

	AllDetectorFactory    func() Detector
	SystemDetectorFactory func(goos, goarch string) (Detector, error)
	AssetDetectorFactory  func(asset string, anti bool, re *regexp.Regexp) Detector
	DetectorChainFactory  func(detectors []Detector, system Detector) Detector

	Sha256VerifierFactory      func(expected string) (Verifier, error)
	Sha256AssetVerifierFactory func(assetURL string, opts Options) Verifier
	Sha256PrinterFactory       func() Verifier
	NoVerifierFactory          func() Verifier

	DownloadOnlyExtractorFactory func(name string) any
	GlobChooserFactory           func(pattern string) (any, error)
	BinaryChooserFactory         func(tool string) any
	ExtractorFactory             func(filename, tool string, chooser any) any
	System7zPathResolver         func(configured string) string
	System7zExtractorFactory     func(filename, tool string, chooser Chooser, exe string) Extractor
}

func NewDefaultService

func NewDefaultService(githubGetter sourcegithub.HTTPGetter, binaryModTime func(tool, output string) time.Time) *Service

func NewService

func NewService() *Service

func (*Service) SelectDetector

func (s *Service) SelectDetector(opts *Options) (Detector, error)

func (*Service) SelectExtractor

func (s *Service) SelectExtractor(url, tool string, opts *Options) (any, error)

func (*Service) SelectFinder

func (s *Service) SelectFinder(target string, opts *Options) (Finder, string, error)

func (*Service) SelectVerifier

func (s *Service) SelectVerifier(sumAsset string, opts *Options) (Verifier, error)

type SevenZipArchive added in v1.5.1

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

func (*SevenZipArchive) Next added in v1.5.1

func (z *SevenZipArchive) Next() (File, error)

func (*SevenZipArchive) ReadAll added in v1.5.1

func (z *SevenZipArchive) ReadAll() ([]byte, error)

func (*SevenZipArchive) WriteTo added in v1.6.1

func (z *SevenZipArchive) WriteTo(w io.Writer) (int64, error)

type SingleFileExtractor

type SingleFileExtractor struct {
	Rename     string
	Name       string
	Decompress func(r io.Reader) (io.Reader, error)
}

func NewDownloadOnlyExtractor

func NewDownloadOnlyExtractor(name string) *SingleFileExtractor

func (*SingleFileExtractor) Extract

func (s *SingleFileExtractor) Extract(data []byte, multiple bool) (ExtractedFile, []ExtractedFile, error)

type System7zExtractor added in v1.6.1

type System7zExtractor struct {
	Filename string
	Tool     string
	Chooser  Chooser
	Exe      string
}

func NewSystem7zExtractor added in v1.6.1

func NewSystem7zExtractor(filename, tool string, chooser Chooser, exe string) *System7zExtractor

func (*System7zExtractor) Extract added in v1.6.1

func (e *System7zExtractor) Extract(data []byte, multiple bool) (ExtractedFile, []ExtractedFile, error)

func (*System7zExtractor) ExtractAllTo added in v1.6.1

func (e *System7zExtractor) ExtractAllTo(data []byte, output string) ([]string, error)

func (*System7zExtractor) ExtractAllToWithOptions added in v1.7.0

func (e *System7zExtractor) ExtractAllToWithOptions(data []byte, output string, opts ArchiveExtractOptions) ([]string, error)

type TarArchive

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

func (*TarArchive) Next

func (t *TarArchive) Next() (File, error)

func (*TarArchive) ReadAll

func (t *TarArchive) ReadAll() ([]byte, error)

func (*TarArchive) WriteTo added in v1.6.1

func (t *TarArchive) WriteTo(w io.Writer) (int64, error)

type TargetKind

type TargetKind string
const (
	TargetUnknown     TargetKind = "unknown"
	TargetRepo        TargetKind = "repo"
	TargetGitHubURL   TargetKind = "github_url"
	TargetDirectURL   TargetKind = "direct_url"
	TargetLocalFile   TargetKind = "local_file"
	TargetSourceForge TargetKind = "sourceforge"
	TargetForge       TargetKind = "forge"
	TargetTemplate    TargetKind = "template"
)

func DetectTargetKind

func DetectTargetKind(target string) TargetKind

type URLTemplateOptions added in v1.7.0

type URLTemplateOptions struct {
	URLTemplate         string
	LatestURL           string
	LatestFormat        string
	LatestJSONPath      string
	VersionRegex        string
	OSMap               map[string]string
	ArchMap             map[string]string
	ExtMap              map[string]string
	LibcMap             map[string]string
	ChecksumURLTemplate string
	ChecksumFormat      string
	ChecksumJSONPath    string
	ChecksumRegex       string
	InstallAction       string
	InstallArgs         []string
	ResolvedVersion     string
	ResolvedVars        map[string]string
}

type Verifier

type Verifier interface {
	Verify(b []byte) error
}

type VersionFallbackFinder added in v1.5.5

type VersionFallbackFinder interface {
	FallbackVersionAssets(limit int) ([][]string, error)
}

type ZipArchive

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

func (*ZipArchive) Next

func (z *ZipArchive) Next() (File, error)

func (*ZipArchive) ReadAll

func (z *ZipArchive) ReadAll() ([]byte, error)

func (*ZipArchive) WriteTo added in v1.6.1

func (z *ZipArchive) WriteTo(w io.Writer) (int64, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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