SDB:DNF

Jump to: navigation, search


Tested on openSUSE

Recommended articles


DNF package manager

DNF is a package manager for RPM systems to install, update and remove packages. DNF was forked from Yum. Among the many improvements, it uses libsolv as a dependency resolver. DNF features support for plugins - which can be used to extend the core functionality of DNF -, automatic updates and parallel package downloads.


Installation

On Leap 15.3 and on Tumbleweed DNF is available from the official repositories and can be installed without adding another repository.

On the command line

# zypper install dnf rpm-repos-openSUSE-Tumbleweed

Obs.:

rpm-repos-openSUSE-Tumbleweed will add the official openSUSE-Tumbleweed repositories to /etc/yum.repos.d/, even though you have them under /etc/zypp/repos.d/. If you prefer to use the repositories you already have, including non-official ones, you can instead:

# zypper install dnf libdnf-repo-config-zypp

This package will make a symlink for every repo file you have in /etc/zypp/repos.d/.

With YaST2

Start YaST2, select "Software Management" and search for DNF. Select DNF and rpm-repos-openSUSE or libdnf-repo-config-zypp and mark them for installation and press Accept.

Using DNF as PackageKit backend

If you want to use DNF as backend for PackageKit, first you should install this package:

# zypper in PackageKit-backend-dnf

Or even use DNF already:

# dnf install PackageKit-backend-dnf

Now you just need to use this command:

# dnf swap PackageKit-backend-zypp PackageKit-backend-dnf

DNF Usage

To refresh repos:

# dnf makecache

To install packages:

# dnf install packagename

To search the repositories for a package type:

# dnf search packagename

To remove a package:

# dnf remove packagename

Other common DNF commands include

autoremove - removes packages installed as dependencies that are no longer required by currently installed programs.

check-update - checks for updates, but does not download or install the packages.

downgrade - reverts to the previous version of a package.

info - provides basic information about the package including name, version, release, and description.

reinstall - reinstalls the currently installed package.

upgrade - checks the repositories for newer packages and updates them.

exclude - exclude a package from the transaction.

For example to update a Tumbleweed installation:

# dnf makecache
# dnf distro-sync

To update a Leap installation:

# dnf makecache
# dnf upgrade

This is the equivalent of:

# zypper refresh 
# zypper dist-upgrade

or

# zypper refresh 
# zypper update

openSUSE flavored DNF

DNF on openSUSE also offers some aliases to mimic zypper commands. These aliases can be listed:

# dnf alias

Which will output something like this:

Alias dup='distro-sync'
Alias dist-upgrade='distro-sync'
Alias ref='makecache'
Alias refresh='makecache'
Alias ri='reinstall'

Using these aliases one can update the system or refresh repos like in zypper with:

# dnf ref
# dnf dup

which are equivalent of:

# zypper ref
# zypper dup 

To add a new alias for example for remove:

# dnf alias add rm=remove

Managing repositories

Adding repositories

DNF in this sense is very similar to zypper in a sense that it has to be pointed to .repo file. The command:

# dnf config-manager --add-repo URL

To add a repository from OBS you would have to replace the zypper addrepo part with dnf config-manager --add-repo and the url at the end.

# dnf config-manager --add-repo https://download.opensuse.org/repositories/devel:languages:python/openSUSE_Tumbleweed/devel:languages:python.repo

Listing repositories

# dnf repolist

or

# dnf repolist all

These command will list the unique id and the name of the available repositories. dnf repolist all will add an extra status field after every repository listed indicating that the repository is enabled or disabled.

Enable/Disable repository

Before enabling or disabling a repository it is best to list all out with their current status

# dnf repolist all

Then using the id of the repository you wish to enable:

# dnf config-manager --set-enabled repo_id

Or to disable:

# dnf config-manager --set-disabled repo_id

Troubleshooting

DNF dup can't update the kernel

Currently DNF is marking the kernel packages as protected and in case of a kernel update - which is fairly frequent on Tumbleweed - it will refuse to update. To get around the issue disable the running kernel protection:

 # dnf --setopt=protect_running_kernel=False --refresh distro-sync 

protect_running_kernel: Controls whether the package corresponding to the running version of kernel is protected from removal. Default is True.

You can make this change permanent by adding protect_running_kernel=False to /etc/dnf/dnf.conf.

Plugins

DNF does not have the same integration with OpenSUSE as zypper does without additional plugins

Specific functionality that is enabled by default with zypper can not be reproduced using DNF without the additional installation of plugins. Functionality such as "protected" packages and snapper integration require the use of plugins. To see a list of plugins available search for:

 # python3-dnf*

refer to the upstream documentation for up to date information about the plugins.

https://dnf-plugins-core.readthedocs.io/en/latest/
https://dnf-plugins-extras.readthedocs.io/en/latest/