installer

package
Version: v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ZIP_INFO_FILENAME = "pkg.info"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultStrategy added in v0.0.2

type DefaultStrategy struct{}

func NewStrategy added in v0.0.2

func NewStrategy() *DefaultStrategy

func (*DefaultStrategy) GenInstallPath added in v0.0.2

func (s *DefaultStrategy) GenInstallPath(dir string, pkgInfo PackageInfo) (string, error)

type Installer

type Installer interface {
	// 读取安装包信息
	// Param: path安装包路径,请使用绝对路径
	// Return: Package安装包信息, error 读取错误
	ReadInfo(path string) (PackageInfo, error)

	// 安装
	// Param: path安装包路径,请使用绝对路径
	// Return: Package安装信息, error 安装错误
	Install(path string, strategy Strategy) (Package, error)

	// 卸载
	// Param: pkg安装包信息,delPkg是否同时删除安装包
	// Return: error 卸载错误
	Uninstall(pkg Package, delPkg bool) error
}

type JsonRecorder added in v0.0.3

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

func CreateJsonRecorder added in v0.0.3

func CreateJsonRecorder(path string) (*JsonRecorder, error)

func (*JsonRecorder) GetPackage added in v0.0.3

func (r *JsonRecorder) GetPackage(name string) []Package

func (*JsonRecorder) ListPackage added in v0.0.3

func (r *JsonRecorder) ListPackage() []Package

func (*JsonRecorder) Remove added in v0.0.3

func (r *JsonRecorder) Remove(pkg Package) error

func (*JsonRecorder) Save added in v0.0.3

func (r *JsonRecorder) Save(pkg Package) error

type Package

type Package interface {
	// 获得安装包名称
	GetName() string

	// 获得安装包版本号
	GetVersion() int

	// 获得安装包信息
	GetInfo() string

	// 获得安装路径
	GetInstallPath() string

	// 卸载已安装应用文件,delPkg为true则将同时删除安装包
	Uninstall(delPkg bool) error

	// 判断两个Package是否相同
	Equal(other Package) bool
}

type PackageInfo

type PackageInfo interface {
	// 获得安装包名称
	GetName() string

	// 获得安装包版本号
	GetVersion() int

	// 获得安装包描述
	GetDescription() string
}

type Recorder

type Recorder interface {
	// 保存安装包信息
	Save(pkg Package) error
	// 删除安装包信息
	Remove(pkg Package) error

	// 列出所有已安装应用
	ListPackage() []Package
	// 根据名称获得安装信息
	GetPackage(name string) []Package
}

type Strategy added in v0.0.2

type Strategy interface {
	// 生成安装包安装路径
	GenInstallPath(dir string, pkgInfo PackageInfo) (string, error)
}

type ZipInstaller

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

func CreateInstaller

func CreateInstaller(installDir string) (*ZipInstaller, error)

func (*ZipInstaller) Install

func (inst *ZipInstaller) Install(path string, strategy Strategy) (Package, error)

func (*ZipInstaller) ReadInfo

func (inst *ZipInstaller) ReadInfo(path string) (PackageInfo, error)

func (*ZipInstaller) Uninstall

func (inst *ZipInstaller) Uninstall(pkg Package, del bool) error

type ZipPackage

type ZipPackage struct {
	Name    string `json:"name" yaml:"name"`
	Version int    `json:"version" yaml:"version"`
	Info    string `json:"info" yaml:"info"`

	PkgPath     string `json:"pkgPath" yaml:"pkgPath"`
	InstallPath string `json:"installPath" yaml:"installPath"`
}

func (*ZipPackage) Equal added in v0.0.3

func (pkg *ZipPackage) Equal(other Package) bool

func (*ZipPackage) GetInfo

func (pkg *ZipPackage) GetInfo() string

func (*ZipPackage) GetInstallPath

func (pkg *ZipPackage) GetInstallPath() string

func (*ZipPackage) GetName

func (pkg *ZipPackage) GetName() string

func (*ZipPackage) GetVersion

func (pkg *ZipPackage) GetVersion() int

func (*ZipPackage) Uninstall

func (pkg *ZipPackage) Uninstall(delPkg bool) (err error)

type ZipPackageInfo

type ZipPackageInfo struct {
	ProtocolVersion int    `json:"protocolVersion" yaml:"protocolVersion"`
	AppVersion      int    `json:"appVersion" yaml:"appVersion"`
	Name            string `json:"name" yaml:"name"`
	ExecCmd         string `json:"execCmd" yaml:"execCmd"`
	Info            string `json:"info" yaml:"info"`
	Description     string `json:"description" yaml:"description"`
	ExecName        string `json:"execName" yaml:"execName"`
	Checksum        string `json:"checksum" yaml:"checksum"`
}

func (*ZipPackageInfo) GetDescription

func (r *ZipPackageInfo) GetDescription() string

获得安装包描述

func (*ZipPackageInfo) GetName

func (r *ZipPackageInfo) GetName() string

func (*ZipPackageInfo) GetVersion

func (r *ZipPackageInfo) GetVersion() int

获得安装包版本号

type ZipRecorder

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

func CreateRecorder

func CreateRecorder(path string) (*ZipRecorder, error)

func (*ZipRecorder) GetPackage

func (r *ZipRecorder) GetPackage(name string) []Package

func (*ZipRecorder) ListPackage

func (r *ZipRecorder) ListPackage() []Package

func (*ZipRecorder) Remove

func (r *ZipRecorder) Remove(pkg Package) error

func (*ZipRecorder) Save

func (r *ZipRecorder) Save(pkg Package) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL