depsolvednf

package
v0.244.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: Apache-2.0 Imports: 20 Imported by: 11

Documentation

Overview

Package depsolvednf is an interface to the osbuild-depsolve-dnf Python script that is packaged with the osbuild project. The core component of this package is the Solver type. The Solver can be configured with distribution-specific values (platform ID, architecture, and version information) and provides methods for dependency resolution (Depsolve) and retrieving a full list of repository package metadata (FetchMetadata).

Alternatively, a BaseSolver can be created which represents an un-configured Solver. This type can't be used for depsolving, but can be used to create configured Solver instances sharing the same cache directory.

This package relies on the types defined in rpmmd to describe RPM package metadata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupOldCacheDirs

func CleanupOldCacheDirs(root string, distros []string)

CleanupOldCacheDirs will remove cache directories for unsupported distros eg. Once support for a fedora release stops and it is removed, this will delete its directory under root.

A happy side effect of this is that it will delete old cache directories and files from before the switch to per-distro cache directories.

NOTE: This does not return any errors. This is because the most common one will be a nonexistant directory which will be created later, during initial cache creation. Any other errors like permission issues will be caught by later use of the cache. eg. touchRepo

func NewDNFCache

func NewDNFCache(timeout time.Duration) *dnfCache

NewDNFCache returns a pointer to an initialized dnfCache struct

Types

type BaseSolver

type BaseSolver struct {
	// contains filtered or unexported fields
}

BaseSolver defines the basic solver configuration without platform information. It can be used to create configured Solver instances with the NewWithConfig() method. A BaseSolver maintains the global repository cache directory.

func NewBaseSolver

func NewBaseSolver(cacheDir string) *BaseSolver

Create a new unconfigured BaseSolver (without platform information). It can be used to create configured Solver instances with the NewWithConfig() method.

func (*BaseSolver) CleanCache

func (bs *BaseSolver) CleanCache() error

CleanCache deletes the least recently used repository metadata caches until the total size of the cache falls below the configured maximum size (see SetMaxCacheSize()).

func (*BaseSolver) CleanupOldCacheDirs

func (bs *BaseSolver) CleanupOldCacheDirs(distros []string)

CleanupOldCacheDirs will remove cache directories for unsupported distros eg. Once support for a fedora release stops and it is removed, this will delete its directory under BaseSolver cache root.

A happy side effect of this is that it will delete old cache directories and files from before the switch to per-distro cache directories.

NOTE: This does not return any errors. This is because the most common one will be a nonexistant directory which will be created later, during initial cache creation. Any other errors like permission issues will be caught by later use of the cache. eg. touchRepo

func (*BaseSolver) NewWithConfig

func (bs *BaseSolver) NewWithConfig(modulePlatformID, releaseVer, arch, distro string) *Solver

NewWithConfig initialises a Solver with the platform information and the BaseSolver's subscription info, cache directory, and osbuild-depsolve-dnf path. Also loads system subscription information.

func (*BaseSolver) SetDepsolveDNFPath

func (s *BaseSolver) SetDepsolveDNFPath(cmd string, args ...string)

SetDepsolveDNFPath sets the path to the osbuild-depsolve-dnf binary and optionally any command line arguments.

func (*BaseSolver) SetMaxCacheSize

func (s *BaseSolver) SetMaxCacheSize(size uint64)

SetMaxCacheSize sets the maximum size for the global repository metadata cache. This is the maximum size of the cache after a CleanCache() call. Cache cleanup is never performed automatically.

type DepsolveResult

type DepsolveResult struct {
	// Transactions is a list of package lists, one for each depsolve
	// transaction. Each transaction contains only the packages to be
	// installed that are unique to that transaction. The transaction results
	// are disjoint sets that should be installed in the order they appear in
	// the list.
	Transactions TransactionList
	Modules      []rpmmd.ModuleSpec
	Repos        []rpmmd.RepoConfig
	SBOM         *sbom.Document
	Solver       string
}

DepsolveResult contains the results of a depsolve operation.

type DumpResult added in v0.230.0

type DumpResult struct {
	Packages rpmmd.PackageList
	Repos    []rpmmd.RepoConfig
	Solver   string
}

DumpResult contains the results of a dump operation.

type Error

type Error struct {
	Kind   string `json:"kind"`
	Reason string `json:"reason"`
	Err    error  `json:"-"`
}

osbuild-depsolve-dnf error structure

func (Error) Error

func (err Error) Error() string

func (Error) Unwrap added in v0.240.0

func (err Error) Unwrap() error

type SearchResult added in v0.230.0

type SearchResult struct {
	Packages rpmmd.PackageList
	Repos    []rpmmd.RepoConfig
	Solver   string
}

SearchResult contains the results of a search operation.

type Solver

type Solver struct {
	BaseSolver

	// Stderr is the stderr output from osbuild-depsolve-dnf, if unset os.Stderr
	// will be used.
	//
	// XXX: ideally this would not be public but just passed via
	// NewSolver() but it already has 5 args so ideally we would
	// add a SolverOptions struct here with "CacheDir" and "Stderr"?
	Stderr io.Writer
	// contains filtered or unexported fields
}

Solver is configured with system information in order to resolve dependencies for RPM packages using DNF.

func NewSolver

func NewSolver(modulePlatformID, releaseVer, arch, distro, cacheDir string) *Solver

Create a new Solver with the given configuration. Initialising a Solver also loads system subscription information.

func (*Solver) Depsolve

func (s *Solver) Depsolve(pkgSets []rpmmd.PackageSet, sbomType sbom.StandardType) (*DepsolveResult, error)

Depsolve the list of required package sets with explicit excludes using their associated repositories. Each package set is depsolved as a separate transactions in a chain. It returns a list of all packages (with solved dependencies) that will be installed into the system.

func (*Solver) DepsolveAll added in v0.232.0

func (s *Solver) DepsolveAll(pkgSetsMap map[string][]rpmmd.PackageSet) (map[string]DepsolveResult, error)

DepsolveAll calls Solver.Depsolve with each package set slice in the map and returns a map of results with the corresponding keys as the input argument.

func (*Solver) FetchMetadata

func (s *Solver) FetchMetadata(repos []rpmmd.RepoConfig) (rpmmd.PackageList, error)

FetchMetadata returns the list of all the available packages in repos and their info.

func (*Solver) GetCacheDir

func (s *Solver) GetCacheDir() string

GetCacheDir returns a distro specific rpm cache directory It ensures that the distro name is below the root cache directory, and if there is a problem it returns the root cache instead of an error.

func (*Solver) SearchMetadata

func (s *Solver) SearchMetadata(repos []rpmmd.RepoConfig, packages []string) (rpmmd.PackageList, error)

SearchMetadata searches for packages and returns a list of the info for matches.

func (*Solver) SetProxy

func (s *Solver) SetProxy(proxy string) error

Set the proxy to use while depsolving. The proxy will be set in DNF's base configuration.

func (*Solver) SetRootDir

func (s *Solver) SetRootDir(path string)

SetRootDir sets a path from which repository configurations, gpg keys, and vars are loaded during depsolve, instead of (or in addition to) the repositories and keys included in each depsolve request.

func (*Solver) SetSBOMType added in v0.232.0

func (s *Solver) SetSBOMType(sbomType sbom.StandardType)

Set the SBOM type to generate with the depsolve.

type TransactionFileInfo added in v0.238.0

type TransactionFileInfo struct {
	// Path is the file path that was looked up
	Path string
	// Package that provides the file
	Package *rpmmd.Package
	// TxIndex is the transaction index where the file becomes available
	TxIndex int
}

TransactionFileInfo contains information about a file provided by a package within a transaction list.

type TransactionList added in v0.238.0

type TransactionList []rpmmd.PackageList

TransactionList represents an ordered list of package transactions. Each transaction contains packages that should be installed together in a single RPM stage. Transactions must be installed in order.

func (TransactionList) AllPackages added in v0.238.0

func (t TransactionList) AllPackages() rpmmd.PackageList

AllPackages returns a flat list of all packages across all transactions, sorted by full NEVRA for deterministic ordering.

func (TransactionList) FindPackage added in v0.238.0

func (t TransactionList) FindPackage(name string) (*rpmmd.Package, error)

FindPackage searches for a package by name across all transactions.

func (TransactionList) GetFilesTransactionInfo added in v0.238.0

func (t TransactionList) GetFilesTransactionInfo(paths []string) map[string]TransactionFileInfo

GetFilesTransactionInfo searches for packages that provide any of the given file paths. Returns a map from file path to TransactionFileInfo, containing only the files that were found. Files not provided by any package are not included in the result. If a file is provided by multiple packages, potentially from different transactions, the first occurrence is returned.

Jump to

Keyboard shortcuts

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