Documentation
¶
Overview ¶
Package selfupdate finds newer releases of the modlock command line and installs one over the running executable.
Index ¶
- func Asset() string
- func Build(ctx context.Context, exe string, output io.Writer) (string, error)
- func Check(ctx context.Context, channel Channel, current string, ...)
- func Clean()
- func Executable() (string, error)
- func Install(ctx context.Context, version, exe string) error
- func Latest(ctx context.Context) (string, error)
- func Newer(latest, current string) bool
- func Released(version string) bool
- func Remember(channel Channel, latest string)
- type Channel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Asset ¶
func Asset() string
Asset returns the name of the release file that holds the command line for this computer.
func Build ¶ added in v0.1.81
Build builds the newest commit of the master branch on this computer and replaces the executable at exe with it, writing the tools' output to output. It keeps the source and the build in the user cache, so a later build compiles only what changed, and installs the game server it builds where a session looks for that version's. It returns the version built, which is the one the master channel gives the same commit.
func Check ¶
Check calls found with channel's newest build when it should replace current. It answers at once from the answer cached in the user cache, which holds the newest version and, as its modification time, when it was learned. When that is older than a day it also asks GitHub in the background and calls found again if the fresh answer is later still. found runs at most twice, on any goroutine, and never after ctx ends. Every failure is dropped: the check must never slow or fail the command that runs it.
func Clean ¶
func Clean()
Clean removes the file an update on Windows moved aside, once the command line that ran from it has exited. It does nothing elsewhere.
func Executable ¶
Executable returns the file of the running command line, through any symbolic link that names it.
func Install ¶
Install replaces the executable at exe with the command line of version, a release or a build of master. It downloads the new file beside exe, runs it once to check that it starts and names version, and only then renames it into place, so a failed or interrupted update leaves the old command line working. An error wrapping fs.ErrPermission means exe's directory is not writable.
Types ¶
type Channel ¶ added in v0.1.81
type Channel string
Channel names the line of builds modlock update follows.
func ParseChannel ¶ added in v0.1.81
ParseChannel returns the channel named name.
func (Channel) News ¶ added in v0.1.81
News reports whether latest, the channel's newest build, should replace current. A release replaces only an older release. A build of master replaces any other published version, since master has no order to read from a version. A development build is never replaced.