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 ¶
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 ¶
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") )
var Packages = []string{"opensvc-server", "opensvc-client", "opensvc-webapp"}
Packages are the opensvc packages the update upgrades, those installed.
Functions ¶
func CompareDeb ¶
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 ¶
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.
Types ¶
type Distro ¶
Distro is what /etc/os-release says of the system, the variables naming the repository of its packages.
func ReadDistro ¶
ReadDistro reads the os-release file at path.
func (Distro) AptRepository ¶
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 ¶
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 ¶
DetectManager returns the package manager of the system: apt on a debian one, else dnf, yum or zypper, the first found.
type Package ¶
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.
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 ¶
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.