dnfjson

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: Apache-2.0 Imports: 15 Imported by: 14

Documentation

Overview

Package dnfjson is an interface to the dnf-json Python script that is packaged with the osbuild-composer 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 added in v0.34.0

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 dnf-json path. Also loads system subscription information.

func (*BaseSolver) SetDNFJSONPath

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

SetDNFJSONPath sets the path to the dnf-json 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 Error

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

dnf-json error structure

func ParseError

func ParseError(data []byte) Error

func (Error) Error

func (err Error) Error() string

type PackageSpec

type PackageSpec struct {
	Name           string `json:"name"`
	Epoch          uint   `json:"epoch"`
	Version        string `json:"version,omitempty"`
	Release        string `json:"release,omitempty"`
	Arch           string `json:"arch,omitempty"`
	RepoID         string `json:"repo_id,omitempty"`
	Path           string `json:"path,omitempty"`
	RemoteLocation string `json:"remote_location,omitempty"`
	Checksum       string `json:"checksum,omitempty"`
	Secrets        string `json:"secrets,omitempty"`
}

Package specification

type Request

type Request struct {
	// Command should be either "depsolve" or "dump"
	Command string `json:"command"`

	// Platform ID, e.g., "platform:el8"
	ModulePlatformID string `json:"module_platform_id"`

	// System architecture
	Arch string `json:"arch"`

	// Cache directory for the DNF metadata
	CacheDir string `json:"cachedir"`

	// Arguments for the action defined by Command
	Arguments arguments `json:"arguments"`
}

Request command and arguments for dnf-json

func (*Request) Hash

func (r *Request) Hash() string

Hash returns a hash of the unique aspects of the Request

type Solver

type Solver struct {
	BaseSolver
	// 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) ([]rpmmd.PackageSpec, 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) 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.

Jump to

Keyboard shortcuts

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