Documentation
¶
Overview ¶
Package apt provides an implementation of the syspkg manager interface for the apt package manager. It provides an Go (golang) API interface for interacting with the APT package manager. This package is a wrapper around the apt command line tool.
APT is the default package manager on Debian-based systems such as Ubuntu, it's a set of core tools inside the Debian package management system. APT simplifies the process of managing software on Unix-like computer systems by automating the retrieval, configuration and installation of software packages, either from precompiled files or by compiling source code. APT was originally designed as a front-end for dpkg to work with Debian's .deb packages, but it has since been modified to also work with the RPM Package Manager system via APT-RPM. The Fink project has ported APT to Mac OS X for some of its own package management tasks. APT is also the upstream for Aptitude, another Debian package manager.
For more information about apt, visit: - https://wiki.debian.org/Apt - https://ubuntu.com/server/docs/package-management This package is part of the syspkg library.
Package apt provides a package manager implementation for Debian-based systems using Advanced Package Tool (APT) as the underlying package management tool.
Index ¶
- Constants
- Variables
- func ParseDeletedOutput(msg string, opts *manager.Options) []manager.PackageInfo
- func ParseDpkgQueryOutput(output []byte, packages map[string]manager.PackageInfo) ([]manager.PackageInfo, error)
- func ParseFindOutput(msg string, opts *manager.Options) []manager.PackageInfo
- func ParseInstallOutput(msg string, opts *manager.Options) []manager.PackageInfo
- func ParseListInstalledOutput(msg string, opts *manager.Options) []manager.PackageInfo
- func ParseListUpgradableOutput(msg string, opts *manager.Options) []manager.PackageInfo
- func ParsePackageInfoOutput(msg string, opts *manager.Options) manager.PackageInfo
- type PackageManager
- func (a *PackageManager) AutoRemove(opts *manager.Options) ([]manager.PackageInfo, error)
- func (a *PackageManager) Clean(opts *manager.Options) error
- func (a *PackageManager) Delete(pkgs []string, opts *manager.Options) ([]manager.PackageInfo, error)
- func (a *PackageManager) Find(keywords []string, opts *manager.Options) ([]manager.PackageInfo, error)
- func (a *PackageManager) GetPackageInfo(pkg string, opts *manager.Options) (manager.PackageInfo, error)
- func (a *PackageManager) GetPackageManager() string
- func (a *PackageManager) Install(pkgs []string, opts *manager.Options) ([]manager.PackageInfo, error)
- func (a *PackageManager) IsAvailable() bool
- func (a *PackageManager) ListInstalled(opts *manager.Options) ([]manager.PackageInfo, error)
- func (a *PackageManager) ListUpgradable(opts *manager.Options) ([]manager.PackageInfo, error)
- func (a *PackageManager) Refresh(opts *manager.Options) error
- func (a *PackageManager) Upgrade(pkgs []string, opts *manager.Options) ([]manager.PackageInfo, error)
- func (a *PackageManager) UpgradeAll(opts *manager.Options) ([]manager.PackageInfo, error)
Constants ¶
const ( ArgsAssumeYes string = "-y" ArgsAssumeNo string = "--assume-no" ArgsDryRun string = "--dry-run" ArgsFixBroken string = "-f" ArgsQuiet string = "-qq" ArgsPurge string = "--purge" ArgsAutoRemove string = "--autoremove" ArgsShowProgress string = "--show-progress" )
Constants used for apt commands
Variables ¶
var ENV_NonInteractive []string = []string{"LC_ALL=C", "DEBIAN_FRONTEND=noninteractive", "DEBCONF_NONINTERACTIVE_SEEN=true"}
ENV_NonInteractive contains environment variables used to set non-interactive mode for apt and dpkg.
Functions ¶
func ParseDeletedOutput ¶
func ParseDeletedOutput(msg string, opts *manager.Options) []manager.PackageInfo
ParseDeletedOutput parses the output of `apt remove packageName` command and returns a list of removed packages.
func ParseDpkgQueryOutput ¶
func ParseDpkgQueryOutput(output []byte, packages map[string]manager.PackageInfo) ([]manager.PackageInfo, error)
ParseDpkgQueryOutput parses the output of `dpkg-query` command and updates the status and version of the packages in the provided map of package names and manager.PackageInfo objects. It returns a list of manager.PackageInfo objects with their statuses and versions updated.
func ParseFindOutput ¶
func ParseFindOutput(msg string, opts *manager.Options) []manager.PackageInfo
ParseFindOutput parses the output of `apt search packageName` command and returns a list of available packages that match the search query. It extracts package information such as name, version, architecture, and category from the output, and stores them in a list of manager.PackageInfo objects.
The output format is expected to be similar to the following example:
Sorting... Full Text Search... zutty/jammy 0.11.2.20220109.192032+dfsg1-1 amd64 Efficient full-featured X11 terminal emulator zvbi/jammy 0.2.35-19 amd64 Vertical Blanking Interval (VBI) utilities
The function first removes the "Sorting..." and "Full Text Search..." lines, and then processes each package entry line to extract relevant information.
func ParseInstallOutput ¶
func ParseInstallOutput(msg string, opts *manager.Options) []manager.PackageInfo
ParseInstallOutput parses the output of `apt install packageName` command and returns a list of installed packages. It extracts the package name, package architecture, and version from the lines that start with "Setting up ". Example msg:
Preparing to unpack .../openssl_3.0.2-0ubuntu1.9_amd64.deb ... Unpacking openssl (3.0.2-0ubuntu1.9) over (3.0.2-0ubuntu1.8) ... Setting up libssl3:amd64 (3.0.2-0ubuntu1.9) ... Setting up libssl3:i386 (3.0.2-0ubuntu1.9) ... Setting up libssl-dev:amd64 (3.0.2-0ubuntu1.9) ... Setting up openssl (3.0.2-0ubuntu1.9) ... Processing triggers for man-db (2.10.2-1) ... Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
func ParseListInstalledOutput ¶
func ParseListInstalledOutput(msg string, opts *manager.Options) []manager.PackageInfo
ParseListInstalledOutput parses the output of `dpkg-query -W -f '${binary:Package} ${Version}\n'` command and returns a list of installed packages. It extracts the package name, version, and architecture from the output and stores them in a list of manager.PackageInfo objects.
func ParseListUpgradableOutput ¶
func ParseListUpgradableOutput(msg string, opts *manager.Options) []manager.PackageInfo
ParseListUpgradableOutput parses the output of `apt list --upgradable` command and returns a list of upgradable packages. It extracts the package name, version, new version, category, and architecture from the output and stores them in a list of manager.PackageInfo objects.
func ParsePackageInfoOutput ¶
func ParsePackageInfoOutput(msg string, opts *manager.Options) manager.PackageInfo
ParsePackageInfoOutput parses the output of `apt-cache show packageName` command and returns a manager.PackageInfo object containing package information such as name, version, architecture, and category. This function is useful for getting detailed package information.
Types ¶
type PackageManager ¶
type PackageManager struct{}
PackageManager implements the manager.PackageManager interface for the apt package manager.
func (*PackageManager) AutoRemove ¶
func (a *PackageManager) AutoRemove(opts *manager.Options) ([]manager.PackageInfo, error)
AutoRemove removes unused packages and dependencies using the apt package manager.
func (*PackageManager) Clean ¶
func (a *PackageManager) Clean(opts *manager.Options) error
Clean cleans the local package cache used by the apt package manager.
func (*PackageManager) Delete ¶
func (a *PackageManager) Delete(pkgs []string, opts *manager.Options) ([]manager.PackageInfo, error)
Delete removes the provided packages using the apt package manager.
func (*PackageManager) Find ¶
func (a *PackageManager) Find(keywords []string, opts *manager.Options) ([]manager.PackageInfo, error)
Find searches for packages matching the provided keywords using the apt package manager.
func (*PackageManager) GetPackageInfo ¶
func (a *PackageManager) GetPackageInfo(pkg string, opts *manager.Options) (manager.PackageInfo, error)
GetPackageInfo retrieves package information for the specified package using the apt package manager.
func (*PackageManager) GetPackageManager ¶
func (a *PackageManager) GetPackageManager() string
GetPackageManager returns the name of the apt package manager.
func (*PackageManager) Install ¶
func (a *PackageManager) Install(pkgs []string, opts *manager.Options) ([]manager.PackageInfo, error)
Install installs the provided packages using the apt package manager.
func (*PackageManager) IsAvailable ¶
func (a *PackageManager) IsAvailable() bool
IsAvailable checks if the apt package manager is available on the system.
func (*PackageManager) ListInstalled ¶
func (a *PackageManager) ListInstalled(opts *manager.Options) ([]manager.PackageInfo, error)
ListInstalled lists all installed packages using the apt package manager.
func (*PackageManager) ListUpgradable ¶
func (a *PackageManager) ListUpgradable(opts *manager.Options) ([]manager.PackageInfo, error)
ListUpgradable lists all upgradable packages using the apt package manager.
func (*PackageManager) Refresh ¶
func (a *PackageManager) Refresh(opts *manager.Options) error
Refresh updates the package list using the apt package manager.
func (*PackageManager) Upgrade ¶
func (a *PackageManager) Upgrade(pkgs []string, opts *manager.Options) ([]manager.PackageInfo, error)
Upgrade upgrades the provided packages using the apt package manager.
func (*PackageManager) UpgradeAll ¶
func (a *PackageManager) UpgradeAll(opts *manager.Options) ([]manager.PackageInfo, error)
UpgradeAll upgrades all installed packages using the apt package manager.