Skip to content

fedrq.backends.libdnf5.backend

This module contains a fedrq backend (i.e. an implementation of the fedrq.backends.base.BackendMod interface) that uses the libdnf5 Python bindings.

Classes:

Functions:

Attributes:

BACKEND module-attribute

BACKEND = 'libdnf5'

Name of the backend

RepoError module-attribute

RepoError = RuntimeError

Error when loading repositories

BaseMaker

BaseMaker(
    base: Base | None = None,
    *,
    initialized: bool = False,
    config_loaded: bool = False
)

Bases: BaseMakerBase

Create a Base object and load repos

Initialize and configure the base object.

Parameters:

  • base (Base | None, default: None ) –

    Pass in a libdnf.base.Base object to configure instead of creating a new one.

  • initialized (bool, default: False ) –

    Set to True if base.setup() has already been called. Only applies when base is passed.

  • config_loaded (bool, default: False ) –

    Set to True if base.load_config_from_file() has already been called. Only applies when base is passed.

Methods:

  • create_repo

    Add a Repo object to the repo sack and configure it.

  • disable_repo

    Disable a repo by its id.

  • enable_repo

    Enable a repo by its id.

  • enable_repos

    Enable a list of repositories by their repoid.

  • enable_source_repos

    Enable the corresponding -source repos of the currently enabled

  • fill_sack

    Fill the sack and returns the Base object.

  • load_changelogs

    Load changelog metadata

  • load_filelists

    Load the filelists if they’re not already enabled by default

  • load_release_repos

    Load the repositories from a fedrq.config.Release object

  • read_repofile

    Load repositories from a repo file

  • read_system_repos

    Load system repositories into the base object.

  • repolist

    List available repoids.

  • set

    Set configuration options. Must be called before reading repos.

  • set_var

    Set substitutions (e.g. arch, basearch, releasever).

  • sets

    Set options on the base object

  • setup

Attributes:

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def __init__(
    self,
    base: libdnf5.base.Base | None = None,
    *,
    initialized: bool = False,
    config_loaded: bool = False,
) -> None:
    """
    Initialize and configure the base object.

    Args:
        base:
            Pass in a [`libdnf.base.Base`][libdnf5.base.Base] object to
            configure instead of creating a new one.
        initialized:
            Set to True if `base.setup()` has already been called. Only
            applies when `base` is passed.
        config_loaded:
            Set to True if base.load_config_from_file() has already been
            called. Only applies when `base` is passed.
    """
    self.base = base or libdnf5.base.Base()
    self.initialized = initialized if base else False
    if not base or not config_loaded:
        # dnf 5.2.0
        try:
            self.base.load_config()
        except AttributeError:
            self.base.load_config_from_file()

backend property

backend: BackendMod

Return fedrq.backends.libdnf5.backend module

base instance-attribute

base: Base = base or Base()

The underlying dnf.base object

conf property

conf: ConfigMain

Return libdnf5 config object.

config property

config: ConfigMain

DEPRECATED: use conf property instead

initialized instance-attribute

initialized: bool = initialized if base else False

INTERNAL: Whether the base object has been initialized

rs property

rs: RepoSackWeakPtr

Return libdnf5 RepoSack object. Not part of the BaseMakerBase interface!

vars property

vars: Vars

Return libdnf5 Vars object. Not part of the BaseMakerBase interface!

create_repo

create_repo(repoid: str, **kwargs: Any) -> None

Add a Repo object to the repo sack and configure it.

Parameters:

  • kwargs (Any, default: {} ) –

    key-values options that should be set on the Repo object values (like $basearch) will be substituted automatically.

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def create_repo(self, repoid: str, **kwargs: t.Any) -> None:
    """
    Add a Repo object to the repo sack and configure it.

    Args:
        kwargs:
            key-values options that should be set on the Repo object values
            (like $basearch) will be substituted automatically.
    """
    repo = self.rs.create_repo(repoid)
    config = repo.get_config()
    for key, value in kwargs.items():
        value = self._substitute(value)
        self._set(config, key, value)

disable_repo

disable_repo(
    repo: str, ignore_missing: bool = True
) -> None

Disable a repo by its id. Raise a ValueError if the repoid is not in self.base’s configuration when ignore_missing is False.

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def disable_repo(self, repo: str, ignore_missing: bool = True) -> None:
    """
    Disable a repo by its id.
    Raise a ValueError if the repoid is not in `self.base`'s configuration
    when ignore_missing is False.
    """
    repoq = libdnf5.repo.RepoQuery(self.base)
    repoq.filter_id(repo, libdnf5.common.QueryCmp_GLOB)
    if not ignore_missing and not repoq:
        raise ValueError(f"{repo} repo definition was not found.")
    for result in repoq:
        result.disable()  # type: ignore

enable_repo

enable_repo(repo: str) -> None

Enable a repo by its id. Raise a ValueError if the repoid is not in self.base’s configuration.

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def enable_repo(self, repo: str) -> None:
    """
    Enable a repo by its id.
    Raise a ValueError if the repoid is not in `self.base`'s configuration.
    """
    repoq = libdnf5.repo.RepoQuery(self.base)
    repoq.filter_id(repo, libdnf5.common.QueryCmp_GLOB)
    if not repoq:
        raise ValueError(f"{repo} repo definition was not found.")
    for result in repoq:
        result.enable()  # type: ignore

enable_repos

enable_repos(repos: Collection[str]) -> None

Enable a list of repositories by their repoid. Raise a ValueError if the repoid is not in self.base’s configuration.

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def enable_repos(self, repos: Collection[str]) -> None:
    """
    Enable a list of repositories by their repoid.
    Raise a ValueError if the repoid is not in `self.base`'s configuration.
    """
    for repo in repos:
        self.enable_repo(repo)

enable_source_repos

enable_source_repos() -> None

Enable the corresponding -source repos of the currently enabled repositories

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def enable_source_repos(self) -> None:
    self.rs.enable_source_repos()

fill_sack

fill_sack(
    *,
    from_cache: bool = False,
    load_system_repo: bool = False
) -> libdnf5.base.Base

Fill the sack and returns the Base object. The repository configuration shouldn’t be manipulated after this.

Note that the _cachedir arg is private and subject to removal.

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def fill_sack(
    self,
    *,
    from_cache: bool = False,
    load_system_repo: bool = False,
) -> libdnf5.base.Base:
    """
    Fill the sack and returns the Base object.
    The repository configuration shouldn't be manipulated after this.

    Note that the `_cachedir` arg is private and subject to removal.
    """
    if from_cache:
        raise NotImplementedError
    try:
        self.rs.load_repos(  # pyright: ignore[reportAttributeAccessIssue]
            libdnf5.repo.Repo.Type_SYSTEM
            if load_system_repo
            else libdnf5.repo.Repo.Type_AVAILABLE
        )
    except AttributeError:
        self.rs.update_and_load_enabled_repos(
            load_system_repo
        )  # pyright: ignore[reportAttributeAccessIssue]
    return self.base

load_changelogs

load_changelogs(enable: bool = True) -> None

Load changelog metadata

Parameters:

  • enable (bool, default: True ) –

    Whether to enable or disable filelists

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def load_changelogs(self, enable: bool = True) -> None:
    self._add_metadata_type(libdnf5.conf.METADATA_TYPE_OTHER, enable)

load_filelists

load_filelists(enable: bool = True) -> None

Load the filelists if they’re not already enabled by default

Parameters:

  • enable (bool, default: True ) –

    Whether to enable or disable filelists

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def load_filelists(self, enable: bool = True) -> None:
    self._add_metadata_type(libdnf5.conf.METADATA_TYPE_FILELISTS, enable)

load_release_repos

load_release_repos(
    release: Release, set_releasever: bool = True
) -> None

Load the repositories from a fedrq.config.Release object

Parameters:

  • release (Release) –

    Release object

  • set_releasever (bool, default: True ) –

    Whether to set the $releasever based on the release or just leave it alone

Source code in src/fedrq/backends/base/__init__.py
def load_release_repos(self, release: Release, set_releasever: bool = True) -> None:
    """
    Load the repositories from a fedrq.config.Release object

    Args:
        release:
            [`Release`][fedrq.config.Release] object
        set_releasever:
            Whether to set the `$releasever` based on the release or just
            leave it alone
    """
    if set_releasever:
        self.set_var("releasever", release.version)
    if release.release_config.system_repos:
        self.read_system_repos(
            disable=not (
                release.repo_name in {"@base", "base"}
                and release.release_config.append_system_repos
            )
        )
    for path in release.release_config.full_def_paths:
        with importlib.resources.as_file(path) as fp:
            LOG.debug("Reading %s", fp)
            self._read_repofile_new(fp)
    release.repog.load(self, release.config, release)

read_repofile

read_repofile(file: StrPath) -> None

Load repositories from a repo file

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def read_repofile(self, file: StrPath) -> None:
    """
    Load repositories from a repo file
    """
    self.rs.create_repos_from_file(str(file))

read_system_repos

read_system_repos(disable: bool = True) -> None

Load system repositories into the base object. By default, they are all disabled even if ‘enabled=1’ is in the repository configuration.

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def read_system_repos(self, disable: bool = True) -> None:
    """
    Load system repositories into the base object.
    By default, they are all disabled even if 'enabled=1' is in the
    repository configuration.
    """
    self.rs.create_repos_from_system_configuration()
    if disable:
        repoq = libdnf5.repo.RepoQuery(self.base)
        repoq.filter_enabled(True)
        for repo in repoq:
            repo.disable()

repolist

repolist(enabled: bool | None = None) -> list[str]

List available repoids.

Parameters:

  • enabled (bool | None, default: None ) –

    Only show enabled repositories

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def repolist(self, enabled: bool | None = None) -> list[str]:
    repoq = libdnf5.repo.RepoQuery(self.base)
    if enabled is not None:
        repoq.filter_enabled(enabled)
    return [r.get_id() for r in repoq]

set

set(key: str, value: Any) -> None

Set configuration options. Must be called before reading repos.

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def set(self, key: str, value: t.Any) -> None:
    # if self.initialized:
    #     raise RuntimeError("The base object has already been initialized")
    LOG.debug("Setting config option %s=%r", key, value)
    self._set(self.conf, key, value)

set_var

set_var(key: str, value: Any) -> None

Set substitutions (e.g. arch, basearch, releasever). Needs to be called before reading repos.

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def set_var(self, key: str, value: t.Any) -> None:
    self.vars.set(key, value)

sets

sets(
    conf: dict[str, Any], substitutions: dict[str, Any]
) -> None

Set options on the base object

Parameters:

  • conf (dict[str, Any]) –

    A dict of configuration options. Call self.set() for each k-v pair.

  • substitutions (dict[str, Any]) –

    A dict of substitutions/vars options. Call self.set_var() for each k-v pair.

Source code in src/fedrq/backends/base/__init__.py
def sets(self, conf: dict[str, Any], substitutions: dict[str, Any]) -> None:
    """
    Set options on the base object

    Args:
        conf:
            A dict of configuration options. Call self.set() for each k-v
            pair.
        substitutions:
            A dict of substitutions/vars options. Call self.set_var() for
            each k-v pair.
    """
    for opt in conf.items():
        self.set(*opt)
    for opt in substitutions.items():
        self.set_var(*opt)

setup

setup() -> None
Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def setup(self) -> None:
    if not self.initialized:
        self.base.setup()
        self.initialized = True

Package

Bases: Package, PackageCompat

libdnf5.rpm.Package subclass with strong dnf.package.Package compatability

Methods:

Attributes:

DEBUGINFO_SUFFIX class-attribute instance-attribute

DEBUGINFO_SUFFIX = '-debuginfo'

DEBUGSOURCE_SUFFIX class-attribute instance-attribute

DEBUGSOURCE_SUFFIX = '-debugsource'

a property

a: str

arch property

arch: str

buildtime property

buildtime: int

conflicts property

conflicts: Iterable[Reldep5]

debug_name property

debug_name: str

description property

description: str

downloadsize property

downloadsize: int

e property

e: int

enhances property

enhances: Iterable[Reldep5]

epoch property

epoch: int

evr property

evr: str

files property

files: Iterable[str]

from_repo property

from_repo: str

installsize property

installsize: int

installtime property

installtime: int

license property

license: str

location property

location: str

name property

name: str

obsoletes property

obsoletes: Iterable[Reldep5]

packager property

packager: str

provides property

provides: Iterable[Reldep5]

r property

r: str

reason property

reason: str

recommends property

recommends: Iterable[Reldep5]

release property

release: str

repo property

repo: RepoWeakPtr

Return the package’s Repo object. The exact object depends on which backend is used.

repoid property

repoid: str

reponame property

reponame: str

requires property

requires: Iterable[Reldep5]

size property

size: int

source_debug_name property

source_debug_name: str

source_name property

source_name: Optional[str]

sourcerpm property

sourcerpm: Optional[str]

suggests property

suggests: Iterable[Reldep5]

summary property

summary: str

supplements property

supplements: Iterable[Reldep5]

url property

url: str

v property

v: str

vendor property

vendor: str

version property

version: str

remote_location

remote_location(
    schemes: Collection[str] | None = (
        "http",
        "ftp",
        "file",
        "https",
    )
) -> str | None
Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def remote_location(
    self, schemes: Collection[str] | None = ("http", "ftp", "file", "https")
) -> str | None:
    location = self.location
    if not location:  # pragma: no cover
        return None
    repo_obj = self.repo
    mirrors = repo_obj.get_mirrors() or repo_obj.get_config().baseurl
    if not mirrors:  # pragma: no cover
        return None

    for url in mirrors:
        if not schemes:
            return path_join(url, location)
        scheme = urlparse(url).scheme
        if scheme in schemes:
            return path_join(url, location)
    return None

PackageQuery

Bases: PackageQuery, PackageQueryCompat[Package]

Subclass of libdnf5.rpm.PackageQuery with dnf.query.Query compatability

Methods:

  • difference

    Return the difference between self and other

  • filter

    Filter the PackageQuery.

  • filter_pkg
  • filterm

    Filter the PackageQuery in place and return ‘self’.

  • intersection

    Return the difference between self and other

  • union

    Combine two PackageQuery objects.

difference

difference(other) -> PackageQuery

Return the difference between self and other (packages that are in self but not other). Depending on the backend, this either modifies ‘self’ in place and returns ‘self’ or returns a new PackageQuery object.

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def difference(self, other) -> PackageQuery:
    libdnf5.rpm.PackageQuery.difference(self, other)
    return self

filter

filter(
    **kwargs: Unpack[_QueryFilterKwargs],
) -> PackageQuery

Filter the PackageQuery. Depending on the backend, this either modifies ‘self’ in place and return ‘self’ or return a new PackageQuery object. See https://dnf.readthedocs.io/en/latest/api_queries.html#dnf.query.Query.filter for the allowed kwargs.

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def filter(  # type: ignore[override]
    self,
    **kwargs: Unpack[_QueryFilterKwargs],
) -> PackageQuery:
    self._filter(**kwargs)
    return self

filter_pkg

filter_pkg(
    pkgs: Iterable[Package],
    comp: _PkgCompsType = libdnf5.common.QueryCmp_EQ,
)
Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def filter_pkg(
    self,
    pkgs: Iterable[libdnf5.rpm.Package],
    comp: _PkgCompsType = libdnf5.common.QueryCmp_EQ,
    /,
):
    if isinstance(pkgs, (libdnf5.rpm.PackageSet, libdnf5.rpm.PackageQuery)):
        newquery = pkgs
    else:
        if hasattr(self, "__rq__"):  # noqa SIM108
            base = self.__rq__.base
        else:
            base = self.get_base()
        newquery = libdnf5.rpm.PackageSet(base)
        newquery.clear()
        for p in pkgs:
            newquery.add(p)
    if comp == libdnf5.common.QueryCmp_EQ:
        self.intersection(newquery)
    elif comp == libdnf5.common.QueryCmp_NEQ:
        self.difference(newquery)
    else:
        raise ValueError()

filterm

filterm(
    **kwargs: Unpack[_QueryFilterKwargs],
) -> PackageQuery

Filter the PackageQuery in place and return ‘self’. See https://dnf.readthedocs.io/en/latest/api_queries.html#dnf.query.Query.filter for the allowed kwargs.

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def filterm(  # type: ignore[override]
    self,
    **kwargs: Unpack[_QueryFilterKwargs],
) -> PackageQuery:
    self._filter(**kwargs)
    return self

intersection

intersection(other) -> PackageQuery

Return the difference between self and other (packages that are in both self and other). Depending on the backend, this either modifies ‘self’ in place and returns ‘self’ or returns a new PackageQuery object.

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def intersection(self, other) -> PackageQuery:
    libdnf5.rpm.PackageQuery.intersection(self, other)
    return self

union

union(other) -> PackageQuery

Combine two PackageQuery objects. Depending on the backend, this either modifies ‘self’ in place and returns ‘self’ or returns a new PackageQuery object.

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def union(self, other) -> PackageQuery:
    self.update(other)
    return self

Repoquery

Repoquery(base: Base)

Bases: RepoqueryBase[Package, PackageQuery]

Helpers to query a repository. Provides a unified repoquery interface for different backends.

Methods:

  • arch_filter

    Filter a query’s architectures and return it.

  • arch_filterm

    Filter a query’s architectures in place and return it.

  • get_package

    Return the latest Package that matches the ‘name’ and ‘arch’.

  • get_subpackages

    Return a PackageQuery containing the binary RPMS/subpackages produced

  • query

    Return an inital PackageQuery that’s filtered with **kwargs.

  • resolve_pkg_specs

    Resolve pkg specs.

Attributes:

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def __init__(self, base: libdnf5.base.Base) -> None:
    self.base: libdnf5.base.Base = base

backend property

backend: BackendMod

Return fedrq.backends.libdnf5.backend module

base instance-attribute

base: Base = base

base_arches property

base_arches: set[str]

Return a set of the system’s arch and basearch.

arch_filter

arch_filter(
    query: _PackageQueryT,
    arch: str | Iterable[str] | None = None,
) -> _PackageQueryT

Filter a query’s architectures and return it. It includes a little more functionality than query.filter(arch=…).

  • When arch is None, the query is left untouched.
  • If arch equals ‘notsrc’, all src and multilib packages are excluded.
  • If arch equals ‘arched’, all noarch, multilib, and source packages are excluded.
  • Otherwise, arch is passed to query.filterm(arch=…) and no other validation is preformed.
Source code in src/fedrq/backends/base/__init__.py
def arch_filter(
    self: RepoqueryBase[PackageCompat, _PackageQueryT],
    query: _PackageQueryT,
    arch: str | Iterable[str] | None = None,
) -> _PackageQueryT:
    """
    Filter a query's architectures and return it.
    It includes a little more functionality than query.filter(arch=...).

    - When arch is None, the query is left untouched.
    - If arch equals 'notsrc', all src and multilib packages are
      excluded.
    - If arch equals 'arched', all noarch, multilib, and source
      packages are excluded.
    - Otherwise, arch is passed to query.filterm(arch=...) and no other
      validation is preformed.
    """
    if not arch:
        return query
    if arch == "notsrc":
        return query.filter(arch=(*self.base_arches, "noarch"))  # type: ignore
    if arch == "arched":
        return query.filter(arch=list(self.base_arches))
    return query.filter(arch=arch)

arch_filterm

arch_filterm(
    query: _PackageQueryT,
    arch: str | Iterable[str] | None = None,
) -> _PackageQueryT

Filter a query’s architectures in place and return it. It includes a little more functionality than query.filterm(arch=…).

  • When arch is None, the query is left untouched.
  • If arch equals ‘notsrc’, all src and multilib packages are excluded.
  • If arch equals ‘arched’, all noarch, multilib, and source packages are excluded.
  • Otherwise, arch is passed to query.filterm(arch=…) and no other validation is preformed.
Source code in src/fedrq/backends/base/__init__.py
def arch_filterm(
    self: RepoqueryBase[PackageCompat, _PackageQueryT],
    query: _PackageQueryT,
    arch: str | Iterable[str] | None = None,
) -> _PackageQueryT:
    """
    Filter a query's architectures in place and return it.
    It includes a little more functionality than query.filterm(arch=...).

    - When arch is None, the query is left untouched.
    - If arch equals 'notsrc', all src and multilib packages are
      excluded.
    - If arch equals 'arched', all noarch, multilib, and source
      packages are excluded.
    - Otherwise, arch is passed to query.filterm(arch=...) and no other
      validation is preformed.
    """
    if not arch:
        return query
    if arch == "notsrc":
        return query.filterm(arch=(*self.base_arches, "noarch"))  # type: ignore
    elif arch == "arched":
        return query.filterm(arch=self.base.conf.basearch)
    else:
        return query.filterm(arch=arch)

get_package

get_package(
    name: str, arch: str | Iterable[str] | None = None
) -> _PackageT_co

Return the latest Package that matches the ‘name’ and ‘arch’. A ValueError is raised when no matches are found.

Source code in src/fedrq/backends/base/__init__.py
def get_package(
    self,
    name: str,
    arch: str | Iterable[str] | None = None,
) -> _PackageT_co:
    """
    Return the latest Package that matches the 'name' and 'arch'.
    A ValueError is raised when no matches are found.
    """
    query = self.query(name=name, arch=arch, latest=1)
    if len(query) < 1:
        raise ValueError(f"Zero packages found for {name} on {arch}")
    return cast("_PackageT_co", next(iter(query)))

get_subpackages

get_subpackages(
    packages: Iterable[_PackageT], **kwargs
) -> _PackageQueryT

Return a PackageQuery containing the binary RPMS/subpackages produced by {packages}.

Parameters:

  • packages (Iterable[_PackageT]) –

    An interable of PackageCompat containing source packages

Source code in src/fedrq/backends/base/__init__.py
def get_subpackages(
    self: RepoqueryBase[_PackageT, _PackageQueryT],
    packages: Iterable[_PackageT],
    **kwargs,
) -> _PackageQueryT:
    """
    Return a PackageQuery containing the binary RPMS/subpackages produced
    by {packages}.

    Args:
        packages:
            An interable of `PackageCompat` containing source packages
    """
    arch = kwargs.get("arch")
    if arch == "src":
        raise ValueError("{arch} cannot be 'src'")
    elif not arch:
        kwargs.setdefault("arch__neq", "src")
    if val := kwargs.pop("sourcerpm", None):
        warn(f"Removing invalid kwarg: 'sourcerpm={val}")

    for package in packages:
        if package.arch != "src":
            raise ValueError(f"{package} must be a source package.")

    sourcerpms = [
        f"{package.name}-{package.version}-{package.release}.src.rpm"
        for package in packages
    ]
    query = self.query(sourcerpm=sourcerpms, **kwargs)
    return query

query

query(
    *, arch: str | Iterable[str] | None = None, **kwargs
) -> _PackageQueryT_co

Return an inital PackageQuery that’s filtered with **kwargs. Further filtering can be applied with the PackageQuery’s filter and filterm methods.

Source code in src/fedrq/backends/base/__init__.py
def query(
    self,
    *,
    arch: str | Iterable[str] | None = None,
    **kwargs,
) -> _PackageQueryT_co:
    """
    Return an inital PackageQuery that's filtered with **kwargs.
    Further filtering can be applied with the PackageQuery's filter and
    filterm methods.
    """
    if kwargs.get("latest") is None:
        kwargs.pop("latest", None)
    query = self._query()
    query.filterm(**kwargs)
    self.arch_filterm(query, arch)
    return query

resolve_pkg_specs

resolve_pkg_specs(
    specs: Collection[str],
    resolve: bool = False,
    latest: int | None = None,
    with_src: bool = True,
    *,
    with_filenames: bool | None = None,
    with_provides: bool | None = None,
    resolve_provides: bool | None = None,
    nevra_forms: list[NEVRAForms | int] | None = None
) -> PackageQuery

Resolve pkg specs. See https://dnf.readthedocs.io/en/latest/command_ref.html?highlight=spec#specifying-packages or https://dnf5.readthedocs.io/en/latest/misc/specs.7.html for valid forms.

Parameters:

  • specs (Collection[str]) –

    Package specs to resolve.

  • resolve (bool, default: False ) –

    Whether to resolve file paths or virtual Provides in addition to package specs

  • latest (int | None, default: None ) –

    Limit packages with the same name and arch.

  • with_src (bool, default: True ) –

    Whether to consider .src packages when resolving specs

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
def resolve_pkg_specs(
    self,
    specs: Collection[str],
    resolve: bool = False,
    latest: int | None = None,
    with_src: bool = True,
    *,
    with_filenames: bool | None = None,
    with_provides: bool | None = None,
    resolve_provides: bool | None = None,
    nevra_forms: list[NEVRAForms | int] | None = None,
) -> PackageQuery:
    opts = self._get_resolve_options(
        resolve, with_filenames, with_provides, resolve_provides
    )
    settings = libdnf5.base.ResolveSpecSettings()
    _sc(settings, "with_filenames", opts["with_filenames"])
    _sc(settings, "with_provides", opts["with_provides"])
    _sc(settings, "nevra_forms", libdnf5.rpm.VectorNevraForm())
    if nevra_forms:
        v_nevra_forms = libdnf5.rpm.VectorNevraForm()
        for form in nevra_forms:
            v_nevra_forms.append(form)
        _sc(settings, "nevra_forms", v_nevra_forms)
    r_query = self.query(empty=True)
    for spec in specs:
        query = self._query()
        query.resolve_pkg_spec(spec, settings, with_src)
        r_query.union(query)
    if opts["with_provides"]:
        r_query = r_query.union(self.query(provides=specs))
    if opts["with_filenames"]:
        r_query = r_query.union(self.query(file=specs))
    filter_latest(r_query, latest)
    return r_query

_QueryFilterKwargs

Bases: TypedDict

Keyword-arguments accepted by Repoquery.query.

Attributes:

arch instance-attribute

arch: StrIter

arch__eq instance-attribute

arch__eq: StrIter

arch__glob instance-attribute

arch__glob: StrIter

arch__neq instance-attribute

arch__neq: StrIter

conflicts instance-attribute

conflicts: Union[StrIter, ReldepList, PackageSet]

conflicts__eq instance-attribute

conflicts__eq: Union[StrIter, ReldepList, PackageSet]

conflicts__glob instance-attribute

conflicts__glob: StrIter

conflicts__neq instance-attribute

conflicts__neq: Union[StrIter, ReldepList, PackageSet]

description instance-attribute

description: StrIter

description__contains instance-attribute

description__contains: StrIter

description__eq instance-attribute

description__eq: StrIter

description__glob instance-attribute

description__glob: StrIter

description__neq instance-attribute

description__neq: StrIter

downgrades instance-attribute

downgrades: bool

empty instance-attribute

empty: bool

enhances instance-attribute

enhances: Union[StrIter, ReldepList, PackageSet]

enhances__eq instance-attribute

enhances__eq: Union[StrIter, ReldepList, PackageSet]

enhances__glob instance-attribute

enhances__glob: StrIter

enhances__neq instance-attribute

enhances__neq: Union[StrIter, ReldepList, PackageSet]

epoch instance-attribute

epoch: Union[StrIter, IntIter]

epoch__eq instance-attribute

epoch__eq: Union[StrIter, IntIter]

epoch__glob instance-attribute

epoch__glob: StrIter

epoch__gt instance-attribute

epoch__gt: IntIter

epoch__gte instance-attribute

epoch__gte: IntIter

epoch__lt instance-attribute

epoch__lt: IntIter

epoch__lte instance-attribute

epoch__lte: IntIter

epoch__neq instance-attribute

epoch__neq: Union[StrIter, IntIter]

file instance-attribute

file: StrIter

file__contains instance-attribute

file__contains: StrIter

file__eq instance-attribute

file__eq: StrIter

file__glob instance-attribute

file__glob: StrIter

file__neq instance-attribute

file__neq: StrIter

latest instance-attribute

latest: int

latest_per_arch instance-attribute

latest_per_arch: int

name instance-attribute

name: Union[StrIter, PackageSet]

name__contains instance-attribute

name__contains: StrIter

name__eq instance-attribute

name__eq: Union[StrIter, PackageSet]

name__glob instance-attribute

name__glob: StrIter

name__neq instance-attribute

name__neq: Union[StrIter, PackageSet]

obsoletes instance-attribute

obsoletes: Union[StrIter, ReldepList, PackageSet]

obsoletes__eq instance-attribute

obsoletes__eq: Union[StrIter, ReldepList, PackageSet]

obsoletes__glob instance-attribute

obsoletes__glob: StrIter

obsoletes__neq instance-attribute

obsoletes__neq: Union[StrIter, ReldepList, PackageSet]

pkg instance-attribute

pkg: Iterable[Package]

pkg__eq instance-attribute

pkg__eq: Iterable[Package]

pkg__neq instance-attribute

pkg__neq: Iterable[Package]

provides instance-attribute

provides: Union[StrIter, ReldepList]

provides__eq instance-attribute

provides__eq: Union[StrIter, ReldepList]

provides__glob instance-attribute

provides__glob: StrIter

provides__neq instance-attribute

provides__neq: Union[StrIter, ReldepList]

recommends instance-attribute

recommends: Union[StrIter, ReldepList, PackageSet]

recommends__eq instance-attribute

recommends__eq: Union[StrIter, ReldepList, PackageSet]

recommends__glob instance-attribute

recommends__glob: StrIter

recommends__neq instance-attribute

recommends__neq: Union[StrIter, ReldepList, PackageSet]

release instance-attribute

release: StrIter

release__eq instance-attribute

release__eq: StrIter

release__glob instance-attribute

release__glob: StrIter

release__gt instance-attribute

release__gt: StrIter

release__gte instance-attribute

release__gte: StrIter

release__lt instance-attribute

release__lt: StrIter

release__lte instance-attribute

release__lte: StrIter

release__neq instance-attribute

release__neq: StrIter

reponame instance-attribute

reponame: StrIter

reponame__contains instance-attribute

reponame__contains: StrIter

reponame__eq instance-attribute

reponame__eq: StrIter

reponame__glob instance-attribute

reponame__glob: StrIter

reponame__neq instance-attribute

reponame__neq: StrIter

requires instance-attribute

requires: Union[StrIter, ReldepList, PackageSet]

requires__eq instance-attribute

requires__eq: Union[StrIter, ReldepList, PackageSet]

requires__glob instance-attribute

requires__glob: StrIter

requires__neq instance-attribute

requires__neq: Union[StrIter, ReldepList, PackageSet]

sourcerpm instance-attribute

sourcerpm: StrIter

sourcerpm__eq instance-attribute

sourcerpm__eq: StrIter

sourcerpm__glob instance-attribute

sourcerpm__glob: StrIter

sourcerpm__neq instance-attribute

sourcerpm__neq: StrIter

suggests instance-attribute

suggests: Union[StrIter, ReldepList, PackageSet]

suggests__eq instance-attribute

suggests__eq: Union[StrIter, ReldepList, PackageSet]

suggests__glob instance-attribute

suggests__glob: StrIter

suggests__neq instance-attribute

suggests__neq: Union[StrIter, ReldepList, PackageSet]

summary instance-attribute

summary: StrIter

summary__contains instance-attribute

summary__contains: StrIter

summary__eq instance-attribute

summary__eq: StrIter

summary__glob instance-attribute

summary__glob: StrIter

summary__neq instance-attribute

summary__neq: StrIter

supplements instance-attribute

supplements: Union[StrIter, ReldepList, PackageSet]

supplements__eq instance-attribute

supplements__eq: Union[StrIter, ReldepList, PackageSet]

supplements__glob instance-attribute

supplements__glob: StrIter

supplements__neq instance-attribute

supplements__neq: Union[StrIter, ReldepList, PackageSet]

url instance-attribute

url: StrIter

url__contains instance-attribute

url__contains: StrIter

url__eq instance-attribute

url__eq: StrIter

url__glob instance-attribute

url__glob: StrIter

url__neq instance-attribute

url__neq: StrIter

version instance-attribute

version: StrIter

version__eq instance-attribute

version__eq: StrIter

version__glob instance-attribute

version__glob: StrIter

version__gt instance-attribute

version__gt: StrIter

version__gte instance-attribute

version__gte: StrIter

version__lt instance-attribute

version__lt: StrIter

version__lte instance-attribute

version__lte: StrIter

version__neq instance-attribute

version__neq: StrIter

NEVRAForms

Bases: int, Enum

Enum of NEVRAForms to pass to Repoquery.resolve_pkg_specs

Attributes:

NA class-attribute instance-attribute

NA = Form_NA

NAME class-attribute instance-attribute

NAME = Form_NAME

NEV class-attribute instance-attribute

NEV = Form_NEV

NEVR class-attribute instance-attribute

NEVR = Form_NEVR

NEVRA class-attribute instance-attribute

NEVRA = Form_NEVRA

get_releasever cached

get_releasever() -> str

Return the system releasever

Source code in src/fedrq/backends/libdnf5/backend/__init__.py
@functools.cache
def get_releasever() -> str:
    """
    Return the system releasever
    """
    # Use our copy of dnf4's code for now.
    # For some reason, `detect_release` from libdnf5 is broken in some libdnf5
    # versions and returns an empty string instead of the correct value.
    # Plus, having to create a Base object just for this is expensive.
    # See also the discussion in https://github.com/rpm-software-management/dnf5/pull/1804.
    # libdnf5 is considering breaking this API.
    return _dnf_getreleasever()

See also