pkgupdate

package
v3.0.0-rc60 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 21 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 pkgupdate upgrades the opensvc packages installed on the node: from the repositories its package manager has configured when they offer them, else from the opensvc package repository, the latest version downloaded and installed with the package manager.

Index

Constants

View Source
const (
	// DefaultBase is the opensvc package repository.
	DefaultBase = "https://packages.opensvc.com"

	// DefaultBranch is the branch of the packages when none is set: the stable one.
	DefaultBranch = "prod"
)

Variables

View Source
var (
	// ErrNoManager is returned on a system with no package manager the
	// update knows.
	ErrNoManager = errors.New("no package manager known: apt-get, dnf, yum or zypper")
)
View Source
var Packages = []string{"opensvc-server", "opensvc-client", "opensvc-webapp"}

Packages are the opensvc packages the update upgrades, those installed.

Functions

func CompareDeb

func CompareDeb(a, b string) int

CompareDeb compares two Debian package versions, [epoch:]upstream[-revision], as dpkg does: -1, 0 or 1 when a is older than, the same as or newer than b. A tilde sorts before anything, even the end of the version, so that 3.0.0~rc56 is older than 3.0.0, and newer than 3.0.0~rc7.

func CompareRPM

func CompareRPM(a, b string) int

CompareRPM compares two RPM versions, [epoch:]version[-release], as rpm does (rpmvercmp): -1, 0 or 1 when a is older than, the same as or newer than b. A tilde sorts before anything, as in Debian versions.

func DebArch

func DebArch() string

DebArch is the debian name of the architecture the agent runs on.

func RPMArch

func RPMArch() string

RPMArch is the rpm name of the architecture the agent runs on.

Types

type Distro

type Distro struct {
	ID              string
	IDLike          []string
	VersionID       string
	VersionCodename string
}

Distro is what /etc/os-release says of the system, the variables naming the repository of its packages.

func ReadDistro

func ReadDistro(path string) (Distro, error)

ReadDistro reads the os-release file at path.

func (Distro) AptRepository

func (t Distro) AptRepository(branch string) (string, string, error)

AptRepository returns the os directory and the suite of the apt repository of the opensvc packages of branch: ubuntu, prod-opensvc-v3-noble.

func (Distro) RPMRepository

func (t Distro) RPMRepository(branch string) (string, error)

RPMRepository returns the directory of the rpm repository of the opensvc packages of branch: prod-opensvc-v3-rhel9. The Red Hat rebuilds take the rhel packages, the SuSE distributions the sles ones, by major version.

type Manager

type Manager interface {
	// Name is the name of its command: apt-get, dnf, yum, zypper.
	Name() string

	// Format is the format of its packages: deb or rpm.
	Format() string

	// Installed returns the version of a package installed, empty when
	// it is not.
	Installed(name string) (string, error)

	// Refresh reads again the metadata of the configured repositories.
	Refresh() []string

	// Offered tells whether a configured repository offers the package.
	Offered(name string) (bool, error)

	// Upgrade upgrades the packages from the configured repositories.
	Upgrade(names []string) []string

	// Install installs package files, their dependencies taken from the
	// configured repositories.
	Install(files []string) []string

	// Env is the environment its commands run with, besides the agent's.
	Env() []string

	// Compare compares two versions of its packages.
	Compare(a, b string) int
}

Manager is the package manager of the system, the commands it runs to say and change what is installed.

func DetectManager

func DetectManager() (Manager, error)

DetectManager returns the package manager of the system: apt on a debian one, else dnf, yum or zypper, the first found.

type Package

type Package struct {
	Name    string
	Version string
	Arch    string
	Path    string
	SHA256  string
}

Package is a package a repository offers: its name, version and architecture, where to download it, relative to the repository, and the sha256 the repository metadata give for it.

func AptIndex

func AptIndex(ctx context.Context, client *http.Client, base, suite, arch string) ([]Package, error)

AptIndex returns the packages of the apt repository at base (the url of the os directory, as https://packages.opensvc.com/apt/ubuntu) for suite and arch, those of all architectures included.

func Latest

func Latest(l []Package, name string, compare func(a, b string) int) (Package, bool)

Latest returns the newest package named name in l, by compare.

func RPMIndex

func RPMIndex(ctx context.Context, client *http.Client, base, arch string) ([]Package, error)

RPMIndex returns the packages of the rpm repository at base (the url of the directory holding repodata/) for arch, those of no architecture included.

type T

type T struct {
	// Base is the url of the package repository: DefaultBase when empty.
	Base string

	// Branch is the branch of the packages: DefaultBranch when empty.
	Branch string

	// DryRun says what the update would do, and changes nothing: the
	// metadata of the configured repositories are not refreshed.
	DryRun bool

	// Out receives what the update does, and the output of the
	// commands it runs.
	Out io.Writer

	// OSRelease is the os-release file: /etc/os-release when empty.
	OSRelease string

	// Client fetches the repository metadata and the packages.
	Client *http.Client

	// TmpDir holds the packages downloaded: os.TempDir() when empty.
	TmpDir string

	// Manager is the package manager: the one of the system
	// (DetectManager) when nil.
	Manager Manager
}

T is an update of the opensvc packages.

func (*T) Run

func (t *T) Run(ctx context.Context) error

Run upgrades the opensvc packages installed. The repositories configured on the node are preferred: the packages one of them offers are upgraded from there. When none offers any, the latest version of each package is taken from the opensvc package repository of the branch and of the distribution, and installed with the package manager, when newer than the one installed.

Jump to

Keyboard shortcuts

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