Documentation
¶
Overview ¶
Package packages provides package backend operations.
Index ¶
- Variables
- type Apt
- func (a *Apt) Absent(ctx context.Context, pkgs []string) error
- func (a *Apt) DirectDeps(ctx context.Context, pkg string) ([]string, error)
- func (a *Apt) Installed(ctx context.Context) ([]string, error)
- func (a *Apt) IsInstalled(ctx context.Context, pkg string) (bool, error)
- func (a *Apt) Present(ctx context.Context, pkgs []string) error
- func (a *Apt) SetVerbose(v bool)
- type Backend
- type Dnf
- func (d *Dnf) Absent(ctx context.Context, pkgs []string) error
- func (d *Dnf) DirectDeps(ctx context.Context, pkg string) ([]string, error)
- func (d *Dnf) Installed(ctx context.Context) ([]string, error)
- func (d *Dnf) IsInstalled(ctx context.Context, pkg string) (bool, error)
- func (d *Dnf) Present(ctx context.Context, pkgs []string) error
- func (d *Dnf) SetVerbose(v bool)
- type ExecRunner
- type PackageDeps
- type Paru
- func (p *Paru) Absent(ctx context.Context, pkgs []string) error
- func (p *Paru) DirectDeps(ctx context.Context, pkg string) ([]string, error)
- func (p *Paru) Installed(ctx context.Context) ([]string, error)
- func (p *Paru) IsInstalled(ctx context.Context, pkg string) (bool, error)
- func (p *Paru) Present(ctx context.Context, pkgs []string) error
- func (p *Paru) SetVerbose(v bool)
- type Runner
Constants ¶
This section is empty.
Variables ¶
var AutoBackend = func() (string, error) { f, err := detect.Detect() if err != nil { return "", err } return f.Backend, nil }
AutoBackend resolves the backend string from the runtime environment. It is a variable so tests can substitute it.
Functions ¶
This section is empty.
Types ¶
type Apt ¶
type Apt struct {
Runner Runner
}
Apt is the Debian/Ubuntu backend skeleton.
func (*Apt) DirectDeps ¶ added in v0.9.0
DirectDeps returns pkg's direct runtime dependencies via `apt-cache depends`. Unknown packages exit 100 and the error propagates.
func (*Apt) Installed ¶ added in v0.22.0
Installed lists every installed package name via dpkg-query.
func (*Apt) IsInstalled ¶
IsInstalled checks if a package is installed via dpkg.
func (*Apt) Present ¶
Present installs packages idempotently. Unlike dnf (which refreshes repository metadata as part of install), apt needs an explicit index refresh first: on a fresh machine/container the index is empty or stale and `apt-get install` fails with "Unable to locate package".
func (*Apt) SetVerbose ¶ added in v0.5.0
SetVerbose toggles live output streaming when the backend runs on the real ExecRunner.
type Backend ¶
type Backend interface {
// Present installs the given packages if not already present.
Present(ctx context.Context, pkgs []string) error
// Absent removes the given packages.
Absent(ctx context.Context, pkgs []string) error
// IsInstalled reports whether a package is already installed.
IsInstalled(ctx context.Context, pkg string) (bool, error)
// DirectDeps returns the names of pkg's direct runtime dependencies.
DirectDeps(ctx context.Context, pkg string) ([]string, error)
// Installed returns the names of ALL installed packages (one list
// query). Powers regex entries in when.packages: a pattern like
// "apollo.*" cannot be answered by IsInstalled(name). An error means
// the list is unavailable — callers fail the filter open.
Installed(ctx context.Context) ([]string, error)
}
Backend performs package operations.
type Dnf ¶
type Dnf struct {
Runner Runner
}
Dnf is the Fedora/RHEL backend skeleton.
func (*Dnf) DirectDeps ¶ added in v0.9.0
DirectDeps returns pkg's direct runtime dependencies via `dnf repoquery --requires --resolve` (--resolve turns capabilities into provider package names; --qf prints bare names).
func (*Dnf) IsInstalled ¶
IsInstalled checks if a package is installed via rpm.
func (*Dnf) SetVerbose ¶ added in v0.5.0
SetVerbose toggles live output streaming when the backend runs on the real ExecRunner.
type ExecRunner ¶
type ExecRunner struct {
Verbose bool
// Out/Err are the Verbose streaming destinations; nil defaults to
// os.Stdout/os.Stderr.
Out io.Writer
Err io.Writer
}
ExecRunner is the real command runner. Run always captures stdout and discards it (probe path). Verbose streams child stdout/stderr live to Out/Err on the streaming entry point (RunStream) used by install/remove, echoing each command line set -x-style ("+ argv") to Err before it runs; probes via Run stay captured and unechoed either way.
func (ExecRunner) RunStream ¶ added in v0.5.0
RunStream runs like Run but streams the child's stdout/stderr live to Out/Err when Verbose is set OR both destinations are terminals (interactive apply), wiring the child's fds straight to them so it keeps its own color output. Under Verbose the command line is echoed set -x-style ("+ argv") to Err before execution; the interactive default omits that trace. Streaming returns no captured output (the terminal already shows it); a non-verbose, piped run captures via Run instead.
type PackageDeps ¶ added in v0.9.0
type PackageDeps struct {
Name string
Deps []PackageDeps
Unknown bool
}
PackageDeps is one node of a dependency tree. Unknown marks a package whose dependency query failed (e.g. unknown/AUR-less package).
func DepsTree ¶ added in v0.9.0
DepsTree builds the dependency tree for pkgs, recursing depth levels (depth 1 = direct dependencies only). Each unique package is queried at most once. Dependency cycles (pacman has real ones, e.g. harfbuzz ↔ freetype2) terminate by rendering the repeated package as a bare leaf. A failed query never aborts the walk: the node is marked Unknown and a warning is logged.
type Paru ¶
type Paru struct {
Runner Runner
}
Paru is the Arch/CachyOS backend.
func (*Paru) DirectDeps ¶ added in v0.9.0
DirectDeps returns pkg's direct runtime dependencies via `paru -Si` (paru, not pacman: `paru -Si` also covers AUR packages, consistent with Present using paru).
func (*Paru) Installed ¶ added in v0.22.0
Installed lists every installed package name via `pacman -Qq`.
func (*Paru) IsInstalled ¶
IsInstalled checks if a package is installed via pacman. The `aur/` AUR marker and `manager:` colon prefix are stripped (see pacmanName).
func (*Paru) SetVerbose ¶ added in v0.5.0
SetVerbose toggles live output streaming when the backend runs on the real ExecRunner.