Documentation
¶
Overview ¶
Package apt provides functionality for parsing APT package manager output.
Index ¶
- Variables
- func AddPPACmd(ppa string) *exec.Cmd
- func AutoRemoveCmd() *exec.Cmd
- func DistUpgradeCmd(recommends, suggests, includePhased bool) *exec.Cmd
- func GetDependencies(name string) ([]string, error)
- func Hold(names []string) error
- func InstallBatchCmd(names []string, recommends, suggests bool) *exec.Cmd
- func InstallVersionCmd(name, version string, recommends, suggests bool) *exec.Cmd
- func ListAllNames() ([]string, error)
- func ListAutoremovable() ([]string, error)
- func ListHeld() ([]string, error)
- func ListInstalled() ([]model.Package, error)
- func ListManual() (map[string]bool, error)
- func ListPackageFiles(name string) ([]string, error)
- func ListPolicyPinned(knownNames []string) (map[string]bool, error)
- func ListUpgradable() ([]model.Package, error)
- func LoadAllAvailableInfo() map[string]PackageInfo
- func PhasedPackages() ([]string, error)
- func PurgeBatchCmd(names []string) *exec.Cmd
- func RemoveBatchCmd(names []string) *exec.Cmd
- func RemovePPACmd(ppa string) *exec.Cmd
- func SearchPackages(query string) ([]model.Package, error)
- func SetPPAEnabled(ppa PPA, enabled bool) error
- func ShowPackage(name string, version string) (string, error)
- func SilentUpdate() error
- func Unhold(names []string) error
- func UpdateCmd() *exec.Cmd
- func UpgradeBatchCmd(names []string, recommends, suggests bool) *exec.Cmd
- func ValidatePPA(input string) error
- type PPA
- type PackageInfo
- type VersionInfo
Constants ¶
This section is empty.
Variables ¶
var ErrAptFileMissing = errors.New("apt-file is not installed. Install it to list files of non-installed packages")
Functions ¶
func AutoRemoveCmd ¶ added in v0.3.0
func DistUpgradeCmd ¶ added in v0.5.0
func GetDependencies ¶
GetDependencies returns the direct dependency package names for a given package.
func InstallBatchCmd ¶ added in v0.2.1
InstallBatchCmd returns an install command for multiple packages at once.
func InstallVersionCmd ¶ added in v0.8.1
InstallVersionCmd returns a command to install a specific version of a package.
func ListAllNames ¶
func ListAutoremovable ¶ added in v0.3.0
ListAutoremovable returns the names of packages that can be autoremoved.
func ListHeld ¶ added in v0.4.0
ListHeld returns the names of packages currently held back via apt-mark.
func ListInstalled ¶
func ListManual ¶ added in v0.7.0
ListManual returns the names of packages explicitly installed by the user (not auto-installed as dependencies).
func ListPackageFiles ¶ added in v0.7.0
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
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 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
PhasedPackages returns package names whose upgrades are currently deferred by APT's phased-updates mechanism.
func PurgeBatchCmd ¶ added in v0.2.1
PurgeBatchCmd returns a purge command for multiple packages at once.
func RemoveBatchCmd ¶ added in v0.2.1
RemoveBatchCmd returns a remove command for multiple packages at once.
func RemovePPACmd ¶ added in v0.3.0
RemovePPACmd returns a command to remove a PPA repository.
func SetPPAEnabled ¶ added in v0.3.0
SetPPAEnabled enables or disables a PPA by modifying its source file.
func SilentUpdate ¶ added in v0.3.0
func SilentUpdate() error
func UpgradeBatchCmd ¶ added in v0.2.1
UpgradeBatchCmd returns an upgrade command for multiple packages at once.
func ValidatePPA ¶ added in v0.3.0
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
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.