goupd

package module
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 16 Imported by: 2

README

goupd

Internal auto-updater library that goes with the make-go project.

Documentation

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PROJECT_NAME string = "unconfigured"
	MODE         string = "DEV"
	CHANNEL      string = "" // output of: git rev-parse --abbrev-ref HEAD
	GIT_TAG      string = ""
	DATE_TAG     string = "0"
	VERSION      string = ""
	HOST         string = "https://dist-go.tristandev.net/"
)
View Source
var BeforeRestart func()

BeforeRestart is called just before the program is restarted, and can be used to prepare for restart, such as duplicating fds before exec/etc.

View Source
var RestartFunction func() error = RestartProgram

RestartFunction is the functions that actually performs the restart, and by default will be RestartProgram which is a OS dependent implementation

View Source
var UnameArchMatch = map[string]string{
	"x86_64":     "amd64",
	"amd64":      "amd64",
	"i686":       "386",
	"powerpc":    "ppc",
	"ppc":        "ppc",
	"ppc64":      "ppc64",
	"armv7l":     "arm",
	"armv6l":     "arm",
	"armv7b":     "armbe",
	"armv6b":     "armbe",
	"aarch64":    "arm64",
	"aarch64_be": "arm64be",
	"armv8b":     "arm64be",
	"armv8l":     "arm64",
	"mips":       "mips",
}

uname -m

View Source
var UnameOsMatch = map[string]string{
	"Linux":    "linux",
	"CYGWIN_*": "windows",
	"MINGW*":   "windows",
	"WIN32":    "windows",
	"WINNT":    "windows",
	"Windows":  "windows",
	"Darwin*":  "darwin",
	"FreeBSD":  "freebsd",
}

uname -s

Functions

func AutoUpdate

func AutoUpdate(allowTest bool)

func Busy added in v0.1.3

func Busy()

func Fetch deprecated added in v0.1.4

func Fetch(projectName, curTag, os, arch, channel string, cb func(dateTag, gitTag string, r io.Reader) error) error

Fetch will check for updates and call the provided callback cb if there is an update.

Deprecated: Use GetLatest instead

func GetUpdate deprecated added in v0.1.4

func GetUpdate(projectName, curTag, os, arch, channel string) (string, string, string, error)

GetUpdate returns update details for a given project.

Deprecated: You should be using GetLatest instead

func GetVars added in v0.2.6

func GetVars() map[string]string

func Restart added in v0.4.0

func Restart()

func RestartProgram added in v0.2.2

func RestartProgram() error

func RunAutoUpdateCheck

func RunAutoUpdateCheck() bool

RunAutoUpdateCheck will perform the update check, update the executable and return false if no update was performed. In case of update the program should restart and RunAutoUpdateCheck() should not return, but if it does, it'll return true.

func SignalVersion

func SignalVersion(git, build string)

SignalVersion is called when seeing another peer running the same software to notify of its version. This will check if the peer is updated compared to us, and call RunAutoUpdateCheck() if necessary

func SignalVersionChannel added in v0.3.1

func SignalVersionChannel(git, build, channel string)

SignalVersionChannel performs the same as SignalVersion but will also check channel

func SwitchChannel added in v0.3.0

func SwitchChannel(channel string) bool

SwitchChannel will update the current running daemon to run on the given channel. It will return false if the running instance is already the latest version on that channel

func Unbusy added in v0.1.3

func Unbusy()

Types

type Version added in v0.3.3

type Version struct {
	ProjectName  string // project's name
	Channel      string // project channel (typically, branch name)
	DateTag      string // version's date tag
	GitTag       string // version's git tag (first 7 digits of git hash)
	UpdatePrefix string // internally used prefix
}

func GetLatest added in v0.3.3

func GetLatest(projectName, channel string) (*Version, error)

GetLatest returns the latest version information for a given projectName and channel

func (*Version) CheckArch added in v0.3.3

func (v *Version) CheckArch(os, arch string) error

CheckArch checks if the provided version is compatible with the provided os and arch

func (*Version) Download added in v0.3.3

func (v *Version) Download(os, arch string) (io.ReadCloser, error)

Download returns a ReadCloser that allows reading the updated executable data. It will handle any decompression that might be needed, so the data can be read directly. Make sure to close the returned ReadCloser after usage.

func (*Version) Install added in v0.4.0

func (v *Version) Install() error

Install will download the update and replace the currently running executable data

func (*Version) IsCurrent added in v0.4.0

func (v *Version) IsCurrent() bool

IsCurrent returns true if the version matches the currently running program

func (*Version) SaveAs added in v0.4.1

func (v *Version) SaveAs(fn string) error

SaveAs will download the update to the given local filename, performing an atomic replacement of the file

func (*Version) URL added in v0.3.3

func (v *Version) URL(os, arch string) string

URL generates the download url for the provided os and arch. Note that the URL will point to a compressed file, use Download() to instead directly receive decompressed data.

Jump to

Keyboard shortcuts

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