multiwerf

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLocalChannelMappingFilename = "multiwerf.json"
View Source
const SelfUpdateLockName = "self-update"

Variables

View Source
var (
	StorageDir string
	TmpDir     string
)

Functions

func CalculateSHA256

func CalculateSHA256(filePath string) (string, error)

CalculateSHA256 returns SHA256 hash of filePath content

func CheckIsFileWritable

func CheckIsFileWritable(path string) error

func CheckMajorMinor

func CheckMajorMinor(version string) error

CheckMajorMinor return error if string not in form MAJOR.MINOR

func DirExists added in v1.0.6

func DirExists(path string) (bool, error)

func ExecUpdatedBinary

func ExecUpdatedBinary(path string) error

ExecUpdatedBinary replaces current process with process from path binary --self-update=no flag is added to arguments to prevent an infinity loop.

func ExpandPath added in v1.0.8

func ExpandPath(path string) (resPath string, err error)

ExpandPath expands tilde prefix and returns an absolute path

func FileExists

func FileExists(path string) (bool, error)

FileExists returns true if path exists

func GetSelfExecutableInfo

func GetSelfExecutableInfo() (path string, err error)

GetSelfExecutableInfo return path of an executable file of current process. If file is not owned by user of the process and has no 0x400 bit — return error

func HighestSemverVersion added in v1.1.0

func HighestSemverVersion(versions []string) (string, error)

HighestSemverVersion returns the latest version from availableVersions array

func IsNotADirectoryError added in v1.2.0

func IsNotADirectoryError(err error) bool

func IsReleaseFilesExist added in v1.0.15

func IsReleaseFilesExist(dir string, files map[string]string) (bool, error)

func LoadHashFile

func LoadHashFile(dir string, fileName string) (hashes map[string]string)

LoadHashFile opens a file and returns hashes map

func LoadHashMap added in v1.0.6

func LoadHashMap(hashesReader io.Reader) (hashes map[string]string)

LoadHashMap returns a map filename -> hash from reader

func PerformSelfUpdate added in v1.0.15

func PerformSelfUpdate(printer output.Printer, skipSelfUpdate bool) (err error)

update multiwerf binary (self-update)

func PrintActionMessage added in v1.0.15

func PrintActionMessage(msg ActionMessage, printer output.Printer)

func PrintActionMessages added in v1.0.15

func PrintActionMessages(messages chan ActionMessage, printer output.Printer) error

PrintActionMessages handle ActionMessage events and print messages with printer object

func ReleaseFiles

func ReleaseFiles(pkg string, version string, osArch string) map[string]string

ReleaseFiles return a map with release filenames of package pkg for particular osArch and version

func ReleaseProgramFilename added in v1.1.0

func ReleaseProgramFilename(pkg, version, osArch string) string

func ReplaceBinaryFile

func ReplaceBinaryFile(dir string, currentName string, newName string) (err error)

func SelfUpdate

func SelfUpdate(messages chan ActionMessage) string

SelfUpdate checks for new version of multiwerf, download it and execute as a new process. Note: multiwerf has no option to exit on self-update errors.

func SetupStorageDir added in v1.1.0

func SetupStorageDir(printer output.Printer) error

func TildeExpand

func TildeExpand(path string) (string, error)

TildeExpand expands tilde prefix with home directory path

func Update

func Update(group, channel string, skipSelfUpdate, withCache bool) (err error)

Update checks for the actual version for group/channel and downloads it to StorageDir if it does not already exist

Arguments:

- group - a major.minor version to update - channel - a string with channel name - skipSelfUpdate - a boolean to perform self-update - withCache - a boolean to try or not getting remote channel mapping

func Use

func Use(group, channel string, forceRemoteCheck, asFile bool, shell string) (err error)

Use: * prints a shell script or * generates a shell script file and prints the path

The script includes two parts for defined group/version based on local channel mapping: * multiwerf update procedure that will be performed on background or foreground and * werf alias that uses path to the actual werf binary

func ValidateGroup added in v1.1.0

func ValidateGroup(group string, printer output.Printer) error

func VerifyReleaseFileHash

func VerifyReleaseFileHash(messages chan ActionMessage, dir string, hashFile string, targetFile string) (bool, error)

func VerifyReleaseFileHashFromHashes added in v1.0.6

func VerifyReleaseFileHashFromHashes(messages chan ActionMessage, dir string, hashes map[string]string, targetFile string) (bool, error)

func WerfExec added in v1.1.0

func WerfExec(group, channel string, args []string) (err error)

WerfExec launches the latest binary version available for the group/channel based on local channel mapping

func WerfPath added in v1.1.0

func WerfPath(group string, channel string) (err error)

WerfPath prints path to the actual version available for the group/channel based on local channel mapping

Types

type ActionMessage

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

ActionMessage is used to send messages from go routines

type BinaryInfo

type BinaryInfo struct {
	BinaryPath   string
	Version      string
	HashVerified bool
}

func UpdateChannelVersionBinary added in v1.2.0

func UpdateChannelVersionBinary(messages chan ActionMessage, group string, channel string, tryRemoteChannelMapping bool) (binInfo *BinaryInfo)

func UseChannelVersionBinary added in v1.2.0

func UseChannelVersionBinary(messages chan ActionMessage, group string, channel string) (binInfo *BinaryInfo)

type ChannelMapping added in v1.1.0

type ChannelMapping interface {
	ChannelVersion(group, channel string) (string, error)
	Save() error
}

func GetChannelMapping added in v1.2.0

func GetChannelMapping(messages chan ActionMessage, tryRemoteChannelMapping bool) (ChannelMapping, error)

type ChannelMappingBase added in v1.1.0

type ChannelMappingBase struct {
	Multiwerf []struct {
		Group    string `json:"group"`
		Channels []struct {
			Name    string `json:"name"`
			Version string `json:"version"`
		} `json:"channels"`
	} `json:"multiwerf"`
}

func (*ChannelMappingBase) ChannelVersion added in v1.2.0

func (c *ChannelMappingBase) ChannelVersion(group, channel string) (string, error)

func (*ChannelMappingBase) Save added in v1.1.0

func (c *ChannelMappingBase) Save() error

type ChannelMappingLocal added in v1.1.0

type ChannelMappingLocal struct {
	ChannelMappingBase
}

type ChannelMappingRemote added in v1.1.0

type ChannelMappingRemote struct {
	ChannelMappingBase
}

func (*ChannelMappingRemote) Save added in v1.1.0

func (c *ChannelMappingRemote) Save() error

type DelayFile added in v1.2.0

type DelayFile struct {
	Filename string
	Delay    time.Duration
}

func (*DelayFile) IsDelayPassed added in v1.2.0

func (u *DelayFile) IsDelayPassed() bool

IsDelayPassed returns true if delay has passed since last UpdateTimestamp

func (*DelayFile) TimeRemains added in v1.2.0

func (u *DelayFile) TimeRemains() string

TimeRemains returns a string representation of time until delay is passed. Empty string is returned if delay is passed

func (*DelayFile) UpdateTimestamp added in v1.2.0

func (u *DelayFile) UpdateTimestamp() error

UpdateTimestamp sets delay timestamp as now() be recreating a delay file

func (*DelayFile) WithDelay added in v1.2.0

func (u *DelayFile) WithDelay(d time.Duration)

type MsgType added in v1.2.0

type MsgType string
var (
	OkMsgType   MsgType = "ok"
	WarnMsgType MsgType = "warn"
	FailMsgType MsgType = "fail"
)

Jump to

Keyboard shortcuts

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