Documentation
¶
Index ¶
- Constants
- type Apk
- func (p *Apk) AddRepo(name, config string) error
- func (p *Apk) AddRepoKey(ctx context.Context, key string) error
- func (p *Apk) AddRepoKeyFile(ctx context.Context, keyFile string) error
- func (p *Apk) AddRepoKeyURL(ctx context.Context, keyURL string) error
- func (p *Apk) AddRepoURL(ctx context.Context, name, repoURL string) error
- func (p *Apk) Clean(ctx context.Context, args []string) error
- func (p *Apk) Command(ctx context.Context, command string, args ...string) *exec.Cmd
- func (p *Apk) Format() string
- func (p *Apk) GetRepo(name string) string
- func (p *Apk) Info(ctx context.Context, args []string, packages ...string) (string, error)
- func (p *Apk) Install(ctx context.Context, args []string, packages ...string) error
- func (p *Apk) InstallFile(ctx context.Context, args []string, packages ...string) error
- func (p *Apk) ListInstalled(ctx context.Context, args []string) (map[string]string, error)
- func (p *Apk) ListRepos(ctx context.Context, args []string) (map[string]string, error)
- func (p *Apk) ListUpgradable(ctx context.Context, args []string) (map[string]string, error)
- func (p *Apk) Name() string
- func (p *Apk) Path() string
- func (p *Apk) Remove(ctx context.Context, args []string, packages ...string) error
- func (p *Apk) RemoveRepo(name string) error
- func (p *Apk) Search(ctx context.Context, args []string, query string) ([]SearchResult, error)
- func (p *Apk) SetCmdWrapper(wrapper []string)
- func (p *Apk) SetIO(stdin io.Reader, stdout, stderr io.Writer)
- func (p *Apk) Sync(ctx context.Context, args []string) error
- func (p *Apk) Upgrade(ctx context.Context, args []string, packages ...string) error
- func (p *Apk) UpgradeAll(ctx context.Context, args []string) error
- func (p *Apk) UseSudoWhenNeeded()
- type Apt
- func (p *Apt) AddRepo(name, config string) error
- func (p *Apt) AddRepoKey(ctx context.Context, key string) error
- func (p *Apt) AddRepoKeyFile(ctx context.Context, keyFile string) error
- func (p *Apt) AddRepoKeyURL(ctx context.Context, keyURL string) error
- func (p *Apt) AddRepoURL(ctx context.Context, name, repoURL string) error
- func (p *Apt) Clean(ctx context.Context, args []string) error
- func (p *Apt) Format() string
- func (p *Apt) GetRepo(name string) string
- func (p *Apt) Info(ctx context.Context, args []string, packages ...string) (string, error)
- func (p *Apt) Install(ctx context.Context, args []string, packages ...string) error
- func (p *Apt) InstallFile(ctx context.Context, args []string, packages ...string) error
- func (p *Apt) ListInstalled(ctx context.Context, args []string) (map[string]string, error)
- func (p *Apt) ListRepos(ctx context.Context, args []string) (map[string]string, error)
- func (p *Apt) ListUpgradable(ctx context.Context, args []string) (map[string]string, error)
- func (p *Apt) Name() string
- func (p *Apt) Path() string
- func (p *Apt) Remove(ctx context.Context, args []string, packages ...string) error
- func (p *Apt) RemoveRepo(name string) error
- func (p *Apt) Search(ctx context.Context, args []string, query string) ([]SearchResult, error)
- func (p *Apt) Sync(ctx context.Context, args []string) error
- func (p *Apt) Upgrade(ctx context.Context, args []string, packages ...string) error
- func (p *Apt) UpgradeAll(ctx context.Context, args []string) error
- type AptGet
- func (p *AptGet) AddRepo(name, config string) error
- func (p *AptGet) AddRepoKey(ctx context.Context, key string) error
- func (p *AptGet) AddRepoKeyFile(ctx context.Context, keyFile string) error
- func (p *AptGet) AddRepoKeyURL(ctx context.Context, keyURL string) error
- func (p *AptGet) AddRepoURL(ctx context.Context, name, repoURL string) error
- func (p *AptGet) Clean(ctx context.Context, args []string) error
- func (p *AptGet) Format() string
- func (p *AptGet) GetRepo(name string) string
- func (p *AptGet) Info(ctx context.Context, args []string, packages ...string) (string, error)
- func (p *AptGet) Install(ctx context.Context, args []string, packages ...string) error
- func (p *AptGet) InstallFile(ctx context.Context, args []string, packages ...string) error
- func (p *AptGet) ListInstalled(ctx context.Context, args []string) (map[string]string, error)
- func (p *AptGet) ListRepos(ctx context.Context, args []string) (map[string]string, error)
- func (p *AptGet) ListUpgradable(ctx context.Context, args []string) (map[string]string, error)
- func (p *AptGet) Name() string
- func (p *AptGet) Path() string
- func (p *AptGet) Remove(ctx context.Context, args []string, packages ...string) error
- func (p *AptGet) RemoveRepo(name string) error
- func (p *AptGet) Search(ctx context.Context, args []string, query string) ([]SearchResult, error)
- func (p *AptGet) Sync(ctx context.Context, args []string) error
- func (p *AptGet) Upgrade(ctx context.Context, args []string, packages ...string) error
- func (p *AptGet) UpgradeAll(ctx context.Context, args []string) error
- type Brew
- func (p *Brew) AddRepo(name, config string) error
- func (p *Brew) AddRepoKey(ctx context.Context, key string) error
- func (p *Brew) AddRepoKeyFile(ctx context.Context, keyFile string) error
- func (p *Brew) AddRepoKeyURL(ctx context.Context, keyURL string) error
- func (p *Brew) AddRepoURL(ctx context.Context, name, repoURL string) error
- func (p *Brew) Clean(ctx context.Context, args []string) error
- func (p *Brew) Command(ctx context.Context, command string, args ...string) *exec.Cmd
- func (p *Brew) Format() string
- func (p *Brew) GetRepo(name string) string
- func (p *Brew) Info(ctx context.Context, args []string, packages ...string) (string, error)
- func (p *Brew) Install(ctx context.Context, args []string, packages ...string) error
- func (p *Brew) InstallFile(ctx context.Context, args []string, packages ...string) error
- func (p *Brew) ListInstalled(ctx context.Context, args []string) (map[string]string, error)
- func (p *Brew) ListRepos(ctx context.Context, args []string) (map[string]string, error)
- func (p *Brew) ListUpgradable(ctx context.Context, args []string) (map[string]string, error)
- func (p *Brew) Name() string
- func (p *Brew) Path() string
- func (p *Brew) Remove(ctx context.Context, args []string, packages ...string) error
- func (p *Brew) RemoveRepo(name string) error
- func (p *Brew) Search(ctx context.Context, args []string, query string) ([]SearchResult, error)
- func (p *Brew) SetCmdWrapper(wrapper []string)
- func (d *Brew) SetDropUser(user string)
- func (p *Brew) SetIO(stdin io.Reader, stdout, stderr io.Writer)
- func (p *Brew) Sync(ctx context.Context, args []string) error
- func (p *Brew) Upgrade(ctx context.Context, args []string, packages ...string) error
- func (p *Brew) UpgradeAll(ctx context.Context, args []string) error
- func (p *Brew) UseSudoWhenNeeded()
- type Dnf
- func (p *Dnf) AddRepo(name, config string) error
- func (p *Dnf) AddRepoKey(ctx context.Context, key string) error
- func (p *Dnf) AddRepoKeyFile(ctx context.Context, keyFile string) error
- func (p *Dnf) AddRepoKeyURL(ctx context.Context, keyURL string) error
- func (p *Dnf) AddRepoURL(ctx context.Context, name, repoURL string) error
- func (p *Dnf) Clean(ctx context.Context, args []string) error
- func (p *Dnf) Format() string
- func (p *Dnf) GetRepo(name string) string
- func (p *Dnf) Info(ctx context.Context, args []string, packages ...string) (string, error)
- func (p *Dnf) Install(ctx context.Context, args []string, packages ...string) error
- func (p *Dnf) InstallFile(ctx context.Context, args []string, packages ...string) error
- func (p *Dnf) ListInstalled(ctx context.Context, args []string) (map[string]string, error)
- func (p *Dnf) ListRepos(ctx context.Context, args []string) (map[string]string, error)
- func (p *Dnf) ListUpgradable(ctx context.Context, args []string) (map[string]string, error)
- func (p *Dnf) Name() string
- func (p *Dnf) Path() string
- func (p *Dnf) Remove(ctx context.Context, args []string, packages ...string) error
- func (p *Dnf) RemoveRepo(name string) error
- func (p *Dnf) Search(ctx context.Context, args []string, query string) ([]SearchResult, error)
- func (p *Dnf) Sync(ctx context.Context, args []string) error
- func (p *Dnf) Upgrade(ctx context.Context, args []string, packages ...string) error
- func (p *Dnf) UpgradeAll(ctx context.Context, args []string) error
- type Manager
- type Pacman
- func (p *Pacman) AddRepo(name, config string) error
- func (p *Pacman) AddRepoKey(ctx context.Context, key string) error
- func (p *Pacman) AddRepoKeyFile(ctx context.Context, keyFile string) error
- func (p *Pacman) AddRepoKeyURL(ctx context.Context, keyURL string) error
- func (p *Pacman) AddRepoURL(ctx context.Context, name, repoURL string) error
- func (p *Pacman) Clean(ctx context.Context, args []string) error
- func (p *Pacman) Command(ctx context.Context, command string, args ...string) *exec.Cmd
- func (p *Pacman) Format() string
- func (p *Pacman) GetRepo(name string) string
- func (p *Pacman) Info(ctx context.Context, args []string, packages ...string) (string, error)
- func (p *Pacman) Install(ctx context.Context, args []string, packages ...string) error
- func (p *Pacman) InstallFile(ctx context.Context, args []string, packages ...string) error
- func (p *Pacman) ListInstalled(ctx context.Context, args []string) (map[string]string, error)
- func (p *Pacman) ListRepos(ctx context.Context, args []string) (map[string]string, error)
- func (p *Pacman) ListUpgradable(ctx context.Context, args []string) (map[string]string, error)
- func (p *Pacman) Name() string
- func (p *Pacman) Path() string
- func (p *Pacman) Remove(ctx context.Context, args []string, packages ...string) error
- func (p *Pacman) RemoveRepo(name string) error
- func (p *Pacman) Search(ctx context.Context, args []string, query string) ([]SearchResult, error)
- func (p *Pacman) SetCmdWrapper(wrapper []string)
- func (p *Pacman) SetIO(stdin io.Reader, stdout, stderr io.Writer)
- func (p *Pacman) Sync(ctx context.Context, args []string) error
- func (p *Pacman) Upgrade(ctx context.Context, args []string, packages ...string) error
- func (p *Pacman) UpgradeAll(ctx context.Context, args []string) error
- func (p *Pacman) UseSudoWhenNeeded()
- type Paru
- func (p *Paru) Clean(ctx context.Context, args []string) error
- func (p *Paru) Info(ctx context.Context, args []string, packages ...string) (string, error)
- func (p *Paru) Install(ctx context.Context, args []string, packages ...string) error
- func (p *Paru) InstallFile(ctx context.Context, args []string, packages ...string) error
- func (p *Paru) ListUpgradable(ctx context.Context, args []string) (map[string]string, error)
- func (p *Paru) Name() string
- func (p *Paru) Path() string
- func (p *Paru) Remove(ctx context.Context, args []string, packages ...string) error
- func (p *Paru) Search(ctx context.Context, args []string, query string) ([]SearchResult, error)
- func (p *Paru) Sync(ctx context.Context, args []string) error
- func (p *Paru) Upgrade(ctx context.Context, args []string, packages ...string) error
- func (p *Paru) UpgradeAll(ctx context.Context, args []string) error
- type SearchResult
- type Yay
- func (p *Yay) Clean(ctx context.Context, args []string) error
- func (p *Yay) Info(ctx context.Context, args []string, packages ...string) (string, error)
- func (p *Yay) Install(ctx context.Context, args []string, packages ...string) error
- func (p *Yay) InstallFile(ctx context.Context, args []string, packages ...string) error
- func (p *Yay) ListUpgradable(ctx context.Context, args []string) (map[string]string, error)
- func (p *Yay) Name() string
- func (p *Yay) Path() string
- func (p *Yay) Remove(ctx context.Context, args []string, packages ...string) error
- func (p *Yay) Search(ctx context.Context, args []string, query string) ([]SearchResult, error)
- func (p *Yay) Sync(ctx context.Context, args []string) error
- func (p *Yay) Upgrade(ctx context.Context, args []string, packages ...string) error
- func (p *Yay) UpgradeAll(ctx context.Context, args []string) error
- type Yum
- func (p *Yum) AddRepo(name, config string) error
- func (p *Yum) AddRepoKey(ctx context.Context, key string) error
- func (p *Yum) AddRepoKeyFile(ctx context.Context, keyFile string) error
- func (p *Yum) AddRepoKeyURL(ctx context.Context, keyURL string) error
- func (p *Yum) AddRepoURL(ctx context.Context, name, repoURL string) error
- func (p *Yum) Clean(ctx context.Context, args []string) error
- func (p *Yum) Format() string
- func (p *Yum) GetRepo(name string) string
- func (p *Yum) Info(ctx context.Context, args []string, packages ...string) (string, error)
- func (p *Yum) Install(ctx context.Context, args []string, packages ...string) error
- func (p *Yum) InstallFile(ctx context.Context, args []string, packages ...string) error
- func (p *Yum) ListInstalled(ctx context.Context, args []string) (map[string]string, error)
- func (p *Yum) ListRepos(ctx context.Context, args []string) (map[string]string, error)
- func (p *Yum) ListUpgradable(ctx context.Context, args []string) (map[string]string, error)
- func (p *Yum) Name() string
- func (p *Yum) Path() string
- func (p *Yum) Remove(ctx context.Context, args []string, packages ...string) error
- func (p *Yum) RemoveRepo(name string) error
- func (p *Yum) Search(ctx context.Context, args []string, query string) ([]SearchResult, error)
- func (p *Yum) Sync(ctx context.Context, args []string) error
- func (p *Yum) Upgrade(ctx context.Context, args []string, packages ...string) error
- func (p *Yum) UpgradeAll(ctx context.Context, args []string) error
- type Zypper
- func (p *Zypper) AddRepo(name, config string) error
- func (p *Zypper) AddRepoKey(ctx context.Context, key string) error
- func (p *Zypper) AddRepoKeyFile(ctx context.Context, keyFile string) error
- func (p *Zypper) AddRepoKeyURL(ctx context.Context, keyURL string) error
- func (p *Zypper) AddRepoURL(ctx context.Context, name, repoURL string) error
- func (p *Zypper) Clean(ctx context.Context, args []string) error
- func (p *Zypper) Format() string
- func (p *Zypper) GetRepo(name string) string
- func (p *Zypper) Info(ctx context.Context, args []string, packages ...string) (string, error)
- func (p *Zypper) Install(ctx context.Context, args []string, packages ...string) error
- func (p *Zypper) InstallFile(ctx context.Context, args []string, packages ...string) error
- func (p *Zypper) ListInstalled(ctx context.Context, args []string) (map[string]string, error)
- func (p *Zypper) ListRepos(ctx context.Context, args []string) (map[string]string, error)
- func (p *Zypper) ListUpgradable(ctx context.Context, args []string) (map[string]string, error)
- func (p *Zypper) Name() string
- func (p *Zypper) Path() string
- func (p *Zypper) Remove(ctx context.Context, args []string, packages ...string) error
- func (p *Zypper) RemoveRepo(name string) error
- func (p *Zypper) Search(ctx context.Context, args []string, query string) ([]SearchResult, error)
- func (p *Zypper) Sync(ctx context.Context, args []string) error
- func (p *Zypper) Upgrade(ctx context.Context, args []string, packages ...string) error
- func (p *Zypper) UpgradeAll(ctx context.Context, args []string) error
Constants ¶
const ( // APK_REPOSITORIES is the single file apk reads its repositories from. // There is no drop-in directory, so named repos are delimited with marker // comments so they can be located and removed later. APK_REPOSITORIES = "/etc/apk/repositories" // APK_KEYS_DIR is where apk reads repo signing keys from. APK_KEYS_DIR = "/etc/apk/keys" )
const ( // APT_SOURCES_DIR is where apt repo files are written. APT_SOURCES_DIR = "/etc/apt/sources.list.d" // APT_KEYRINGS_DIR is where apt repo signing keys are written when apt-key // is unavailable. It is only used as a fallback on modern systems (apt has // removed apt-key), so the armored ".asc" form written here is always read // by the apt that is present. APT_KEYRINGS_DIR = "/etc/apt/trusted.gpg.d" )
const PACMAN_CONF = "/etc/pacman.conf"
PACMAN_CONF is the configuration file pacman reads its repos from. pacman has no drop-in repo directory by default, so repos are managed as [name] sections within this file.
const YUM_REPO_DIR = "/etc/yum.repos.d"
YUM_REPO_DIR is where rpm-based managers (dnf, yum, zypper) write repo files.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Apk ¶
type Apk struct {
// contains filtered or unexported fields
}
func (*Apk) AddRepo ¶
AddRepo adds a repo from a configuration string (one repository URL per line). The lines are stored in APK_REPOSITORIES delimited by markers.
func (*Apk) AddRepoKey ¶
AddRepoKey adds a key for repo package verification.
func (*Apk) AddRepoKeyFile ¶
AddRepoKeyFile adds a key for repo package verification from a file.
func (*Apk) AddRepoKeyURL ¶
AddRepoKeyURL adds a key for repo package verification from a URL.
func (*Apk) AddRepoURL ¶
AddRepoURL adds repoURL as a repository line. apk repositories are plain URLs, so repoURL is used directly rather than downloaded.
func (*Apk) Command ¶
Command builds an *exec.Cmd for the manager, applying the configured command wrapper and I/O streams. The command is bound to ctx for cancellation.
func (*Apk) InstallFile ¶
InstallFile installs a package from a local file.
func (*Apk) ListInstalled ¶
ListInstalled returns installed packages mapped to their version.
func (*Apk) ListRepos ¶
ListRepos returns every named repo section in APK_REPOSITORIES mapped name->configuration. The value matches what GetRepo returns for that name. Plain repository lines that are not enclosed in named markers have no name and so are not included.
func (*Apk) ListUpgradable ¶
ListUpgradable returns packages with an available update mapped to the candidate version.
func (*Apk) RemoveRepo ¶
RemoveRepo removes a repo's lines from APK_REPOSITORIES.
func (*Apk) SetCmdWrapper ¶
func (p *Apk) SetCmdWrapper(wrapper []string)
SetCmdWrapper sets a command wrapper, for example []string{"sudo"}.
func (*Apk) UpgradeAll ¶
UpgradeAll upgrades all packages with available updates.
func (*Apk) UseSudoWhenNeeded ¶
func (p *Apk) UseSudoWhenNeeded()
UseSudoWhenNeeded sets the command wrapper to sudo when the process is not already root, so privileged operations escalate. It is a no-op when running as root. Managers that must not run as root (brew, yay, paru) bypass the wrapper for their own command, so this only affects their privileged pacman-side helpers and the root-required managers.
type Apt ¶
type Apt struct {
// contains filtered or unexported fields
}
func (*Apt) AddRepoKey ¶
AddRepoKey adds a key for repo package verification. apt-key is used when it is present, which keeps older releases (where it is the only supported method) working. On modern systems that have removed apt-key, a drop-in keyring file is written instead.
func (*Apt) AddRepoKeyFile ¶
AddRepoKeyFile adds a key for repo package verification from a file.
func (*Apt) AddRepoKeyURL ¶
AddRepoKeyURL adds a key for repo package verification from a URL.
func (*Apt) AddRepoURL ¶
AddRepoURL adds a repo whose configuration is downloaded from repoURL.
func (*Apt) InstallFile ¶
InstallFile installs a package from a local file.
func (*Apt) ListInstalled ¶
ListInstalled returns installed packages mapped to their version.
func (*Apt) ListRepos ¶
ListRepos returns every repo file in APT_SOURCES_DIR keyed by file stem. The value matches what GetRepo returns for that name. Only the .list drop-in files this manager reads and writes are enumerated; the main sources.list and deb822 .sources files are not included.
func (*Apt) ListUpgradable ¶
ListUpgradable returns packages with an available update mapped to the candidate version. It simulates an upgrade with apt-get, which both apt and apt-get ship, so the listing is consistent and never prompts.
type AptGet ¶
type AptGet struct {
// contains filtered or unexported fields
}
func (*AptGet) AddRepoKey ¶
AddRepoKey adds a key for repo package verification. apt-key is used when it is present, which keeps older releases (where it is the only supported method) working. On modern systems that have removed apt-key, a drop-in keyring file is written instead.
func (*AptGet) AddRepoKeyFile ¶
AddRepoKeyFile adds a key for repo package verification from a file.
func (*AptGet) AddRepoKeyURL ¶
AddRepoKeyURL adds a key for repo package verification from a URL.
func (*AptGet) AddRepoURL ¶
AddRepoURL adds a repo whose configuration is downloaded from repoURL.
func (*AptGet) Info ¶
Info returns detailed information about the named packages. apt-get has no show subcommand, so apt-cache is used.
func (*AptGet) InstallFile ¶
InstallFile installs a package from a local file.
func (*AptGet) ListInstalled ¶
ListInstalled returns installed packages mapped to their version.
func (*AptGet) ListRepos ¶
ListRepos returns every repo file in APT_SOURCES_DIR keyed by file stem. The value matches what GetRepo returns for that name. Only the .list drop-in files this manager reads and writes are enumerated; the main sources.list and deb822 .sources files are not included.
func (*AptGet) ListUpgradable ¶
ListUpgradable returns packages with an available update mapped to the candidate version. It simulates an upgrade with apt-get, which both apt and apt-get ship, so the listing is consistent and never prompts.
func (*AptGet) RemoveRepo ¶
RemoveRepo removes a repo.
func (*AptGet) Search ¶
Search searches the repositories for packages matching query. apt-get has no search subcommand, so apt-cache is used.
type Brew ¶
type Brew struct {
// contains filtered or unexported fields
}
Brew is the Homebrew manager. Homebrew refuses to run as root, so its command is never sudo-wrapped; the embedded dropPrivilege runs it unprivileged and drops to a user via `sudo -u` when the process is root.
func (*Brew) AddRepoKey ¶
AddRepoKey is a no-op: Homebrew verifies downloads itself and has no user-managed signing keyring.
func (*Brew) AddRepoKeyFile ¶
AddRepoKeyFile is a no-op: Homebrew manages verification itself.
func (*Brew) AddRepoKeyURL ¶
AddRepoKeyURL is a no-op: Homebrew manages verification itself.
func (*Brew) AddRepoURL ¶
AddRepoURL adds a repo by tapping name from repoURL.
func (*Brew) Clean ¶
Clean removes stale downloads and old installed versions. brew is run unprivileged since Homebrew must not run as root.
func (*Brew) Command ¶
Command builds an *exec.Cmd for the manager, applying the configured command wrapper and I/O streams. The command is bound to ctx for cancellation.
func (*Brew) Info ¶
Info returns detailed information about the named packages. brew is run unprivileged since Homebrew must not run as root.
func (*Brew) InstallFile ¶
InstallFile installs a package from a local formula or cask file.
func (*Brew) ListInstalled ¶
ListInstalled returns installed packages mapped to their version.
func (*Brew) ListRepos ¶
ListRepos returns every tapped repo mapped name->tap-info. The value for each name matches what GetRepo returns for it. brew is run unprivileged since Homebrew must not run as root.
func (*Brew) ListUpgradable ¶
ListUpgradable returns packages with an available update mapped to the candidate version. brew is run unprivileged since Homebrew must not run as root.
func (*Brew) RemoveRepo ¶
RemoveRepo removes a repo by untapping it.
func (*Brew) Search ¶
Search searches the repositories for packages matching query. brew is run unprivileged since Homebrew must not run as root.
func (*Brew) SetCmdWrapper ¶
func (p *Brew) SetCmdWrapper(wrapper []string)
SetCmdWrapper sets a command wrapper, for example []string{"sudo"}.
func (*Brew) SetDropUser ¶
func (d *Brew) SetDropUser(user string)
SetDropUser sets the unprivileged user the command drops to when the process runs as root. When unset, the SUDO_USER environment variable is used.
func (*Brew) UpgradeAll ¶
UpgradeAll upgrades all packages with available updates.
func (*Brew) UseSudoWhenNeeded ¶
func (p *Brew) UseSudoWhenNeeded()
UseSudoWhenNeeded sets the command wrapper to sudo when the process is not already root, so privileged operations escalate. It is a no-op when running as root. Managers that must not run as root (brew, yay, paru) bypass the wrapper for their own command, so this only affects their privileged pacman-side helpers and the root-required managers.
type Dnf ¶
type Dnf struct {
// contains filtered or unexported fields
}
func (*Dnf) AddRepoKey ¶
AddRepoKey adds a key for repo package verification.
func (*Dnf) AddRepoKeyFile ¶
AddRepoKeyFile adds a key for repo package verification from a file.
func (*Dnf) AddRepoKeyURL ¶
AddRepoKeyURL adds a key for repo package verification from a URL.
func (*Dnf) AddRepoURL ¶
AddRepoURL adds a repo whose configuration is downloaded from repoURL.
func (*Dnf) InstallFile ¶
InstallFile installs a package from a local file.
func (*Dnf) ListInstalled ¶
ListInstalled returns installed packages mapped to their version. It queries rpm directly so the listing is consistent across dnf, yum, and zypper.
func (*Dnf) ListRepos ¶
ListRepos returns every repo file in YUM_REPO_DIR keyed by file stem. The value matches what GetRepo returns for that name.
func (*Dnf) ListUpgradable ¶
ListUpgradable returns packages with an available update mapped to the candidate version.
type Manager ¶
type Manager interface {
// Name is the package manager's name.
Name() string
// Format is the package format the manager installs (deb, rpm, ...).
Format() string
// Path is the resolved path to the manager's command, or "" if missing.
Path() string
// SetCmdWrapper sets a command wrapper, for example []string{"sudo"}.
SetCmdWrapper(wrapper []string)
// UseSudoWhenNeeded wraps privileged commands with sudo when not already
// root. It is a no-op as root, and managers that must not run as root
// (brew, yay, paru) bypass the wrapper for their own command.
UseSudoWhenNeeded()
// SetIO overrides the stdin, stdout, and stderr used by spawned commands.
// Passing nil for a stream restores its os default.
SetIO(stdin io.Reader, stdout, stderr io.Writer)
// AddRepo adds a repo from a configuration string.
AddRepo(name, config string) error
// AddRepoURL adds a repo whose configuration is downloaded from repoURL.
AddRepoURL(ctx context.Context, name, repoURL string) error
// RemoveRepo removes a repo.
RemoveRepo(name string) error
// GetRepo returns a repo's configuration, or "" if it does not exist.
GetRepo(name string) string
// ListRepos returns all configured repos mapped name->configuration. The
// value for each name matches what GetRepo returns for it.
ListRepos(ctx context.Context, args []string) (map[string]string, error)
// AddRepoKey adds a key for repo package verification.
AddRepoKey(ctx context.Context, key string) error
// AddRepoKeyFile adds a key for repo package verification from a file.
AddRepoKeyFile(ctx context.Context, keyFile string) error
// AddRepoKeyURL adds a key for repo package verification from a URL.
AddRepoKeyURL(ctx context.Context, keyURL string) error
// Sync updates repository metadata.
Sync(ctx context.Context, args []string) error
// Install installs packages from the repositories.
Install(ctx context.Context, args []string, packages ...string) error
// Remove removes packages.
Remove(ctx context.Context, args []string, packages ...string) error
// Upgrade upgrades the named packages.
Upgrade(ctx context.Context, args []string, packages ...string) error
// InstallFile installs a package from a local file.
InstallFile(ctx context.Context, args []string, packages ...string) error
// UpgradeAll upgrades all packages with available updates.
UpgradeAll(ctx context.Context, args []string) error
// Clean removes cached package data to reclaim disk space.
Clean(ctx context.Context, args []string) error
// Search searches the repositories for packages matching query and returns
// the matches.
Search(ctx context.Context, args []string, query string) ([]SearchResult, error)
// Info returns detailed information about the named packages as the
// underlying tool's native text output.
Info(ctx context.Context, args []string, packages ...string) (string, error)
// ListInstalled returns installed packages mapped to their version.
ListInstalled(ctx context.Context, args []string) (map[string]string, error)
// ListUpgradable returns packages with an available update mapped to the
// candidate version, without applying the updates.
ListUpgradable(ctx context.Context, args []string) (map[string]string, error)
}
Manager is the interface for working with a system package manager. Methods that run a subprocess or perform network I/O take a context.Context so the caller can apply cancellation and timeouts.
func GetSystemManager ¶
func GetSystemManager() Manager
GetSystemManager finds the system manager with a priority of zypper, dnf, yum, apt, apt-get, pacman, apk, brew. It returns nil when none are found.
type Pacman ¶
type Pacman struct {
// contains filtered or unexported fields
}
func (*Pacman) AddRepoKey ¶
AddRepoKey adds a key for repo package verification.
func (*Pacman) AddRepoKeyFile ¶
AddRepoKeyFile adds a key for repo package verification from a file.
func (*Pacman) AddRepoKeyURL ¶
AddRepoKeyURL adds a key for repo package verification from a URL.
func (*Pacman) AddRepoURL ¶
AddRepoURL adds a repo whose configuration is downloaded from repoURL.
func (*Pacman) Command ¶
Command builds an *exec.Cmd for the manager, applying the configured command wrapper and I/O streams. The command is bound to ctx for cancellation.
func (*Pacman) InstallFile ¶
InstallFile installs a package from a local file.
func (*Pacman) ListInstalled ¶
ListInstalled returns installed packages mapped to their version.
func (*Pacman) ListRepos ¶
ListRepos returns every repository section in PACMAN_CONF mapped name->body. The value matches what GetRepo returns for that name. pacman treats every section other than [options] as a repository, so [options] is excluded.
func (*Pacman) ListUpgradable ¶
ListUpgradable returns packages with an available update mapped to the candidate version.
func (*Pacman) RemoveRepo ¶
RemoveRepo removes a repo's section from PACMAN_CONF.
func (*Pacman) SetCmdWrapper ¶
func (p *Pacman) SetCmdWrapper(wrapper []string)
SetCmdWrapper sets a command wrapper, for example []string{"sudo"}.
func (*Pacman) UpgradeAll ¶
UpgradeAll upgrades all packages with available updates.
func (*Pacman) UseSudoWhenNeeded ¶
func (p *Pacman) UseSudoWhenNeeded()
UseSudoWhenNeeded sets the command wrapper to sudo when the process is not already root, so privileged operations escalate. It is a no-op when running as root. Managers that must not run as root (brew, yay, paru) bypass the wrapper for their own command, so this only affects their privileged pacman-side helpers and the root-required managers.
type Paru ¶
type Paru struct {
// contains filtered or unexported fields
}
Paru is the AUR helper manager backed by the paru command.
func (*Paru) Info ¶
Info returns detailed information about the named packages. It is run unprivileged since the helper refuses to run as root.
func (*Paru) InstallFile ¶
InstallFile installs a package from a local file.
func (*Paru) ListUpgradable ¶
ListUpgradable returns repo and AUR packages with an available update mapped to the candidate version. The helper's `-Qu` covers the AUR, and like pacman it exits 1 when nothing is upgradable, which is treated as an empty result.
func (*Paru) Path ¶
func (p *Paru) Path() string
Path is the resolved path to the helper command, or "" if missing.
func (*Paru) Search ¶
Search searches the repositories and the AUR for packages matching query. The helper is a pacman drop-in, so its output is parsed like pacman's. It is run unprivileged since the helper refuses to run as root.
type SearchResult ¶
SearchResult is a single package match returned by Search. Version and Summary are best-effort: a field is left empty when the underlying tool does not report it in its search output.
type Yay ¶
type Yay struct {
// contains filtered or unexported fields
}
Yay is the AUR helper manager backed by the yay command.
func (*Yay) Info ¶
Info returns detailed information about the named packages. It is run unprivileged since the helper refuses to run as root.
func (*Yay) InstallFile ¶
InstallFile installs a package from a local file.
func (*Yay) ListUpgradable ¶
ListUpgradable returns repo and AUR packages with an available update mapped to the candidate version. The helper's `-Qu` covers the AUR, and like pacman it exits 1 when nothing is upgradable, which is treated as an empty result.
func (*Yay) Path ¶
func (p *Yay) Path() string
Path is the resolved path to the helper command, or "" if missing.
func (*Yay) Search ¶
Search searches the repositories and the AUR for packages matching query. The helper is a pacman drop-in, so its output is parsed like pacman's. It is run unprivileged since the helper refuses to run as root.
type Yum ¶
type Yum struct {
// contains filtered or unexported fields
}
func (*Yum) AddRepoKey ¶
AddRepoKey adds a key for repo package verification.
func (*Yum) AddRepoKeyFile ¶
AddRepoKeyFile adds a key for repo package verification from a file.
func (*Yum) AddRepoKeyURL ¶
AddRepoKeyURL adds a key for repo package verification from a URL.
func (*Yum) AddRepoURL ¶
AddRepoURL adds a repo whose configuration is downloaded from repoURL.
func (*Yum) InstallFile ¶
InstallFile installs a package from a local file.
func (*Yum) ListInstalled ¶
ListInstalled returns installed packages mapped to their version. It queries rpm directly so the listing is consistent across dnf, yum, and zypper.
func (*Yum) ListRepos ¶
ListRepos returns every repo file in YUM_REPO_DIR keyed by file stem. The value matches what GetRepo returns for that name.
func (*Yum) ListUpgradable ¶
ListUpgradable returns packages with an available update mapped to the candidate version.
type Zypper ¶
type Zypper struct {
// contains filtered or unexported fields
}
func (*Zypper) AddRepoKey ¶
AddRepoKey adds a key for repo package verification.
func (*Zypper) AddRepoKeyFile ¶
AddRepoKeyFile adds a key for repo package verification from a file.
func (*Zypper) AddRepoKeyURL ¶
AddRepoKeyURL adds a key for repo package verification from a URL.
func (*Zypper) AddRepoURL ¶
AddRepoURL adds a repo whose configuration is downloaded from repoURL.
func (*Zypper) InstallFile ¶
InstallFile installs a package from a local file.
func (*Zypper) ListInstalled ¶
ListInstalled returns installed packages mapped to their version. It queries rpm directly so the listing is consistent across dnf, yum, and zypper.
func (*Zypper) ListRepos ¶
ListRepos returns every repo file in YUM_REPO_DIR keyed by file stem. The value matches what GetRepo returns for that name.
func (*Zypper) ListUpgradable ¶
ListUpgradable returns packages with an available update mapped to the candidate version.
func (*Zypper) RemoveRepo ¶
RemoveRepo removes a repo.