dnfinstall

package
v2.1.6 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package dnfinstall replaces "dnf install" and "rpm --install" subprocesses.

It resolves transitive package dependencies via dnfcache, downloads RPM files, and extracts them to a target filesystem root. This mirrors the functionality of pkg/aptinstall (for Debian) and pkg/apkindex (for Alpine).

It supports GPG signature verification, scriptlet execution (%pretrans, %pre, %post, %posttrans), and state tracking via yapdb. System rpmdb write is optional.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSignature = errors.New("dnfinstall: invalid signature")

ErrInvalidSignature is returned when a signature is present and well-formed but cryptographically invalid (corrupted data, wrong key material).

View Source
var ErrNoTrustAnchor = errors.New("dnfinstall: no usable trust anchor for RPM verification")

ErrNoTrustAnchor is returned when no usable keyring file can be found for RPM signature verification, or when the available keys do not include the signing key. The caller decides whether to escalate (strict mode) or fall back to the AllowUnverifiedRPMs opt-in.

View Source
var ErrUnknownSigner = errors.New("dnfinstall: signature made by unknown entity")

ErrUnknownSigner is returned when a signature is present but was made by a key not in the trust anchor. This is distinct from a cryptographically invalid signature and is treated the same as ErrNoTrustAnchor for the AllowUnverifiedRPMs opt-in: the RPM hasn't been trusted yet.

View Source
var ErrUnsignedRPM = errors.New("dnfinstall: RPM has no signature")

ErrUnsignedRPM is returned when an RPM has no signature header.

Functions

func Install

func Install(ctx context.Context, names []string) error

Install performs a full dnf install equivalent with default options.

Default policy: when running on a privileged host (uid 0 — the expected case inside a yap build container) `AllowRootInstall` is implicitly enabled. On a developer workstation running as a regular user, the safety guard still trips and refuses to clobber the host filesystem.

Callers needing explicit control (sandboxed RootDir, suppressed ldconfig, etc.) should call InstallWithOptions directly.

func InstallFile

func InstallFile(ctx context.Context, rpmPath string, opts Options) error

InstallFile installs a single local RPM file to the target filesystem. Useful for installing pre-downloaded or custom-built packages.

func InstallWithOptions

func InstallWithOptions(ctx context.Context, names []string, opts Options) error

InstallWithOptions is the explicit-options variant of Install.

Types

type Options

type Options struct {
	RootDir             string
	AllowRootInstall    bool
	AllowUnverifiedRPMs bool
	RunLDConfig         bool
	SkipScriptlets      bool
	StrictScriptlets    bool
	KeyringPath         string
	WriteSystemRpmdb    bool
}

Options controls Install's runtime behaviour.

RootDir is the filesystem root the installation writes into.

  • "" / "/" → install into the live system root. Refused unless AllowRootInstall is true: the typical caller is yap running inside a build container, but on a developer workstation accidentally invoking Install would clobber the host filesystem.
  • Any other value → install into that directory (fakeroot use).

AllowUnverifiedRPMs: RPM packages ship with GPG signatures. Verification of those signatures is not yet wired into this package. Callers that accept this gap (e.g. inside a trusted CI container) must set this flag explicitly.

RunLDConfig defaults to true; set false in fakeroot scenarios where the ld.so.cache would be meaningless.

SkipScriptlets: if true, pre/post install scriptlets are not executed. Useful for fakeroot scenarios where scriptlets may fail or be unnecessary.

KeyringPath: optional override for the GPG keyring directory. Defaults to /etc/pki/rpm-gpg/. Used for signature verification.

WriteSystemRpmdb: if true, ALSO write to /var/lib/rpm/rpmdb.sqlite (SQLite hosts only — Fedora 33+, RHEL 9+, Rocky 9+). Default is false; YAP uses yapdb for state tracking instead. NOTE: writer integration is not yet wired (see install.go writeSystemRpmdb); enabling this currently fails the install rather than silently swallowing the stub error.

StrictScriptlets: if true, %pretrans/%post/%posttrans failures are treated as fatal. RPM convention is non-fatal; this flag is intended for build-time makedepends provisioning where a broken scriptlet poisons later builds.

Jump to

Keyboard shortcuts

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