update

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package update finds out whether a newer RemoHop release exists and how this copy should be upgraded. It only reads: it downloads nothing but a small version file and never replaces a program.

The version file is https://remohop.com/version.json, a static file of the website ({"version": "v1.2.3"}), built from site/build.py. The request carries no identifier: no machine ID, no account, and the User-Agent is just "RemoHop". Everything the app shows (the download page, the release notes) is an address this package builds from the version number, so a tampered file can at most claim a version, never send the user elsewhere.

Index

Constants

View Source
const (
	// AppleTeamID signs the macOS app (checked by VerifyBundle).
	AppleTeamID = "H7FLAAL9RB"
	SigContext  = "remohop-update-v1"
	SumsFile    = "SHA256SUMS"
	SigFile     = "SHA256SUMS.ed25519"
)

In-app upgrades trust a release only through an Ed25519 signature made by the release workflow (secret UPDATE_SIGNING_KEY) over the release's SHA256SUMS. The signed message binds the tag, so the files of an older release cannot be passed off as a newer one:

"remohop-update-v1\n" + tag + "\n" + the bytes of SHA256SUMS

The signature is the release asset SigFile: base64 on one line. The public keys the app accepts are TrustedKeys (keys.go); with none, one-click upgrades are off and the app only opens the download page.

View Source
const (
	KindDownload = "download" // a download from the website: get the new one there
	KindHomebrew = "homebrew"
	KindScoop    = "scoop"
	KindWinget   = "winget"
	KindSnap     = "snap"
	KindPackage  = "package" // .deb, .rpm, .apk, AUR: the system's package manager
	KindNix      = "nix"
	KindStore    = "store" // the Microsoft Store (MSIX): the Store updates it
)

Kinds of installation.

View Source
const Repo = "readori/RemoHop"

Repo is the GitHub repository the release pages are in.

View Source
const URL = "https://remohop.com/version.json"

URL is where the version file lives.

Variables

View Source
var ErrBadSignature = errors.New("the release signature does not check out")

ErrBadSignature: the signature is not one of a trusted key over these sums for this tag.

View Source
var ErrUnsupported = errors.New("this copy cannot upgrade itself")

ErrUnsupported: this copy cannot upgrade itself.

View Source
var TrustedKeys = []string{
	"EhMAtz32qkaC5xnCXOo6SLO2J/fH6WzxkIV3wvZuUyQ=",
	"fdzFU7FhCrIrtD3sTKmcEP4Y1TioJ6LKurOp5fzetSo=",
}

TrustedKeys are the Ed25519 public keys (base64) whose signatures on a release's SHA256SUMS this build accepts for one-click upgrades (sign.go).

  • The first is the release workflow's key; its private half is only the repository secret UPDATE_SIGNING_KEY.
  • The second, when set, is a spare kept offline by the project's owner: if the first is ever lost or leaked, releases are signed with the spare, and a release that drops the old key goes out signed by it.

Empty: one-click upgrades are off, and the app offers the download page. `go run ./scripts/updsign keygen` makes a key pair.

Functions

func Cleanup

func Cleanup(p Plan)

Cleanup removes what an upgrade left behind (the old program, a staged one that was never installed). It is called at start; failures are harmless (the old program may still be exiting on Windows).

func Download

func Download(ctx context.Context, f Fetcher, keys []ed25519.PublicKey, tag string, p Plan, progress Progress) (string, error)

Download fetches and checks tag's archive for p and unpacks the new program next to p.Target. It returns the staged path, which Install puts in place. Nothing is changed when it fails.

func DownloadURL

func DownloadURL(lang string) string

DownloadURL is the website's download page in the given language.

func Install

func Install(p Plan, staged string) error

Install swaps the staged program in: the old one becomes Target+".old" (a running program can be renamed, even on Windows), which Cleanup removes at the next start. On failure the old program is put back.

func Keys

func Keys() []ed25519.PublicKey

Keys returns TrustedKeys parsed. A key that does not parse is a build mistake and panics (TestTrustedKeys catches it first).

func Message

func Message(tag string, sums []byte) []byte

Message is what is signed for a release.

func Newer

func Newer(latest, current string) bool

Newer reports whether latest is a newer version than current. A current version that does not parse (a development build, including one built from source after a tag, such as v1.0.7-3-gabc1234) is never out of date: offering the last release would be a downgrade.

func ParseKey

func ParseKey(s string) (ed25519.PublicKey, error)

ParseKey reads a public key written as base64 (what `updsign keygen` prints).

func ParseSums

func ParseSums(b []byte) (map[string]string, error)

ParseSums reads SHA256SUMS ("<hex> <name>" lines) into name -> hex.

func Sign

func Sign(priv ed25519.PrivateKey, tag string, sums []byte) []byte

Sign signs a release's SHA256SUMS; the result is the content of SigFile.

func Verify

func Verify(keys []ed25519.PublicKey, tag string, sums, sig []byte) error

Verify checks sig (the content of SigFile) against the trusted keys.

func VerifyBundle

func VerifyBundle(string) error

VerifyBundle only applies to macOS app bundles.

Types

type Env

type Env struct {
	GOOS   string
	Exe    string // the program's path, symbolic links resolved
	Getenv func(string) string
	Exists func(string) bool
}

Env is what Detect looks at; tests replace it.

type Fetcher

type Fetcher struct {
	Client *http.Client
	// Base is the release download address with %s for the tag;
	// empty means GitHub's.
	Base string
}

Fetcher downloads release files; tests replace it.

type Method

type Method struct {
	Kind string `json:"kind"`
	// Command upgrades it, when there is one command for it.
	Command string `json:"command,omitempty"`
}

Method is how this copy is upgraded.

func Detect

func Detect(env Env) Method

Detect works out how the program at env.Exe was installed, from where it is. A copy it does not recognise is a download.

type Plan

type Plan struct {
	// Asset is the release file to download.
	Asset string `json:"asset"`
	// Member is the file (or, for an app bundle, the directory) inside it.
	Member string `json:"-"`
	// Target is what is replaced: the program, or on macOS the .app.
	Target string `json:"-"`
	// Bundle: Target is a macOS .app directory.
	Bundle bool `json:"-"`
}

Plan is what an upgrade of this program replaces and with which file.

func PlanFor

func PlanFor(goos, goarch, exe string) (Plan, error)

PlanFor works out the upgrade of the program at exe (symbolic links resolved) on goos/goarch.

func (Plan) Writable

func (p Plan) Writable() bool

Writable reports whether the user can replace p.Target: a file can be created next to it.

type Progress

type Progress func(stage string, percent int)

Progress reports a stage ("verifying", "downloading", "installing") and, while downloading, the percentage done (-1 when unknown).

type Release

type Release struct {
	Version string `json:"version"`
}

Release is what the version file says.

func Fetch

func Fetch(ctx context.Context, client *http.Client, url string) (Release, error)

Fetch reads the version file at url (URL when empty).

func Parse

func Parse(b []byte) (Release, error)

Parse reads a version file. Only a plain release version (vX.Y.Z) is accepted.

func (Release) NotesURL

func (r Release) NotesURL() string

NotesURL is the release's page on GitHub (its notes and files).

type Version

type Version struct {
	Major, Minor, Patch int
	Pre                 string
}

Version is a parsed vMAJOR.MINOR.PATCH[-PRE].

func ParseVersion

func ParseVersion(s string) (Version, bool)

ParseVersion parses "v1.2.3" or "v1.2.3-rc.1". Development builds ("dev", a build from source such as "v1.2.3-4-gabc1234" or "v1.2.3-dirty", or anything else) do not parse.

func (Version) Less

func (v Version) Less(w Version) bool

Less reports whether v comes before w. A pre-release comes before its release; two pre-releases of the same version compare as text, which is enough to tell any of them from the release.

Jump to

Keyboard shortcuts

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