packages

package
v0.0.0-...-66439cb Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 24 Imported by: 2

Documentation

Overview

Package packages provides package management functions for Windows and Linux systems.

Index

Constants

This section is empty.

Variables

View Source
var (
	// AptExists indicates whether apt is installed.
	AptExists bool
	// DpkgExists indicates whether dpkg is installed.
	DpkgExists bool
	// DpkgQueryExists indicates whether dpkg-query is installed.
	DpkgQueryExists bool
	// YumExists indicates whether yum is installed.
	YumExists bool
	// ZypperExists indicates whether zypper is installed.
	ZypperExists bool
	// RPMExists indicates whether rpm is installed.
	RPMExists bool
	// RPMQueryExists indicates whether rpmquery is installed.
	RPMQueryExists bool
	// COSPkgInfoExists indicates whether COS package information is available.
	COSPkgInfoExists bool
	// GemExists indicates whether gem is installed.
	GemExists bool
	// PipExists indicates whether pip is installed.
	PipExists bool
	// GooGetExists indicates whether googet is installed.
	GooGetExists bool
	// MSIExists indicates whether MSIs can be installed.
	MSIExists bool
)

Functions

func AptUpdate

func AptUpdate(ctx context.Context) ([]byte, error)

AptUpdate runs apt-get update.

func DpkgInstall

func DpkgInstall(ctx context.Context, path string) error

DpkgInstall installs a deb package.

func InstallAptPackages

func InstallAptPackages(ctx context.Context, pkgs []string) error

InstallAptPackages installs apt packages.

func InstallGooGetPackages

func InstallGooGetPackages(ctx context.Context, pkgs []string) error

InstallGooGetPackages installs GooGet packages.

func InstallMSIPackage

func InstallMSIPackage(_ context.Context, _ string, _ []string) error

InstallMSIPackage is a linux stub function.

func InstallYumPackages

func InstallYumPackages(ctx context.Context, pkgs []string) error

InstallYumPackages installs yum packages.

func InstallZypperPackages

func InstallZypperPackages(ctx context.Context, pkgs []string) error

InstallZypperPackages Installs zypper packages

func MSIInfo

func MSIInfo(_ string) (string, string, error)

MSIInfo is a linux stub function.

func MSIInstalled

func MSIInstalled(_ string) (bool, error)

MSIInstalled is a linux stub function.

func RPMInstall

func RPMInstall(ctx context.Context, path string) error

RPMInstall installs an rpm packages.

func RemoveAptPackages

func RemoveAptPackages(ctx context.Context, pkgs []string) error

RemoveAptPackages removes apt packages.

func RemoveGooGetPackages

func RemoveGooGetPackages(ctx context.Context, pkgs []string) error

RemoveGooGetPackages installs GooGet packages.

func RemoveYumPackages

func RemoveYumPackages(ctx context.Context, pkgs []string) error

RemoveYumPackages removes yum packages.

func RemoveZypperPackages

func RemoveZypperPackages(ctx context.Context, pkgs []string) error

RemoveZypperPackages installed Zypper packages.

func SetCommandRunner

func SetCommandRunner(commandRunner util.CommandRunner)

SetCommandRunner allows external clients to set a custom commandRunner.

func SetPtyCommandRunner

func SetPtyCommandRunner(commandRunner util.CommandRunner)

SetPtyCommandRunner allows external clients to set a custom custom commandRunner.

func ZypperInstall

func ZypperInstall(ctx context.Context, patches []*ZypperPatch, pkgs []*PkgInfo) error

ZypperInstall installs zypper patches and packages

func ZypperPackagesInPatch

func ZypperPackagesInPatch(ctx context.Context, patches []*ZypperPatch) (map[string][]string, error)

ZypperPackagesInPatch returns the list of patches, a package upgrade belongs to

Types

type AptGetUpgradeOption

type AptGetUpgradeOption func(*aptGetUpgradeOpts)

AptGetUpgradeOption is an option for apt-get upgrade.

func AptGetUpgradeAllowDowngrades

func AptGetUpgradeAllowDowngrades(allowDowngrades bool) AptGetUpgradeOption

AptGetUpgradeAllowDowngrades returns a AptGetUpgradeOption that specifies AllowDowngrades.

func AptGetUpgradeShowNew

func AptGetUpgradeShowNew(showNew bool) AptGetUpgradeOption

AptGetUpgradeShowNew returns a AptGetUpgradeOption that indicates whether 'new' packages should be returned.

func AptGetUpgradeType

func AptGetUpgradeType(upgradeType AptUpgradeType) AptGetUpgradeOption

AptGetUpgradeType returns a AptGetUpgradeOption that specifies upgrade type.

type AptUpgradeType

type AptUpgradeType int

AptUpgradeType is the apt upgrade type.

const (
	// AptGetUpgrade specifies apt-get upgrade should be run.
	AptGetUpgrade AptUpgradeType = iota
	// AptGetDistUpgrade specifies apt-get dist-upgrade should be run.
	AptGetDistUpgrade
	// AptGetFullUpgrade specifies apt-get full-upgrade should be run.
	AptGetFullUpgrade
)

type Packages

type Packages struct {
	Yum                []*PkgInfo            `json:"yum,omitempty"`
	Rpm                []*PkgInfo            `json:"rpm,omitempty"`
	Apt                []*PkgInfo            `json:"apt,omitempty"`
	Deb                []*PkgInfo            `json:"deb,omitempty"`
	Zypper             []*PkgInfo            `json:"zypper,omitempty"`
	ZypperPatches      []*ZypperPatch        `json:"zypperPatches,omitempty"`
	COS                []*PkgInfo            `json:"cos,omitempty"`
	Gem                []*PkgInfo            `json:"gem,omitempty"`
	Pip                []*PkgInfo            `json:"pip,omitempty"`
	GooGet             []*PkgInfo            `json:"googet,omitempty"`
	WUA                []*WUAPackage         `json:"wua,omitempty"`
	QFE                []*QFEPackage         `json:"qfe,omitempty"`
	WindowsApplication []*WindowsApplication `json:"-"`
}

Packages is a selection of packages based on their manager.

func GetInstalledPackages

func GetInstalledPackages(ctx context.Context) (*Packages, error)

GetInstalledPackages gets all installed packages from any known installed package manager.

func GetPackageUpdates

func GetPackageUpdates(ctx context.Context) (*Packages, error)

GetPackageUpdates gets all available package updates from any known installed package manager.

type PkgInfo

type PkgInfo struct {
	Name, Arch, Version string
}

PkgInfo describes a package.

func AptUpdates

func AptUpdates(ctx context.Context, opts ...AptGetUpgradeOption) ([]*PkgInfo, error)

AptUpdates returns all the packages that will be installed when running apt-get [dist-|full-]upgrade.

func DebPkgInfo

func DebPkgInfo(ctx context.Context, path string) (*PkgInfo, error)

DebPkgInfo gets PkgInfo from a deb package.

func GemUpdates

func GemUpdates(ctx context.Context) ([]*PkgInfo, error)

GemUpdates queries for all available gem updates.

func GooGetUpdates

func GooGetUpdates(ctx context.Context) ([]*PkgInfo, error)

GooGetUpdates queries for all available googet updates.

func InstalledCOSPackages

func InstalledCOSPackages() ([]*PkgInfo, error)

InstalledCOSPackages queries for all installed COS packages.

func InstalledDebPackages

func InstalledDebPackages(ctx context.Context) ([]*PkgInfo, error)

InstalledDebPackages queries for all installed deb packages.

func InstalledGemPackages

func InstalledGemPackages(ctx context.Context) ([]*PkgInfo, error)

InstalledGemPackages queries for all installed gem packages.

func InstalledGooGetPackages

func InstalledGooGetPackages(ctx context.Context) ([]*PkgInfo, error)

InstalledGooGetPackages queries for all installed googet packages.

func InstalledPipPackages

func InstalledPipPackages(ctx context.Context) ([]*PkgInfo, error)

InstalledPipPackages queries for all installed pip packages.

func InstalledRPMPackages

func InstalledRPMPackages(ctx context.Context) ([]*PkgInfo, error)

InstalledRPMPackages queries for all installed rpm packages.

func PipUpdates

func PipUpdates(ctx context.Context) ([]*PkgInfo, error)

PipUpdates queries for all available pip updates.

func RPMPkgInfo

func RPMPkgInfo(ctx context.Context, path string) (*PkgInfo, error)

RPMPkgInfo gets PkgInfo from a rpm package.

func YumUpdates

func YumUpdates(ctx context.Context, opts ...YumUpdateOption) ([]*PkgInfo, error)

YumUpdates queries for all available yum updates.

func ZypperUpdates

func ZypperUpdates(ctx context.Context) ([]*PkgInfo, error)

ZypperUpdates queries for all available zypper updates.

func (*PkgInfo) String

func (i *PkgInfo) String() string

type QFEPackage

type QFEPackage struct {
	Caption, Description, HotFixID, InstalledOn string
}

QFEPackage describes a Windows Quick Fix Engineering package.

type WUAPackage

type WUAPackage struct {
	LastDeploymentChangeTime time.Time
	Title                    string
	Description              string
	SupportURL               string
	UpdateID                 string
	Categories               []string
	KBArticleIDs             []string
	MoreInfoURLs             []string
	CategoryIDs              []string
	RevisionNumber           int32
}

WUAPackage describes a Windows Update Agent package.

type WindowsApplication

type WindowsApplication struct {
	DisplayName    string
	DisplayVersion string
	InstallDate    time.Time
	Publisher      string
	HelpLink       string
}

WindowsApplication describes a Windows Application.

type YumUpdateOption

type YumUpdateOption func(*yumUpdateOpts)

YumUpdateOption is an option for yum update.

func YumUpdateMinimal

func YumUpdateMinimal(minimal bool) YumUpdateOption

YumUpdateMinimal returns a YumUpdateOption that specifies the update-minimal command should be used.

func YumUpdateSecurity

func YumUpdateSecurity(security bool) YumUpdateOption

YumUpdateSecurity returns a YumUpdateOption that specifies the --security flag should be used.

type ZypperListOption

type ZypperListOption func(opts *zypperListPatchOpts)

ZypperListOption is patch list options

func ZypperListPatchAll

func ZypperListPatchAll(all bool) ZypperListOption

ZypperListPatchAll is zypper list option to all all patches

func ZypperListPatchCategories

func ZypperListPatchCategories(categories []string) ZypperListOption

ZypperListPatchCategories is zypper list option to provide category filter

func ZypperListPatchSeverities

func ZypperListPatchSeverities(severities []string) ZypperListOption

ZypperListPatchSeverities is zypper list option to provide severity filter

func ZypperListPatchWithOptional

func ZypperListPatchWithOptional(withOptional bool) ZypperListOption

ZypperListPatchWithOptional is zypper list option to also list optional patches

type ZypperPatch

type ZypperPatch struct {
	Name, Category, Severity, Summary string
}

ZypperPatch describes a Zypper patch.

func ZypperInstalledPatches

func ZypperInstalledPatches(ctx context.Context, opts ...ZypperListOption) ([]*ZypperPatch, error)

ZypperInstalledPatches queries for all installed zypper patches.

func ZypperPatches

func ZypperPatches(ctx context.Context, opts ...ZypperListOption) ([]*ZypperPatch, error)

ZypperPatches queries for all available zypper patches.

Jump to

Keyboard shortcuts

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