Documentation
¶
Overview ¶
Package packages provides package backend operations.
Index ¶
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) 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)
}
Backend performs package operations.
type Dnf ¶
type Dnf struct {
Runner Runner
}
Dnf is the Fedora/RHEL backend skeleton.
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, echoing the command line set -x-style ("+ argv") to Err immediately before execution, and returning no captured output (the terminal already shows it). With Verbose unset it is byte-identical to Run.
type Paru ¶
type Paru struct {
Runner Runner
}
Paru is the Arch/CachyOS backend.
func (*Paru) IsInstalled ¶
IsInstalled checks if a package is installed via pacman.
func (*Paru) SetVerbose ¶ added in v0.5.0
SetVerbose toggles live output streaming when the backend runs on the real ExecRunner.