meta_package_manager.managers.microdnf module¶

class meta_package_manager.managers.microdnf.MicroDNF[source]¶

Bases: PackageManager

A minimal dnf written in C on top of libdnf, for containers.

The minimal container images of the RHEL family install it instead of dnf: AlmaLinux 10’s lists microdnf and no dnf. On a host that has both, microdnf and dnf read the same RPM database, so their listings overlap.

Note

On Fedora, and on RHEL releases after 10, the dnf5 package takes over the microdnf name as a symlink to dnf5 (dnf5.spec). No microdnf RPM package is installed there, so this manager reports no version and leaves that binary to dnf5.

Caution

microdnf keeps one system-wide cache under /var/cache/yum, and only root can write to it. As a regular user, every query fails while /var/cache/yum/metadata is missing, which is the state clean all leaves. search and outdated also fail once the repository metadata expires, with failed to obtain lock 'metadata'. mpm --microdnf sync runs makecache with sudo to rebuild the cache.

microdnf has no autoremove and no self-check, so mpm offers no orphan operations and no doctor for it. Its leaves command is no substitute: it lists every installed package that nothing else requires, including the packages installed on request.

Initialize cli_errors list.

maintenance_note: str | None = 'Superseded by [dnf5](https://github.com/rpm-software-management/dnf5) on Fedora, and on RHEL releases after 10. The C implementation stays maintained for RHEL 10 and older, whose minimal images ship it; mpm wraps `dnf5` as a separate manager.'¶

A watch note about a still-maintained upstream whose activity is slowing or whose status is ambiguous, as a MyST markdown block.

Unlike unmaintained, this is purely informational: the manager stays in the default selection and in the test matrices. It renders as a {note} admonition atop the manager’s documentation page, flagging upstreams worth keeping an eye on (a slow release cadence, superseded-but-still-shipped tools, a discontinued platform still under vendor support). May embed markdown links. Mutually exclusive with unmaintained: a confirmed-dead manager carries an unmaintained_message instead. Enforced by test_maintenance_note.

name: str = 'microdnf'¶

Return package manager’s common name.

Default value is based on class name.

repository_url: str | None = 'https://github.com/rpm-software-management/microdnf'¶

Repository holding the project’s code, or None when it has no public one.

Linked from the manager’s documentation page. Also what the weekly metrics sample reads: docs/docs_update.py writes it into the [tool.repomatic.metrics] subjects of pyproject.toml when its forge answers the sampler, through a mirror for a forge that does not.

Never inherited, for the same reason as wikipedia_url: the AUR helpers extending pacman each live in a repository of their own.

Slug of the brand mark standing for this manager in the documentation.

Names an SVG vendored under docs/assets/managers/, whose provenance and license are recorded in docs/assets/managers/logos.yaml. Inlined at the top of the manager’s page by meta_package_manager._docs; a manager leaving it unset keeps the page’s default package glyph.

Several managers legitimately share one slug, either because they wrap the same upstream (brew and cask) or because the tool has no mark of its own and its ecosystem’s stands in (apt under Debian’s swirl, cargo under Rust’s gear). Documentation-only, like homepage_url: no CLI output reads it.

platforms: frozenset[Platform] | Group | Platform | Iterable[Platform | Group] = frozenset({Platform(id='almalinux', name='AlmaLinux'), Platform(id='alpine', name='Alpine Linux'), Platform(id='altlinux', name='ALT Linux'), Platform(id='amzn', name='Amazon Linux'), Platform(id='android', name='Android'), Platform(id='arch', name='Arch Linux'), Platform(id='buildroot', name='Buildroot'), Platform(id='cachyos', name='CachyOS'), Platform(id='centos', name='CentOS'), Platform(id='chromeos', name='ChromeOS'), Platform(id='clearlinux', name='Clear Linux OS'), Platform(id='cloudlinux', name='CloudLinux OS'), Platform(id='crux', name='CRUX'), Platform(id='debian', name='Debian'), Platform(id='endeavouros', name='EndeavourOS'), Platform(id='exherbo', name='Exherbo Linux'), Platform(id='fedora', name='Fedora'), Platform(id='generic_linux', name='Generic Linux'), Platform(id='gentoo', name='Gentoo Linux'), Platform(id='guix', name='Guix System'), Platform(id='ibm_powerkvm', name='IBM PowerKVM'), Platform(id='kali', name='Kali Linux'), Platform(id='kvmibm', name='KVM for IBM z Systems'), Platform(id='linuxmint', name='Linux Mint'), Platform(id='mageia', name='Mageia'), Platform(id='mandriva', name='Mandriva Linux'), Platform(id='manjaro', name='Manjaro Linux'), Platform(id='nixos', name='NixOS'), Platform(id='nobara', name='Nobara'), Platform(id='nutyx', name='NuTyX'), Platform(id='opensuse', name='openSUSE'), Platform(id='openwrt', name='OpenWrt'), Platform(id='oracle', name='Oracle Linux'), Platform(id='parallels', name='Parallels'), Platform(id='pidora', name='Pidora'), Platform(id='pikaos', name='PikaOS'), Platform(id='raspbian', name='Raspbian'), Platform(id='rhel', name='RedHat Enterprise Linux'), Platform(id='rocky', name='Rocky Linux'), Platform(id='scientific', name='Scientific Linux'), Platform(id='slackware', name='Slackware'), Platform(id='sles', name='SUSE Linux Enterprise Server'), Platform(id='slitaz', name='SliTaz GNU/Linux'), Platform(id='solus', name='Solus'), Platform(id='sourcemage', name='Source Mage GNU/Linux'), Platform(id='tuxedo', name='Tuxedo OS'), Platform(id='ubuntu', name='Ubuntu'), Platform(id='ultramarine', name='Ultramarine'), Platform(id='void', name='Void Linux'), Platform(id='wsl1', name='Windows Subsystem for Linux v1'), Platform(id='wsl2', name='Windows Subsystem for Linux v2'), Platform(id='xenserver', name='XenServer')})¶

List of platforms supported by the manager.

Allows for a mishmash of platforms and groups of platforms. Will be normalized into a frozenset of Platform instances at instantiation.

default_sudo: bool = True¶

Built-in escalation default, used when sudo is None.

False on the base: most managers install into user-writable trees and never need root. The system package managers whose privileged operations require root (apt, dnf, pacman, zypper, …) set this to True so their build_cli(..., sudo=True) operations escalate out of the box, while staying switchable off through sudo (--no-sudo or config) for rootless setups.

requirement: str | None = '>=3.8.0'¶

3.8.0 is the first release with the makecache command that sync runs (rpm-software-management/microdnf@e2d56ee). Everything else is older: --assumeno, which outdated needs, shipped in 3.7.0, and repoquery in 3.4.0.

version_cli: str | None = 'rpm'¶

microdnf has no version option. It ignores --version, prints its usage and No command specified to stderr, and exits 1. So the probe asks RPM for the version of the microdnf package instead.

rpm --query matches package names, never the capabilities a package provides. That is why the probe finds nothing where dnf5 provides a microdnf symlink.

version_cli_options: tuple[str, ...] = ('--query', '--queryformat', '%{VERSION}', 'microdnf')¶

CLI options used to produce the version of the package manager.

The raw output produced by the package manager CLI will be parsed with the version_regexes below to extract the version number.

version_regexes: tuple[str, ...] = ('^(?P<version>\\d\\S*)$',)¶

Anchored at both ends: a host without the package answers with the sentence package microdnf is not installed, which must match nothing.

$ rpm --query --queryformat %{VERSION} microdnf
3.10.1
property installed: Iterator[Package]¶

Fetch installed packages.

$ microdnf repoquery --installed
NetworkManager-1:1.56.0-2.el10_2.aarch64
NetworkManager-libnm-1:1.56.0-2.el10_2.aarch64
NetworkManager-tui-1:1.56.0-2.el10_2.aarch64
almalinux-gpg-keys-10.2-21.el10.aarch64
almalinux-release-10.2-21.el10.aarch64
almalinux-repos-10.2-21.el10.aarch64
alternatives-1.30-2.el10.aarch64
attr-2.5.2-5.el10.aarch64
property outdated: Iterator[Package]¶

Fetch outdated packages.

microdnf has no command that lists pending updates. So mpm reads the transaction upgrade would run, which --assumeno refuses before anything changes. The command exits 0 either way, with Operation aborted. after the table, or Nothing to do. alone.

An upgraded package is a row under Upgrading:, followed by a replacing row that names the installed version. An install-only package, like the kernel, is a row under Installing: instead: RPM installs its new version beside the old one. New dependencies show up in that section too, so a second query reads which of those names are installed, and skips the others.

$ microdnf --assumeno upgrade
Package                                             Repository     Size
Installing:
 kernel-6.12.0-211.53.1.el10_2.aarch64              baseos       1.7 MB
 kernel-core-6.12.0-211.53.1.el10_2.aarch64         baseos      19.9 MB
 kernel-modules-6.12.0-211.53.1.el10_2.aarch64      baseos      28.3 MB
 kernel-modules-core-6.12.0-211.53.1.el10_2.aarch64 baseos      26.6 MB
Upgrading:
 rsync-3.5.0-3.el10_2.aarch64                       baseos     474.3 kB
  replacing rsync-3.4.4-1.el10_2.aarch64
 tar-2:1.35-13.el10_2.aarch64                       baseos     884.5 kB
   replacing tar-2:1.35-11.el10.aarch64
Transaction Summary:
 Installing:        4 packages
 Reinstalling:      0 packages
 Upgrading:         2 packages
 Obsoleting:        0 packages
 Removing:          0 packages
 Downgrading:       0 packages
Operation aborted.
$ microdnf repoquery --installed kernel kernel-core kernel-modules kernel-modules-core
kernel-6.12.0-211.47.1.el10_2.aarch64
kernel-core-6.12.0-211.47.1.el10_2.aarch64
kernel-modules-6.12.0-211.47.1.el10_2.aarch64
kernel-modules-core-6.12.0-211.47.1.el10_2.aarch64
cli_names: tuple[str, ...] = ('microdnf',)¶

List of CLI names the package manager is known as.

This list of recognized CLI names is ordered by priority. That way we can influence the search of the right binary.

..hint::

This was helpful in the case of the Python transition from 2.x to 3.x, where multiple versions of the same executable were named python or python3.

By default, this property’s value is derived from the manager’s ID (see the MetaPackageManager.__init__ method above).

homepage_url: str | None = None¶

Home page of the project, only used in documentation for reference.

Left unset when the home page is the project’s repository, which repository_url names on its own. Never inherited, like the other links.

id: str = 'microdnf'¶

Package manager’s ID.

Derived by defaults from the lower-cased class name in which underscores _ are replaced by dashes -.

This ID must be unique among all package manager definitions and lower-case, as they’re used as feature flags for the mpm CLI.

search(query, extended, exact)[source]¶

Fetch matching packages.

Caution

repoquery matches package names only, never summaries. The match ignores case and also accepts a name-version form, so meta_package_manager.manager.PackageManager.refiltered_search() refines the exact results.

A repository can keep several builds of a package, and repoquery prints a row for each. Only the newest build is reported.

$ microdnf repoquery *xxd*
xxd-2:9.1.083-9.el10_2.2.aarch64
xxd-2:9.1.083-9.el10_2.3.aarch64
xxd-2:9.1.083-9.el10_2.4.aarch64
xxd-2:9.1.083-9.el10_2.7.aarch64
xxd-2:9.1.083-9.el10_2.12.aarch64
xxd-2:9.1.083-9.el10_2.20.aarch64
$ microdnf repoquery xxd
xxd-2:9.1.083-9.el10_2.2.aarch64
xxd-2:9.1.083-9.el10_2.3.aarch64
xxd-2:9.1.083-9.el10_2.4.aarch64
xxd-2:9.1.083-9.el10_2.7.aarch64
xxd-2:9.1.083-9.el10_2.12.aarch64
xxd-2:9.1.083-9.el10_2.20.aarch64
Return type:

Iterator[Package]

virtual: bool = False¶

Should we expose the package manager to the user?

Virtual package manager are just skeleton classes used to factorize code among managers of the same family.

wikipedia_url: str | None = None¶

English Wikipedia article about the project, or None when it has none.

Listed after homepage_url in the links of the manager’s documentation page. The article covers the project that home page names, or is a redirect Wikipedia keeps under the project’s name, landing on the part of a broader article that describes it: Cargo_(software) opens the Cargo section of the Rust article. An article that merely mentions the project does not count, nor does one about a related subject: lazy is a Neovim plugin manager, and the Neovim article is not about it.

Never inherited: the metaclass resets it to None on any class not declaring its own. A subclass often wraps a distinct project, like the six AUR helpers extending pacman, and would otherwise present pacman’s article as its own. Documentation-only, like homepage_url.

install(package_id, version=None)[source]¶

Install one package, optionally pinned to a version.

microdnf resolves name-version the way it resolves a bare name, so a pin joins the two with a dash. The epoch and the release are optional: a version without a release installs the newest build of that version.

$ sudo microdnf --assumeyes install tree
$ sudo microdnf --assumeyes install xxd-2:9.1.083-9.el10_2.3
Return type:

str

upgrade_all_cli()[source]¶

Generates the CLI to upgrade all outdated packages.

$ sudo microdnf --assumeyes upgrade
Return type:

tuple[str, ...]

upgrade_one_cli(package_id, version=None)[source]¶

Generates the CLI to upgrade one package, optionally to a version.

The version joins the package ID the way it does for install.

$ sudo microdnf --assumeyes upgrade tree
$ sudo microdnf --assumeyes upgrade xxd-9.1.083-9.el10_2.12
Return type:

tuple[str, ...]

remove(package_id)[source]¶

Remove one package and one only.

$ sudo microdnf --assumeyes remove tree
Return type:

str

sync()[source]¶

Download fresh metadata for every enabled repository.

$ sudo microdnf makecache
Return type:

None

cleanup_cache()[source]¶

Clear the cached packages and repository metadata.

$ sudo microdnf clean all
Return type:

None