installer

package
v0.0.100 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 27 Imported by: 4

Documentation

Overview

Package installer is the core part of the software package installation.

Index

Constants

View Source
const (
	// ConfigGitHub is the default git repository URI
	ConfigGitHub = "https://github.com/LinuxSuRen/hd-home"
	// ConfigBranch is the default branch name of hd-home git repository
	ConfigBranch = "master"
)
View Source
const (
	// ProviderGitHub represents https://github.com
	ProviderGitHub = "github"
)

Variables

This section is empty.

Functions

func FindByKeyword added in v0.0.56

func FindByKeyword(keyword, configDir string) (result []string)

FindByKeyword find org/repo by a keyword

func FindCategories added in v0.0.54

func FindCategories() (result []string)

FindCategories returns the whole supported categories

func GetInstalledFile added in v0.0.100

func GetInstalledFile() (path string, err error)

GetInstalledFile returns the path of the installed tools record file

func GetProxyServers added in v0.0.92

func GetProxyServers() []string

GetProxyServers returns the proxy servers

func IsSupport

func IsSupport(cfg HDConfig) bool

IsSupport checks if support

func RecordInstalledPackage added in v0.0.100

func RecordInstalledPackage(tool InstalledPackage) (err error)

RecordInstalledPackage adds or updates a tool in the record file

func SaveInstalledPackages added in v0.0.100

func SaveInstalledPackages(tools []InstalledPackage) (err error)

SaveInstalledPackages saves the installed tools into the record file

Types

type CmdWithArgs

type CmdWithArgs struct {
	Cmd  string   `yaml:"cmd"`
	Args []string `yaml:"args"`
}

CmdWithArgs is a command with arguments

type ConfigFile added in v0.0.61

type ConfigFile struct {
	OS      string `yaml:"os"`
	Path    string `yaml:"path"`
	Content string `yaml:"content"`
}

ConfigFile represents a config file

type DefaultFetcher added in v0.0.56

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

DefaultFetcher is the default fetcher which fetches the config files from a git repository

func (*DefaultFetcher) FetchLatestRepo added in v0.0.56

func (f *DefaultFetcher) FetchLatestRepo(provider string, branch string,
	progress io.Writer) (err error)

FetchLatestRepo fetches the hd-home as the config

func (*DefaultFetcher) GetConfigDir added in v0.0.56

func (f *DefaultFetcher) GetConfigDir() (configDir string, err error)

GetConfigDir returns the directory of the config

func (*DefaultFetcher) GetHomeDir added in v0.0.85

func (f *DefaultFetcher) GetHomeDir() (homeDir string, err error)

GetHomeDir returns the user home directory

func (*DefaultFetcher) SetContext added in v0.0.73

func (f *DefaultFetcher) SetContext(ctx context.Context)

SetContext sets the context of the fetch

type FakeFetcher added in v0.0.56

type FakeFetcher struct {
	ConfigDir          string
	HomeDir            string
	GetConfigDirErr    error
	FetchLatestRepoErr error
}

FakeFetcher is a fake fetch. We expect to use it for unit test cases.

func (*FakeFetcher) FetchLatestRepo added in v0.0.56

func (f *FakeFetcher) FetchLatestRepo(provider string, branch string,
	progress io.Writer) (err error)

FetchLatestRepo is a fake method

func (*FakeFetcher) GetConfigDir added in v0.0.56

func (f *FakeFetcher) GetConfigDir() (configDir string, err error)

GetConfigDir is a fake method

func (*FakeFetcher) GetHomeDir added in v0.0.85

func (f *FakeFetcher) GetHomeDir() (HomeDir string, err error)

GetHomeDir is a fake method

func (*FakeFetcher) SetContext added in v0.0.73

func (f *FakeFetcher) SetContext(ctx context.Context)

SetContext is a fake method

type Fetcher added in v0.0.56

type Fetcher interface {
	GetConfigDir() (configDir string, err error)
	GetHomeDir() (homeDir string, err error)
	FetchLatestRepo(provider string, branch string,
		progress io.Writer) (err error)
	SetContext(ctx context.Context)
}

Fetcher is the interface of a fetcher which responses to fetch config files

type HDConfig

type HDConfig struct {
	Name              string            `yaml:"name"`
	Categories        []string          `yaml:"categories"`
	Filename          string            `yaml:"filename"`
	FormatOverrides   PackagingFormat   `yaml:"formatOverrides"`
	Binary            string            `yaml:"binary"`
	TargetBinary      string            `yaml:"targetBinary"`
	TargetDirectory   string            `yaml:"targetDirectory"`
	AdditionBinaries  []string          `yaml:"additionBinaries"`
	FromSource        bool              `yaml:"fromSource"`
	URL               string            `yaml:"url"`
	Tar               string            `yaml:"tar"`
	LatestVersion     string            `yaml:"latestVersion"`
	SupportOS         []string          `yaml:"supportOS"`
	SupportArch       []string          `yaml:"supportArch"`
	Replacements      map[string]string `yaml:"replacements"`
	Requirements      []string          `yaml:"requirements"`
	Installation      *CmdWithArgs      `yaml:"installation"`
	DefaultConfigFile []ConfigFile      `yaml:"defaultConfigFiles"`
	PreInstalls       []CmdWithArgs     `yaml:"preInstalls"`
	PostInstalls      []CmdWithArgs     `yaml:"postInstalls"`
	TestInstalls      []CmdWithArgs     `yaml:"testInstalls"`
	Version           string            `yaml:"version"`
	VersionCmd        string            `yaml:"versionCmd"`

	Org, Repo string
}

HDConfig is the config of http-downloader

func FindPackagesByCategory added in v0.0.53

func FindPackagesByCategory(category string) (result []HDConfig)

FindPackagesByCategory returns the HDConfigs by category

type HDPackage

type HDPackage struct {
	Name             string
	Version          string // e.g. v1.0.1
	VersionNum       string // e.g. 1.0.1
	OS               string // e.g. linux, darwin
	Arch             string // e.g. amd64
	AdditionBinaries []string
}

HDPackage represents a package of http-downloader

type InstalledPackage added in v0.0.100

type InstalledPackage struct {
	Name            string   `yaml:"name" json:"name"`
	Org             string   `yaml:"org,omitempty" json:"org,omitempty"`
	Repo            string   `yaml:"repo,omitempty" json:"repo,omitempty"`
	Version         string   `yaml:"version,omitempty" json:"version,omitempty"`
	Binaries        []string `yaml:"binaries,omitempty" json:"binaries,omitempty"`
	TargetDirectory string   `yaml:"targetDirectory,omitempty" json:"targetDirectory,omitempty"`
	InstalledAt     string   `yaml:"installedAt,omitempty" json:"installedAt,omitempty"`
	FromSource      bool     `yaml:"fromSource,omitempty" json:"fromSource,omitempty"`
	Native          bool     `yaml:"native,omitempty" json:"native,omitempty"`
}

InstalledPackage represents a tool which is installed by hd

func FindInstalledPackage added in v0.0.100

func FindInstalledPackage(name string) (target *InstalledPackage, index int)

FindInstalledPackage finds an installed tool by its name

func LoadInstalledPackages added in v0.0.100

func LoadInstalledPackages() (tools []InstalledPackage, err error)

LoadInstalledPackages loads all the installed tools from the record file

func RemoveInstalledPackage added in v0.0.100

func RemoveInstalledPackage(name string) (removed *InstalledPackage, err error)

RemoveInstalledPackage removes a tool from the record file by its name

type Installer

type Installer struct {
	Package          *HDConfig
	Tar              bool
	Output           string
	TargetDirectory  string
	Source           string
	Name             string
	CleanPackage     bool
	Provider         string
	OS               string
	Arch             string
	Fetch            bool
	AdditionBinaries []string

	Org         string
	Repo        string
	ProxyGitHub string

	Execer fakeruntime.Execer
}

Installer is a tool to install a package

func (*Installer) CheckDepAndInstall

func (o *Installer) CheckDepAndInstall(tools map[string]string) (err error)

CheckDepAndInstall checks the desired tools, install the missing packages

func (*Installer) GetVersion added in v0.0.40

func (o *Installer) GetVersion(path string) (version string, err error)

GetVersion parse install app info

func (*Installer) Install

func (o *Installer) Install() (err error)

Install installs a package

func (*Installer) OverWriteBinary added in v0.0.34

func (o *Installer) OverWriteBinary(sourceFile, targetPath string) (err error)

OverWriteBinary install a binary file

func (*Installer) ProviderURLParse

func (o *Installer) ProviderURLParse(path string, acceptPreRelease bool) (packageURL string, err error)

ProviderURLParse parse the URL

type PackagingFormat added in v0.0.43

type PackagingFormat struct {
	Windows string `yaml:"windows"`
	Linux   string `yaml:"linux"`
	Format  string
}

PackagingFormat is used for containing config depending on machine

func (PackagingFormat) String added in v0.0.84

func (f PackagingFormat) String() string

String returns a pretty string

Jump to

Keyboard shortcuts

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