update

package
v0.9.0-rc.53 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: AGPL-3.0 Imports: 35 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 answers whether a newer release exists and how to put it in place.

Index

Constants

View Source
const (
	RollbackNone   = "binary"
	RollbackPGData = "pgdata"
	RollbackBackup = "backup"
)
View Source
const (
	TimerQuiet  = time.Hour
	StartupCalm = 30 * time.Minute
)
View Source
const (
	ProblemFailed  = "failed"
	ProblemStopped = "stopped"
	ProblemFetch   = "fetch"
	ProblemInstall = "install"
)
View Source
const (
	PrivateStaging  = "staging"
	PrivateRollback = "rollback"
	PrivateBin      = "bin"
)
View Source
const (
	ManifestName   = "latest.json"
	ChecksumsName  = "SHA256SUMS"
	ManifestFormat = 1
)
View Source
const (
	RuntimeFile = "serve.json"
	HealthPath  = "/-/health"
)
View Source
const (
	AnnounceAhead = 10 * time.Minute
	CheckEvery    = time.Hour
	DefaultWindow = "03:00-05:00"
	DefaultMinAge = time.Duration(0)

	MissedAfter = 2 * time.Hour

	RollbackKept = 7 * 24 * time.Hour
	PostponeFor  = 24 * time.Hour
	UpdatedShown = 24 * time.Hour
)
View Source
const (
	OutcomeUpdated    = "updated"
	OutcomeRolledBack = "rolled-back"
	OutcomeFailed     = "failed"
)
View Source
const (
	GitHubReleases = "https://github.com/WikitTeam/ProjectWikit/releases"

	EnvReleases = "PWIKIT_RELEASES_URL"
)
View Source
const NoFollow = syscall.O_NOFOLLOW

Variables

View Source
var ErrBusy = errors.New("another pwikit update is running")
View Source
var ErrCannotHandOver = errors.New("the filesystem does not let root change who owns a file")

Functions

func Account

func Account(root string) (uint32, uint32, bool)
func Banner(st db.UpdateState, s Settings, now time.Time) (time.Time, bool)

func CheckInstance

func CheckInstance(root string) error

func CheckRunPath

func CheckRunPath(dir string) string

func ChownTree

func ChownTree(path, root string) error

func CopyFile

func CopyFile(from, to string) error

func CopyTree

func CopyTree(src, dst string) error

func ExecutableName

func ExecutableName(goos string) string

func ExtractExecutable

func ExtractExecutable(archive, dest, goos string) error

func FreeBytes

func FreeBytes(dir string) (uint64, error)

func HealthHandler

func HealthHandler(check func(context.Context) Health) http.Handler

func IsPrivate

func IsPrivate(path string) bool

func ListenHealth

func ListenHealth() (net.Listener, error)

func Lock

func Lock(dir string) (func(), error)

func MaintenanceHandler

func MaintenanceHandler(bundle *i18n.Bundle, assets *static.Assets, files http.Handler) http.Handler

func Newer

func Newer(candidate, current string) bool

func NewlyFound

func NewlyFound(previous string, st db.UpdateState, current string) bool

A release is announced once, when a check first finds it, and only when it is newer than what runs, so a rollback back onto an old number stays quiet.

func NoExec

func NoExec(dir string) bool

func OldExecutable

func OldExecutable(current string) string

func Owner

func Owner(path string) (uint32, uint32, bool)

func PackageDir

func PackageDir(version, goos, goarch string) string

func PackageFile

func PackageFile(version, goos, goarch string) string

func PostgresMajor

func PostgresMajor(version string) string

func Postpone

func Postpone(st *db.UpdateState, now time.Time)

func PrivateDir

func PrivateDir(root string) (string, error)

func PrivatePath

func PrivatePath(root string) string

func RecordCheck

func RecordCheck(st *db.UpdateState, now time.Time, fetch func() (Manifest, error))

func RecordInstance

func RecordInstance(private, root, exe string) error

func RecordedExecutable

func RecordedExecutable(running string) string

func RemoveCheckRun

func RemoveCheckRun(dir string)

func Replace

func Replace(current, next string) error

Windows refuses to overwrite a running program but lets it be renamed, and the updater is itself that program.

func RollbackDir

func RollbackDir(root string) string

func Skip

func Skip(st *db.UpdateState) string

func StartNow

func StartNow(st *db.UpdateState, f Facts) bool

func Startable

func Startable(st db.UpdateState, f Facts) bool

Asking by hand sets aside the window, the age of the release and any earlier skip, postponement or hold, so only what rules an update out is checked.

func Tick

func Tick(st *db.UpdateState, s Settings, f Facts, fetch func() (Manifest, error)) string

func TreeSize

func TreeSize(dir string) (int64, error)

func Writable

func Writable(dir string) bool

func WriteCheckRun

func WriteCheckRun(dir string, run CheckRun) error

func WriteRuntime

func WriteRuntime(dir string, r Runtime) error

Types

type Applier

type Applier struct {
	Root       string
	PGData     string
	Executable string
	Bundled    bool
	Current    string
	Database   []string

	Private  string
	RootCopy string

	Offline bool

	Source      Source
	Machine     Machine
	Run         Runner
	Maintenance func(ctx context.Context) (stop func(), err error)
	Logf        func(format string, args ...any)

	HealthWithin time.Duration
}

func (*Applier) Apply

func (a *Applier) Apply(ctx context.Context, t Target) Outcome

func (*Applier) CurrentPostgres

func (a *Applier) CurrentPostgres() string

func (*Applier) Rollback

func (a *Applier) Rollback(ctx context.Context) (RollbackPoint, error)

type Board

type Board struct {
	DB              *db.DB
	Bundle          *i18n.Bundle
	Settings        Settings
	Current         string
	BundledPostgres string
	Container       bool
	Dir             string
	LogPath         string
	Started         time.Time
	Exposed         string
	AsRoot          bool
	Announce        func(context.Context, db.UpdateState)
	// contains filtered or unexported fields
}

func (*Board) CheckNow

func (b *Board) CheckNow(ctx context.Context) (db.UpdateState, error)

func (*Board) Facts

func (b *Board) Facts(now time.Time) Facts

func (*Board) Notices

func (b *Board) Notices(ctx context.Context) []Notice

func (*Board) Postpone

func (b *Board) Postpone(ctx context.Context) error

func (*Board) Problem

func (b *Board) Problem(ctx context.Context) (CheckProblem, bool)

func (*Board) Skip

func (b *Board) Skip(ctx context.Context) error

func (*Board) StartNow

func (b *Board) StartNow(ctx context.Context) error

func (*Board) Startable

func (b *Board) Startable(ctx context.Context) bool

func (*Board) State

func (b *Board) State(ctx context.Context) db.UpdateState

func (*Board) Wrap

func (b *Board) Wrap(next http.Handler) http.Handler

type CheckProblem

type CheckProblem struct {
	Kind    string
	Error   string
	Version string
}

func Problem

func Problem(run CheckRun, seen bool, st db.UpdateState, s Settings, now, started time.Time) (CheckProblem, bool)

type CheckRun

type CheckRun struct {
	At             time.Time `json:"at"`
	Error          string    `json:"error,omitempty"`
	InstallVersion string    `json:"install_version,omitempty"`
	InstallError   string    `json:"install_error,omitempty"`
}

func ReadCheckRun

func ReadCheckRun(dir string) (CheckRun, bool)

type Facts

type Facts struct {
	Current string

	BundledPostgres string

	Container bool
	Now       time.Time
}

type Health

type Health struct {
	Version  string `json:"version"`
	Database bool   `json:"database"`
	Page     int    `json:"page"`
	Problem  string `json:"problem,omitempty"`
}

func WaitHealthy

func WaitHealthy(ctx context.Context, dir, want string, since time.Time, within time.Duration) (Health, error)

func (Health) OK

func (h Health) OK() bool

type Instance

type Instance struct {
	Root       string `json:"root"`
	Executable string `json:"executable"`
	Dev        uint64 `json:"dev"`
	Ino        uint64 `json:"ino"`
}

func ReadInstance

func ReadInstance(private string) (Instance, bool)

func (Instance) Check

func (in Instance) Check() error

type Machine

type Machine interface {
	StopService(ctx context.Context) error
	StartService(ctx context.Context) error
}

type Manifest

type Manifest struct {
	Format      int                `json:"format"`
	Version     string             `json:"version"`
	PublishedAt string             `json:"published_at"`
	Notes       string             `json:"notes"`
	Postgres    string             `json:"postgres"`
	Packages    map[string]Package `json:"packages"`
}

func ParseManifest

func ParseManifest(body []byte) (Manifest, error)

func (Manifest) Published

func (m Manifest) Published() time.Time

type Notice

type Notice struct {
	Kind    NoticeKind
	Version string
	From    string
	At      time.Time
	Reason  Reason
	Error   string
	Notes   string
	ByHand  bool
}

func Notices

func Notices(st db.UpdateState, s Settings, f Facts) []Notice

type NoticeKind

type NoticeKind string
const (
	NoticeScheduled  NoticeKind = "scheduled"
	NoticeAvailable  NoticeKind = "available"
	NoticeUpdated    NoticeKind = "updated"
	NoticeRolledBack NoticeKind = "rolled-back"
)

type Outcome

type Outcome struct {
	From        string
	To          string
	Kind        string
	Err         error
	RolledBack  bool
	RollbackErr error
}

type Package

type Package struct {
	File   string `json:"file"`
	SHA256 string `json:"sha256"`
	Size   int64  `json:"size"`
}

type Preflight

type Preflight struct {
	Version         string   `json:"version"`
	Postgres        string   `json:"postgres"`
	Pending         []string `json:"pending"`
	PendingBreaking bool     `json:"pending_breaking"`
	PostgresMoves   bool     `json:"postgres_moves"`
	Problem         string   `json:"problem,omitempty"`
}

type Reason

type Reason struct {
	Code   string
	Detail string
}

func Eligible

func Eligible(st db.UpdateState, s Settings, f Facts) (string, Reason)

func (Reason) String

func (r Reason) String() string

type RollbackPoint

type RollbackPoint struct {
	From      string    `json:"from"`
	To        string    `json:"to"`
	Kind      string    `json:"kind"`
	CreatedAt time.Time `json:"created_at"`
}

func ReadRollback

func ReadRollback(dir string) (RollbackPoint, error)

func (RollbackPoint) Expired

func (p RollbackPoint) Expired(now time.Time) bool

type Runner

type Runner func(ctx context.Context, exe string, args ...string) ([]byte, error)

type Runtime

type Runtime struct {
	PID       int       `json:"pid"`
	Version   string    `json:"version"`
	StartedAt time.Time `json:"started_at"`
	Health    string    `json:"health"`

	Mode      string   `json:"mode"`
	Plain     string   `json:"plain"`
	Secure    string   `json:"secure"`
	CertFile  string   `json:"cert_file"`
	KeyFile   string   `json:"key_file"`
	CacheDir  string   `json:"cache_dir"`
	Email     string   `json:"email"`
	Directory string   `json:"directory"`
	Hosts     []string `json:"hosts"`
}

func ReadRuntime

func ReadRuntime(dir string) (Runtime, error)

type Settings

type Settings struct {
	Auto         bool
	PublicBanner bool
	Check        bool
	Window       Window
	Zone         *time.Location
	MinAge       time.Duration
	Mirror       string
}

func (Settings) ZoneName

func (s Settings) ZoneName() string

type Source

type Source struct {
	Releases string
	Mirror   string
	Log      func(string)
	// contains filtered or unexported fields
}

func NewSource

func NewSource(mirror string) Source

func (Source) Checksums

func (s Source) Checksums(ctx context.Context, version string) (map[string]string, error)

func (Source) Download

func (s Source) Download(ctx context.Context, version, file, dest, want string) error

func (Source) Latest

func (s Source) Latest(ctx context.Context) (Manifest, error)

type Target

type Target struct {
	Version string
	File    string
	SHA256  string

	AllowPostgresMove bool
}

type Version

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

func ParseVersion

func ParseVersion(s string) (Version, bool)

func (Version) Compare

func (v Version) Compare(o Version) int

type Window

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

func ParseWindow

func ParseWindow(s string) (Window, error)

func (Window) Next

func (w Window) Next(now time.Time) time.Time

func (Window) String

func (w Window) String() string

Jump to

Keyboard shortcuts

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