multiwerf

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AvailableChannels = []string{
	"alpha",
	"beta",
	"rc",
	"stable",
}
View Source
var MultiwerfStorageDir string

Effective path to a storage.

Functions

func CalculateSHA256

func CalculateSHA256(filePath string) (string, error)

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 ChooseLatestVersion

func ChooseLatestVersion(version string, channel string, availableVersions []string, availableChannels []string) (string, error)

ChooseLatestVersion returns a latest version from availableVersions that suits version and channel constrain.

version is a constrain on MAJOR and MINOR parts

channel is a constrain on Prerelease part

availableChannels is an array of prioritized Prerelease variants

func ChooseLatestVersionSimple

func ChooseLatestVersionSimple(availableVersions []string) (string, error)

ChooseLatestVersionSimple returns a latest version from availableVersions array

func DirExists added in v1.0.6

func DirExists(dir string) (bool, error)

func DoSelfUpdate added in v1.0.6

func DoSelfUpdate(messages chan ActionMessage) string

func DownloadVersion added in v1.0.6

func DownloadVersion(version string, messages chan ActionMessage, btClient bintray.BintrayClient) (err 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 ExpandAndVerifyDirectoryPath added in v1.0.6

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

func FileExists

func FileExists(dir string, name string) (bool, error)

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 LoadHashFile

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

func LoadHashMap added in v1.0.6

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

func PrintMessages added in v1.0.6

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

PrintMessages handle ActionMessage events and print messages to the screen

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 RemoteLatestVersion added in v1.0.6

func RemoteLatestVersion(version string, channel string, messages chan ActionMessage, btClient bintray.BintrayClient) (latestVersion string, err error)

RemoteLatestVersion searches for a latest available version in bintray

func ReplaceBinaryFile

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

func SelfUpdate

func SelfUpdate(messages chan ActionMessage)

SelfUpdate checks for new version of multiwerf, download it and execute a new proccess success — downloaded new version, need exec success — already latest version warning — cannot rewrite binary, self update disabled by spec error — no versions in bintray, download problems, etc. — stop self update debug — just show a message multiwerf has no option to exit on self-update errors.

func TildeExpand

func TildeExpand(path string) (string, error)

func Update

func Update(version string, channel string, args []string) (err error)

func Use

func Use(version string, channel string, args []string) (err error)

func VerifyReleaseFileHash

func VerifyReleaseFileHash(dir string, hashFile string, targetFile string) (bool, error)

TODO transform to VerifyFileHash — return 4 states: no hash file, no target file, not match, match

func VerifyReleaseFileHashFromHashes added in v1.0.6

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

Types

type ActionMessage

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

use and update actions send messages

type BinaryInfo

type BinaryInfo struct {
	BinaryPath   string
	Version      string
	HashVerified bool
}

func GetBinaryInfo added in v1.0.6

func GetBinaryInfo(version string, messages chan ActionMessage) (binInfo BinaryInfo, err error)

GetBinaryInfo return BinaryInfo object for binary with exact version if it is stored in MultiwerfStorageDir. Empty object is returned if no binary found. Hash of binary is verified with SHA256SUMS files.

func LocalLatestBinaryInfo added in v1.0.6

func LocalLatestBinaryInfo(version string, channel string, messages chan ActionMessage) (binInfo BinaryInfo, err error)

LocalLatestBinaryInfo return BinaryInfo for latest localy available version

1. find version dirs in ~/.multiwerf 2. find latest version for channel and verify a hash for that binary

type BinaryUpdater added in v1.0.6

type BinaryUpdater interface {
	// this method is intented to update from remote source
	// check remote — get local — if local need update — download and verify a hash
	// ↑no remote — error/exit
	//                ↑no local — no error
	//                                                   ↑ error if download failed or hash not verified
	DownloadLatest(version string, channel string) (binInfo BinaryInfo)

	// this method return BinaryInfo instance
	// multiwerf exit with error if no binary found remote or local
	// check remote versions — check local version — if local need update — download and verify a hash
	GetLatestBinaryInfo(version string, channel string) (binInfo BinaryInfo)
}

func NewBinaryUpdater added in v1.0.6

func NewBinaryUpdater(messages chan ActionMessage) BinaryUpdater

type MainBinaryUpdater added in v1.0.6

type MainBinaryUpdater struct {
	BintrayClient bintray.BintrayClient
	Messages      chan ActionMessage
}

func (*MainBinaryUpdater) DownloadLatest added in v1.0.6

func (u *MainBinaryUpdater) DownloadLatest(version string, channel string) (binInfo BinaryInfo)

UpdateBinary check for new latest version in bintray. Exit with error on connection problems or if no versions found for version/channel 1. Check for new version → print version 2. Check hashes existed binaries → print 'version stays' 3. Download and check if no binaries are existed — print 'updated to'

func (*MainBinaryUpdater) GetLatestBinaryInfo added in v1.0.6

func (u *MainBinaryUpdater) GetLatestBinaryInfo(version string, channel string) (binInfo BinaryInfo)

GetLatestBinaryInfo return BinaryInfo object for latest binary with version/channel. Checks for local versions and remote versions. If no remote version is available — use local version.

Jump to

Keyboard shortcuts

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