multiwerf

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

MultiwerfStorageDir is an effective path to a storage

Functions

func AvailableReleases added in v1.0.11

func AvailableReleases(version string, channel string, outputFormat string) (err error)

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 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(path string) (bool, error)

DirExists returns true if path is an existing directory

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(dir string, name string) (bool, error)

FileExists returns true if file `name` is existing in `dir`

func FindSemverDirs added in v1.0.13

func FindSemverDirs(path string) ([]string, string, 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 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) (err error)

update multiwerf binary (self update)

func PickLatestVersions added in v1.0.10

func PickLatestVersions(version string, versions []string, top int) []string

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 RemoteLatestChannelsReleases added in v1.0.11

func RemoteLatestChannelsReleases(version string, messages chan ActionMessage, btClient bintray.BintrayClient) (orderedReleases []string, releases map[string][]string, err error)

RemoteLatestChannelsReleases searches for a latest available version in bintray for each channel

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 SetupVersionAndStorageDir added in v1.0.15

func SetupVersionAndStorageDir(version string, printer output.Printer) (err error)

func TildeExpand

func TildeExpand(path string) (string, error)

TildeExpand expands tilde prefix with home directory path

func Update

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

Update checks for the latest available version and download it to StorageDir

Arguments:

- version - a major.minor portion of version to update - channel - a string with channel name - args - excess arguments from command line (not used yet by "update" command)

This command is fully locked on major.minor basis: - if "update-1.0" lock is present, then command is exited with message - if "lock is acquired, then self-update and update is performed as usual.

func Use

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

Use prints a shell script with alias to the latest binary version available for the channel TODO make script more responsive: print messages immediately

func VerifyReleaseFileHash

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

VerifyReleaseFileHash verify targetFile in dir accroding to hashFile in dir

There are three states: - err != nil if something is missing false, nil if files are exists, we got hash for file and hashes is not matched true, nil is hashes is matched

func VerifyReleaseFileHashFromHashes added in v1.0.6

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

VerifyReleaseFileHashFromHashes verifies targetFile hash with matched hash from hashes map

Types

type ActionMessage

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

ActionMessage is used to send messages from go routines started in use and update commands

type AllChannelsReleasesInfo added in v1.0.11

type AllChannelsReleasesInfo struct {
	OrderedChannels []string            `json:"orderedChannels"`
	OrderedReleases []string            `json:"orderedReleases"`
	Releases        map[string][]string `json:"releases"`
}

{"orderedChannels":[stable, ea, ...], orderedReleases: ["v1.1.0","v1.1.1-alpha.10"], releases:{"v1.1.0":[stable,ea], "v1.1.1-alpha.10":["alpha"]}}

type AvailableReleasesInformer added in v1.0.11

type AvailableReleasesInformer interface {
	// GetReleases retrieves information about available releases.
	GetMajorMinorReleases() ([]string, error)
	// GetllChannelsReleases retrieves infrmation about all channels for MAJOR.MINOR version
	GetAllChannelsReleases(version string) (AllChannelsReleasesInfo, error)
	// GetRelease returns exact versoin for MAJOR.MINOR and channel as use or update command will do
	GetRelease(version string, channel string) (string, error)
}

func NewAvailableReleasesInformer added in v1.0.11

func NewAvailableReleasesInformer(messages chan ActionMessage) AvailableReleasesInformer

type BinaryInfo

type BinaryInfo struct {
	BinaryPath        string
	Version           string
	HashVerified      bool
	AvailableVersions []string
}

func DownloadRelease added in v1.0.15

func DownloadRelease(version string, messages chan ActionMessage, btClient bintray.BintrayClient) (binInfo BinaryInfo, err error)

DownloadRelease download all files for release and verify them. If files are good, then create version directory and move files there

func GetLocalReleaseInfo added in v1.0.15

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

GetLocalReleaseInfo 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 NOT verified with SHA256SUMS files.

func GetVerifiedBinaryInfo added in v1.0.15

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

GetVerifiedBinaryInfo 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 returns BinaryInfo for latest locally available version

1. find version dirs in ~/.multiwerf 2. find latest version for channel 3. check if binary exists in directory with version

Note that this function doesn't verify a file hash

func RemoteLatestBinaryInfo added in v1.0.10

func RemoteLatestBinaryInfo(version string, channel string, messages chan ActionMessage, btClient bintray.BintrayClient) (binInfo BinaryInfo, err error)

RemoteLatestBinaryInfo searches for a latest available version in bintray

type BinaryUpdater added in v1.0.6

type BinaryUpdater interface {
	// DownloadLatest updates a binary in local storage from remote source
	//
	// Check remote latest → get local latest → 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)

	// GetLatestBinaryInfo returns BinaryInfo instance with path to the program of latest version.
	//
	// If remote is enabled, then method tries to get a latest version from remote source and verify a hash.
	//
	// If remote is not enabled or remote update was not successfull, then method check if local latest version is good.
	GetLatestBinaryInfo(version string, channel string) (binInfo BinaryInfo)

	// SetRemoteEnabled sets remoteEnabled flag
	SetRemoteEnabled(enabled bool)
}

func NewBinaryUpdater added in v1.0.6

func NewBinaryUpdater(messages chan ActionMessage) BinaryUpdater

type Delayable added in v1.0.10

type Delayable interface {
	WithDelay(d time.Duration)
	IsDelayPassed() bool
	TimeRemains() string
	UpdateTimestamp()
}

type MainAvailableReleasesInformer added in v1.0.11

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

func (*MainAvailableReleasesInformer) GetAllChannelsReleases added in v1.0.11

func (m *MainAvailableReleasesInformer) GetAllChannelsReleases(version string) (info AllChannelsReleasesInfo, err error)

TODO

func (*MainAvailableReleasesInformer) GetMajorMinorReleases added in v1.0.11

func (m *MainAvailableReleasesInformer) GetMajorMinorReleases() ([]string, error)

TODO

func (*MainAvailableReleasesInformer) GetRelease added in v1.0.11

func (m *MainAvailableReleasesInformer) GetRelease(version string, channel string) (string, error)

type MainBinaryUpdater added in v1.0.6

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

func (*MainBinaryUpdater) DownloadLatest added in v1.0.6

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

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

func (*MainBinaryUpdater) SetRemoteEnabled added in v1.0.11

func (u *MainBinaryUpdater) SetRemoteEnabled(enabled bool)

type SemverWithChannels added in v1.0.8

type SemverWithChannels []*semver.Version

SemverWithChannels is a collection of Version instances and implements the sort interface. See the sort package for more details. https://golang.org/pkg/sort/

func (SemverWithChannels) Len added in v1.0.8

func (c SemverWithChannels) Len() int

Len returns the length of a collection. The number of Version instances on the slice.

func (SemverWithChannels) Less added in v1.0.8

func (c SemverWithChannels) Less(i, j int) bool

Less is needed for the sort interface to compare two Version objects on the slice. If checks if one is less than the other.

func (SemverWithChannels) Swap added in v1.0.8

func (c SemverWithChannels) Swap(i, j int)

Swap is needed for the sort interface to replace the Version objects at two different positions in the slice.

type UpdateDelay added in v1.0.10

type UpdateDelay struct {
	Filename string
	Delay    time.Duration
}

func (*UpdateDelay) IsDelayPassed added in v1.0.10

func (u *UpdateDelay) IsDelayPassed() bool

IsDelayPassed returns true if delay has passed since last UpdateTimestamp

func (*UpdateDelay) TimeRemains added in v1.0.15

func (u *UpdateDelay) TimeRemains() string

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

func (*UpdateDelay) UpdateTimestamp added in v1.0.10

func (u *UpdateDelay) UpdateTimestamp()

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

func (*UpdateDelay) WithDelay added in v1.0.15

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

Jump to

Keyboard shortcuts

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