apt

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 19 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 apt provides functionality for parsing APT package manager output.

Index

Constants

This section is empty.

Variables

View Source
var ErrAptFileMissing = errors.New("apt-file is not installed. Install it to list files of non-installed packages")

Functions

func AddPPACmd added in v0.3.0

func AddPPACmd(ppa string) *exec.Cmd

AddPPACmd returns a command to add a PPA repository.

func AutoRemoveCmd added in v0.3.0

func AutoRemoveCmd() *exec.Cmd

func DistUpgradeCmd added in v0.5.0

func DistUpgradeCmd(recommends, suggests, includePhased bool) *exec.Cmd

func GetDependencies

func GetDependencies(name string) ([]string, error)

GetDependencies returns the direct dependency package names for a given package.

func Hold added in v0.4.0

func Hold(names []string) error

Hold holds packages via apt-mark hold.

func InstallBatchCmd added in v0.2.1

func InstallBatchCmd(names []string, recommends, suggests bool) *exec.Cmd

InstallBatchCmd returns an install command for multiple packages at once.

func InstallVersionCmd added in v0.8.1

func InstallVersionCmd(name, version string, recommends, suggests bool) *exec.Cmd

InstallVersionCmd returns a command to install a specific version of a package.

func ListAllNames

func ListAllNames() ([]string, error)

func ListAutoremovable added in v0.3.0

func ListAutoremovable() ([]string, error)

ListAutoremovable returns the names of packages that can be autoremoved.

func ListHeld added in v0.4.0

func ListHeld() ([]string, error)

ListHeld returns the names of packages currently held back via apt-mark.

func ListInstalled

func ListInstalled() ([]model.Package, error)

func ListManual added in v0.7.0

func ListManual() (map[string]bool, error)

ListManual returns the names of packages explicitly installed by the user (not auto-installed as dependencies).

func ListPackageFiles added in v0.7.0

func ListPackageFiles(name string) ([]string, error)

ListPackageFiles returns the files belonging to a package. It tries dpkg -L first (works for installed packages), then falls back to apt-file list for non-installed packages.

func ListPolicyPinned added in v0.8.2

func ListPolicyPinned(knownNames []string) (map[string]bool, error)

ListPolicyPinned returns package names that are targeted by package-specific rules from apt preferences files (resolved via platform.AptPath). Global rules (Package: *) are ignored to avoid marking all packages in the UI.

func ListUpgradable

func ListUpgradable() ([]model.Package, error)

func LoadAllAvailableInfo added in v0.4.0

func LoadAllAvailableInfo() map[string]PackageInfo

LoadAllAvailableInfo parses APT package index files to bulk-load metadata for all available packages. This is much faster than spawning apt-cache show processes because it's pure file I/O with no process overhead.

func PhasedPackages added in v0.7.0

func PhasedPackages() ([]string, error)

PhasedPackages returns package names whose upgrades are currently deferred by APT's phased-updates mechanism.

func PurgeBatchCmd added in v0.2.1

func PurgeBatchCmd(names []string) *exec.Cmd

PurgeBatchCmd returns a purge command for multiple packages at once.

func RemoveBatchCmd added in v0.2.1

func RemoveBatchCmd(names []string) *exec.Cmd

RemoveBatchCmd returns a remove command for multiple packages at once.

func RemovePPACmd added in v0.3.0

func RemovePPACmd(ppa string) *exec.Cmd

RemovePPACmd returns a command to remove a PPA repository.

func SearchPackages

func SearchPackages(query string) ([]model.Package, error)

func SetPPAEnabled added in v0.3.0

func SetPPAEnabled(ppa PPA, enabled bool) error

SetPPAEnabled enables or disables a PPA by modifying its source file.

func ShowPackage

func ShowPackage(name string, version string) (string, error)

func SilentUpdate added in v0.3.0

func SilentUpdate() error

func Unhold added in v0.4.0

func Unhold(names []string) error

Unhold unholds packages via apt-mark unhold.

func UpdateCmd added in v0.3.0

func UpdateCmd() *exec.Cmd

func UpgradeBatchCmd added in v0.2.1

func UpgradeBatchCmd(names []string, recommends, suggests bool) *exec.Cmd

UpgradeBatchCmd returns an upgrade command for multiple packages at once.

func ValidatePPA added in v0.3.0

func ValidatePPA(input string) error

ValidatePPA checks that a PPA string has the correct format.

Types

type PPA added in v0.3.0

type PPA struct {
	Name        string // e.g. "ppa:deadsnakes/ppa" or "debian main"
	URL         string // e.g. "https://ppa.launchpad.net/deadsnakes/ppa/ubuntu"
	File        string // source file path
	SourceEntry int    // 1-based stanza number for Deb822 .sources files; 0 for .list files
	SourceID    string // stable Deb822 stanza fingerprint excluding Enabled
	Components  string
	Enabled     bool
	IsPPA       bool
}

PPA represents a repository configured on the system. When IsPPA is true it is a Launchpad PPA; otherwise it is a standard Debian/Ubuntu repository entry.

func ListAllRepos added in v0.7.0

func ListAllRepos() ([]PPA, error)

ListAllRepos scans /etc/apt/sources.list and /etc/apt/sources.list.d/ for all repository entries, including both PPA and standard Debian/Ubuntu repositories.

type PackageInfo

type PackageInfo struct {
	Version      string
	Size         string
	Section      string
	Architecture string
	Description  string
	Essential    bool
	Origins      []string // repository origins that provide this package
}

func ParseShowEntry

func ParseShowEntry(info string) PackageInfo

ParseShowEntry parses a single apt-cache show output and returns PackageInfo.

type VersionInfo added in v0.8.1

type VersionInfo struct {
	Version   string
	Installed bool
	Origin    string // repository origin (e.g. "Ubuntu", archive URI)
}

VersionInfo holds metadata about a specific version of a package.

func ListVersions added in v0.8.1

func ListVersions(name string) ([]VersionInfo, error)

ListVersions returns all available versions for a package using apt-cache policy.

Jump to

Keyboard shortcuts

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