From Mageia wiki
Jump to: navigation, search


Drakconf multiflag.png
Other languages
Deutsch ; English ; Español ; Français ; Nederlands ; 简体中文 ;

Preamble

Now that Feature:Add DNF as Alternate Repository Manager is almost done, it is possible to start using it. Before starting using DNF, do read Warning about orphans mechanisms below, and have a search in our Bugzilla. At the end of this document there are links to manuals.

Install

Stable

It is normally installed by default. If not: urpmi dnf.

Next-generation

There is also a next-gen version of DNF, DNF5 available in Cauldron. This is basically a complete rewrite but most of the old switches and commands work just fine.

To install it: dnf install dnf5

Usage: Just use it the same way as the stable branch with a 5 added at the end.

Example: dnf5 upgrade --refresh --allowerasing for updating the system.

Documentation: https://dnf5.readthedocs.io/en/latest/

Choose repositories

By default two repositories are enabled and should always be: core and core updates; in DNF named mageia-x86_64 and updates-x86_64 for a 64 bit system; mageia-i586 and updates-i586 for a 32-bit system.

If you have installed packages from another repo, you should always have that repo and its update repo enabled.

Note that this is important also when you switch from urpmi to DNF, or use both; to have corresponding repositories enabled in both!

  • If nonfree or tainted repositories are desired, they can be activated using dnf config-manager as shown with this example for 64 bit system (replace x86_64 with i586 for 32 bit):

dnf config-manager --set-enabled mageia-x86_64-nonfree updates-x86_64-nonfree
dnf config-manager --set-enabled mageia-x86_64-tainted updates-x86_64-tainted

  • 32-bit repositories are turned off by default on 64-bit x86. If you need them:

dnf config-manager --set-enabled mageia-i586 updates-i586
Repeat similarly (see previous example) if you also need nonfree and tainted (replace x86_64 with i586).

  • For Cauldron, replace "mageia" with "cauldron" and "updates", "backports", etc. with "cauldron-updates", "cauldron-backports", etc respectively in the above commands.
  • If you wish to override the mirror selection with your preferred mirror, you can do so by editing the repository config files in /etc/yum.repos.d. Uncomment the "baseurl=" line and change the URL to point to your preferred mirror. This will automatically override the "metalink" and "mirrorlist" properties so that it will use the designated mirror. If you want, you can comment out the "metalink=" and "mirrorlist=" entries if you want, but that will eliminate the failover mechanism that occurs when the "primary" mirror isn't functioning.

Example: Here is a list of repos on a 64 bit system with nonfree and tainted repos, and with 32-bit repos:

$ dnf repolist
repo id                                           repo name
mageia-i586                                       Mageia 9 - i586
mageia-i586-nonfree                               Mageia 9 - i586 - Nonfree
mageia-i586-tainted                               Mageia 9 - i586 - Tainted
mageia-x86_64                                     Mageia 9 - x86_64
mageia-x86_64-nonfree                             Mageia 9 - x86_64 - Nonfree
mageia-x86_64-tainted                             Mageia 9 - x86_64 - Tainted
updates-i586                                      Mageia 9 - i586 - Updates
updates-i586-nonfree                              Mageia 9 - i586 - Nonfree - Updates
updates-i586-tainted                              Mageia 9 - i586 - Tainted - Updates
updates-x86_64                                    Mageia 9 - x86_64 - Updates
updates-x86_64-nonfree                            Mageia 9 - x86_64 - Nonfree - Updates
updates-x86_64-tainted                            Mageia 9 - x86_64 - Tainted - Updates  

Some commands to get started

Also see the documentation.

As root:

  • dnf install ri-li installs ri-li
  • dnf reinstall ri-li reinstalls ri-li
  • dnf downgrade ri-li downgrades ri-li
  • dnf remove ri-li removes ri-li
  • dnf makecache refreshes the metadata (what is available in the repos)
  • dnf check-update --refresh refreshes the metadata and checks for new updates
  • dnf upgrade --refresh refreshes metadata and does all available updates
  • dnf upgrade --best forces attempts to select best available versions, which can help in determining dependency errors
  • dnf distro-sync --refresh refreshes the metadata and synchronizes the package set installed on the computer with versions in the repositories
  • dnf distro-sync --allowerasing --best will help to upgrade a package with changed major, like e.g. lib64clang3.8 to lib64clang3.9
  • dnf history list shows the install/remove/upgrade history list
  • dnf history info 12 shows what happened during item 12 from the history list
  • dnf shell invokes the interactive shell for doing multiple actions as one transaction
  • dnf install --enablerepo updates_testing-x86_64 caja installs a package (for caja) from a specific repository (updates_testing-x86_64)

As user (or root):

  • dnf help shows a help page
  • dnf search fax returns all packages with "fax" in the name or summary
  • dnf repolist shows last metadata check, the enabled repos and their size. First it downloads any yet not downloaded.

Short command variants

Starting with DNF 2.6.2, there are now short abbreviations for commonly used commands:
As root:

  • dnf in ri-li installs ri-li
  • dnf ri ri-li reinstalls ri-li
  • dnf dg ri-li downgrade ri-li
  • dnf rm ri-li removes ri-li
  • dnf mc refreshes the metadata (what is available on the repos)
  • dnf up does all available updates
  • dnf dsync synchronizes the package set installed on the computer with versions in the repositories
  • dnf sh invokes the interactive shell for doing multiple actions as one transaction

As user (or root):

  • dnf se fax returns all packages with "fax" in the name or summary

If you have a non-English system and need the output in English, then put LANGUAGE=C on the same line before the command.

Graphical interface

Install: dnf in dnfdragora

Launch: Mageia menu > Tools > System tools > dnfdragora. ( Or in terminal issue dnfdragora )

Quirk: mga#21453 - dnfdragora does not remember packages source selection.

Warning about orphans mechanisms

Mixing use of URPMI and DNF renders orphan mechanisms of both of them unreliable.

If you are going to use DNF, please switch to it as soon as possible after a fresh install.

Removing URPMI updater applet

Uninstall mgaonline.

DNF updater applet

Install dnfdragora-updater.

Synchronize with repos

In this chapter we demonstrate off-line synchronisation of installed packages. That means that in a preparation step it evaluates what to do, verifies with user, and then downloads all needed packages and prepare scripts. Later user give another command that makes system reboot and execute the process during boot. This minimises risk of problems compared to changing packages on a fully running system.

(For working on a running system, see "dnf distro-sync" shortly described above.)

These commands synchronize the package versions installed, with them in enabled repositories - both upgrade, install dependencies, and downgrade, optionally also removes packages that do not exist in repos.

For example this is perfect to execute on a system that you have used for testing Mageia before release, or you have participated in testing updates, and now want to make sure you are only using official versions - no more no less. It also comes in handy if your Mageia upgrade went wrong.

Make sure you have correct repos enabled, see Choose repositories. Repos can be disabled for the run, see the example below, option "disablerepo".

You have to install the command: as root dnf install 'dnf-command(offline-distrosync)'

The command to execute is dnf offline-distrosync download --disablerepo=\*cauldron\* --allowerasing - Note here that you might not want the "--allowerasing" option in your case if it will erase something you need and can not reinstall. The --disablerepo part is for skipping any cauldron repos that was configured. You may do similar for i.e any testing repos if you have.

Here is an example run on a system that was testing Cauldron/Mageia 9 before release, and a while after switching to release, I realised some packages had wrong versions - DNF to the rescue :) As you can see it upgraded, installed dependency, downgraded, and removed packages. This system had not used DNF before, so I had to enable same repos urpmi have been using: nonfree and tainted repos, and 32-bit repos.

$ LANGUAGE=C sudo dnf offline-distrosync download --disablerepo=\*cauldron\* --allowerasing
No repository match: *cauldron*
Mageia 9 - i586                                                                    8.8 kB/s | 2.5 kB     00:00    
Mageia 9 - i586 - Updates                                                          5.5 kB/s | 1.5 kB     00:00    
Mageia 9 - i586 - Nonfree                                                          6.0 kB/s | 2.0 kB     00:00    
Mageia 9 - i586 - Nonfree - Updates                                                4.3 kB/s | 1.5 kB     00:00    
Mageia 9 - x86_64 - Nonfree                                                        4.1 kB/s | 2.0 kB     00:00    
Mageia 9 - x86_64 - Nonfree - Updates                                              4.5 kB/s | 1.5 kB     00:00    
Mageia 9 - i586 - Tainted                                                          2.4 kB/s | 1.5 kB     00:00    
Mageia 9 - i586 - Tainted - Updates                                                4.6 kB/s | 1.5 kB     00:00    
Mageia 9 - x86_64 - Tainted                                                        4.5 kB/s | 1.5 kB     00:00    
Mageia 9 - x86_64 - Tainted - Updates                                              4.7 kB/s | 1.5 kB     00:00    
Mageia 9 - x86_64                                                                  7.4 kB/s | 2.5 kB     00:00    
Mageia 9 - x86_64 - Updates                                                        5.7 kB/s | 1.5 kB     00:00    
Dependencies resolved.
===================================================================================================================
 Package                                Architecture Version                     Repository                   Size
===================================================================================================================
Installing:
 kernel-desktop                         x86_64       6.4.9-4.mga9                mageia-x86_64                80 M
Installing dependencies:
 lib64bind9.18.15                       x86_64       9.18.15-2.mga9              mageia-x86_64               1.2 M
Removing:
 kernel-desktop                         x86_64       6.3.9-1.1.mga9              @System                      89 M
 kernel-desktop                         x86_64       6.4.8-3.mga9                @System                      90 M
 kernel-desktop                         x86_64       6.4.8-4.mga9                @System                      90 M
 kernel-desktop                         x86_64       6.4.9-2.mga9                @System                      90 M
Downgrading:
 bind-utils                             x86_64       9.18.15-2.mga9              mageia-x86_64               194 k
- 65 lines omitted for this wiki post... -
 wireless-regdb                         noarch       20230503-1.mga9             mageia-i586                  15 k

Transaction Summary
===================================================================================================================
Install     2 Packages
Remove      4 Packages
Downgrade  67 Packages

Total download size: 143 M
DNF will only download packages, install gpg keys, and check the transaction.
Is this ok [y/N]: y
Downloading Packages:
(1/69): gurpmi-8.131-1.mga9.noarch.rpm                                             254 kB/s |  25 kB     00:00    
 - 67 lines omitted for this wiki post... -
(69/69): kernel-desktop-6.4.9-4.mga9.x86_64.rpm                                    1.9 MB/s |  80 MB     00:41    
-------------------------------------------------------------------------------------------------------------------
Total                                                                              2.2 MB/s | 143 MB     01:06     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Complete!
Transaction saved to /var/lib/dnf/system-upgrade/system-upgrade-transaction.json.
Download complete! Use 'dnf offline-distrosync reboot' to start the upgrade.
To remove cached metadata and transaction use 'dnf offline-distrosync clean'
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.   

Read through the report carefully. If you wish you can to change repos or options on the command line and run it again.

If you decide to execute:

  1. Save your work, and close applications!
  2. Trigger the upgrade: dnf offline-distrosync reboot - /!\ NOTE: This immediately reboots your system! /!\

When system is up again, ensure mageia-repos-cauldron is uninstalled: dnf remove mageia-repos-cauldron.

More Documentation here.

Upgrade Mageia release using DNF

You can upgrade Mageia in just a few steps. Note all commands must be run as root.

  1. Make sure you have correct repos enabled, see Choose repositories.
  2. Ensure you're fully up to date: dnf --refresh upgrade
  3. Install the system-upgrade plugin: dnf install 'dnf-command(system-upgrade)'
  4. Start it: dnf system-upgrade --releasever <targetversion> download --allowerasing. For example, to upgrade to Mageia 8, use 8 for <targetversion>.
    1. It will ask before downloading packages, and report how much space is required. If you do not have what it says plus a couple of hundred MB free space on /var partition (if /var is not separate but part of / partition, add another couple hundred MB), then either make enough space or add the option --downloaddir path_to_directory_with_free_space to this and the next system-upgrade commands. Also make sure / has additional room for the larger new programs. Note that maybe there needs to be room for not just one, but two kernels (see Extra kernel flavour below). Especially if you have a separate /boot partition, check there is enough room for that.
    2. When you know you have sufficient space, say yes to let it download. It will also dry run a transaction test.
  5. If the downloading and transaction test succeeded,
    1. Save your work, and close applications!
    2. Trigger the upgrade: dnf system-upgrade reboot - /!\ NOTE: This immediately reboots your system! /!\

Now enjoy some beverage while looking at the bubbles on our boot splash - and above it, messages detailing what is happening. When done, it will reboot, allowing you enjoy your new Mageia.

Extra kernel flavour

DNF uses a different method to select kernel flavour than Mageia installer. This may result in that a system that was using the desktop kernel, can end up with both desktop and server installed after upgrade by DNF, and server being used. Easy fix: select at boot the desktop kernel, then uninstall server kernel. mga#28272

Setting up a container for a non-native architecture

Starting with DNF 2.6.2, it is now possible to build chroots or containers for foreign architectures.

The procedure for creating an ARMv7 chroot on an x86_64 system is as follows:

  1. Install qemu-user-static on the host system
  2. Restart systemd-binfmt.service to have new binary format information to take effect
  3. Create the directory of your foreign arch chroot. For example /var/lib/machines/mga8armv7hl
  4. Run DNF as root to create the installroot:
dnf --installroot=/var/lib/machines/mga8armv7hl --releasever=8 --forcearch=armv7hl --repofrompath=mga8rel,http://mirrors.kernel.org/mageia/distrib/8/armv7hl/media/core/release/ --repofrompath=mga8up,http://mirrors.kernel.org/mageia/distrib/8/armv7hl/media/core/updates/ --disablerepo=* --enablerepo=mga8rel --enablerepo=mga8up --setopt=install_weak_deps=False install basesystem-minimal-core dnf

Finally, test the chroot to see if a program runs. Here's a suggested command (run as root): chroot /var/lib/machines/mga8armv7hl /usr/bin/uname -r -m

Documentation