installer

package
v0.0.97 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 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 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

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 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