meta_package_manager.managers.dnf module¶

class meta_package_manager.managers.dnf.DNF[source]¶

Bases: PackageManager

Fedora’s RPM package manager.

mpm reads the inventory through repoquery rather than the human-facing listing: --userinstalled for packages installed on request (dependencies pulled in automatically are skipped) and --upgrades for pending updates, both with a --queryformat that joins the fields on a private ___MPM___ delimiter so summaries containing spaces stay splittable. Every call is forced --color=never and --quiet for parseable output.

Note

remove runs autoremove, so removing a package also drops the dependencies it leaves orphaned. search matches names only, with no exact or extended mode.

The DNF5 and YUM subclasses reuse everything here, differing only in the binary and forced arguments.

Documentation:

Initialize cli_errors list.

maintenance_note: str | None = "DNF 4 is superseded by [dnf5](https://github.com/rpm-software-management/dnf5) (Fedora's default since Fedora 41) but stays maintained for the RHEL 8/9 family; 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 = 'Fedora DNF'¶

Return package manager’s common name.

Default value is based on class name.

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

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

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='aix', name='IBM AIX'), 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='cygwin', name='Cygwin'), Platform(id='debian', name='Debian'), Platform(id='dragonfly_bsd', name='DragonFly BSD'), Platform(id='endeavouros', name='EndeavourOS'), Platform(id='exherbo', name='Exherbo Linux'), Platform(id='fedora', name='Fedora'), Platform(id='freebsd', name='FreeBSD'), Platform(id='generic_linux', name='Generic Linux'), Platform(id='gentoo', name='Gentoo Linux'), Platform(id='guix', name='Guix System'), Platform(id='haiku', name='Haiku'), Platform(id='hurd', name='GNU/Hurd'), Platform(id='ibm_powerkvm', name='IBM PowerKVM'), Platform(id='illumos', name='illumos'), 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='midnightbsd', name='MidnightBSD'), Platform(id='netbsd', name='NetBSD'), Platform(id='nixos', name='NixOS'), Platform(id='nobara', name='Nobara'), Platform(id='openbsd', name='OpenBSD'), Platform(id='opensuse', name='openSUSE'), Platform(id='openwrt', name='OpenWrt'), Platform(id='oracle', name='Oracle Linux'), Platform(id='os400', name='IBM i'), 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='solaris', name='Solaris'), Platform(id='sourcemage', name='Source Mage GNU/Linux'), Platform(id='sunos', name='SunOS'), 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 = '>=4.0.0'¶

Version requirement specifier.

Supports a comma-separated range of constraints (e.g. ">=1.20.0,<2.0.0"). A bare version string like "1.20.0" is treated as >=1.20.0.

Parsed by meta_package_manager.version.VersionRange.

Defaults to None, which deactivates version check entirely.

cli_names: tuple[str, ...] = ('dnf', 'dnf4')¶
$ dnf --version
4.9.0
pre_args: tuple[str, ...] = ('--color=never', '--quiet')¶
DELIMITER = '___MPM___'¶
property installed: Iterator[Package]¶

Fetch installed packages.

$ dnf repoquery --userinstalled --qf FORMAT
acl___MPM___2.2.53-1.el8___MPM___Access control list utilities___MPM___x86_64
audit___MPM___3.0.7-4.el9___MPM___User space auditing tools___MPM___x86_64
audit-libs___MPM___3.0.7-4.el9___MPM___Dynamic auditing library___MPM___x86_64
property outdated: Iterator[Package]¶

Fetch outdated packages.

$ dnf repoquery --upgrades --qf FORMAT
acl___MPM___2.2.53-1.el8___MPM___2.6.53-1.el8___MPM___Access control list utilities___MPM___x86_64
audit___MPM___2.2.53-1.el8___MPM___2.5.53-1.el8___MPM___User space auditing tools___MPM___x86_64
audit-libs___MPM___2.2.53-1.el8___MPM___2.6.53-1.el8___MPM___Dynamic auditing library___MPM___x86_64
property orphans: Iterator[Package]¶

Fetch packages installed as dependencies that nothing requires anymore.

$ dnf --color=never --quiet repoquery --unneeded
libfoo-1.0.2-3.el9.x86_64
python3-extra-0:3.9.18-3.el9.noarch
search(query, extended, exact)[source]¶

Fetch matching packages.

Caution

Search does not support extended or exact matching. So we return the best subset of results and let meta_package_manager.manager.PackageManager.refiltered_search() refine them.

$ dnf --color=never search usd
Last metadata expiration check: 0:06:37 ago on Sun 03 Apr 2022.
=================== Name Exactly Matched: usd =====================
usd.aarch64 : 3D VFX pipeline interchange file format
=================== Name & Summary Matched: usd ===================
python3-usd.aarch64 : Development files for USD
usd-devel.aarch64 : Development files for USD
======================= Name Matched: usd =========================
lvm2-dbusd.noarch : LVM2 D-Bus daemon
usd-libs.aarch64 : Universal Scene Description library
Return type:

Iterator[Package]

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

Install one package.

$ sudo dnf --color=never --quiet --assumeyes install pip
Return type:

str

upgrade_all_cli()[source]¶

Generates the CLI to upgrade all outdated packages.

$ sudo dnf --color=never --quiet --assumeyes upgrade
Return type:

tuple[str, ...]

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

Generates the CLI to upgrade the provided package.

$ sudo dnf --color=never --quiet --assumeyes upgrade pip
Return type:

tuple[str, ...]

remove(package_id)[source]¶

Remove one package and one only.

$ sudo dnf --color=never --quiet --assumeyes remove pip
Return type:

str

remove_orphan(package_id)[source]¶

Remove one package, dropping dependencies it alone pulled in.

autoremove targets the package plus the dependencies that were installed to satisfy it and are no longer required by anything else.

$ sudo dnf --color=never --quiet --assumeyes autoremove pip
Return type:

str

sync()[source]¶

Sync package metadata.

$ dnf --color=never --quiet check-update
Return type:

None

cleanup_orphan()[source]¶

Remove every package installed as a dependency and no longer required.

$ sudo dnf --color=never --quiet --assumeyes autoremove
Return type:

None

cleanup_cache()[source]¶

Clear the cached packages and repository metadata.

$ sudo dnf --color=never --quiet clean all
Return type:

None

doctor_cli()[source]¶

Generates the CLI running the native self-diagnosis.

check examines the rpm database for problems (duplicates, obsoleted packages, unsatisfied dependencies) and exits non-zero when any is found.

$ dnf --color=never --quiet check
Return type:

tuple[str, ...]

id: str = 'dnf'¶

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.

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.

class meta_package_manager.managers.dnf.DNF5[source]¶

Bases: DNF

The dnf5 rewrite of DNF, Fedora’s reference package manager since Fedora 41.

Inherits every operation and parser from DNF. Its forced arguments drop --color=never (dnf5 rejects that option), keeping only --quiet.

Initialize cli_errors list.

maintenance_note: str | None = None¶

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 = 'Fedora DNF5'¶

Return package manager’s common name.

Default value is based on class name.

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

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

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.

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

dnf5 is the new reference package manager as of Fedora 41.

cli_names: tuple[str, ...] = ('dnf5',)¶
$ dnf --version
4.9.0
pre_args: tuple[str, ...] = ('--quiet',)¶

Reset global options inherited from the DNF above.

dnf5 does not support --color=never parameter.

id: str = 'dnf5'¶

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.

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.

class meta_package_manager.managers.dnf.YUM[source]¶

Bases: DNF

YUM, the package manager DNF superseded.

On current Fedora and RHEL the yum binary is a wrapper around dnf. mpm drives it exactly as DNF, only the binary name differs.

Initialize cli_errors list.

maintenance_note: str | None = 'The standalone [yum project is archived](https://github.com/rpm-software-management/yum); on modern RHEL and Fedora the `yum` command is a maintained compatibility alias for [dnf](https://github.com/rpm-software-management/dnf).'¶

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.

id: str = 'yum'¶

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.

name: str = 'Fedora YUM'¶

Return package manager’s common name.

Default value is based on class name.

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.

homepage_url: str | None = 'http://yum.baseurl.org'¶

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

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.

cli_names: tuple[str, ...] = ('yum',)¶
$ dnf --version
4.9.0