Using DNF5

I recently installed DNF5 on my system and also created aliasing to make everything run through DNF5. I also updated the updatesys.run with DNF5 references and ordered the OPTIONS to be after the modified command, as such:

#!/bin/sh
konsole -e sh -c "pkexec dnf5 clean all ; pkexec dnf5 distro-sync --refresh --allowerasing; echo 'Press enter to close konsole'; read"

Really, I didn’t do much. Anyway, I ran the script afterwards and it ran perfectly fine. I’m just letting everyone know in case I run into any issues which may help with the eventual implementation of DNF5.
Ultimately, the dnf command will have to be symlinked to dnf5 as was done previously in changes to the dnf version. (see this article) Isn’t the tree outline cool! lol. :smiley:
P.S. I did this because of the implementation of snapshotting with BTRFS and the DNF5 plugin to take snapshots when system changes occur. It has worked flawlessly so far.

1 Like

This is just as effective and removes some bloat:

#!/bin/sh
pkexec -e sh -c "dnf5 clean all ; dnf5 distro-sync --refresh --allowerasing"

It’s also DE agnostic as polkit will call the password prompt for the DE being used.

1 Like

Thank you for the suggestion :clap:
With respect to the devs, I did minimal editing on the updatesys.run file–only updating the dnf to dnf5 command. I’m not really suggesting this change to be permanent. Ultimately, dnf will probably have to be symlinked to dnf5, this change will break updatesys.rn a little, however, since the order of the OPTIONS has to be after the command.
Your suggestions are spot on, though with the removal of both clean all commands!

Why is dnf5 not the default?

I imagine it is because the devs have not yet chosen to move to DNF5 because it is either not completely compatible with some of their scripting or the process of converting the numerous scripts is lower on the list of things to do since the “older” version of DNF is still very usable.

I would like to suggest moving to DNF5.

I changed the symlink in my bin folder to point to dnf5 as a test to see how things go. The shell script to update the system, being modified back to its regular format does, indeed, fail, because of the order of the OPTIONS, but simply putting them behind the command causes the script to function correctly.
before:

konsole -e sh -c "pkexec dnf clean all ; pkexec dnf --refresh --allowerasing distro-sync ; echo 'Press enter to close konsole'; read"

after:

konsole -e sh -c "pkexec dnf clean all ; pkexec dnf distro-sync --refresh --allowerasing; echo 'Press enter to close konsole'; read"

Another reason may be a unified tooling. DNFdragora, for instance, version 2.1.6 is using dnf4, having package managers that use different DNF versions can cause problems.
In the upcoming release of DNFdragora (the pre-release, 2.99.0 was put out three weeks ago, per github) will use dnf5. I’m not sure when it will be released, but this could be seen as motivation to move to DNF5 on OMLx. :smiley:

1 Like

It is a goal. I’m not sure when, but it has been discussed.

I don’t use gui package managers, just the terminal. Is there anything I need to do to switch over to dnf5 on my own?

1 Like

@zeroability That’s exciting. I’ll look forward to an official implementation!

@LeeTalbert I’m the same. I update in the terminal. If you change to dnf5 and don’t alias correctly, and don’t always remember to use dnf5, you can flip back and forth inadvertently. If you do alias correctly, but sometimes use the official OMLx scripts, you will still use older versions of dnf5. That’s why I changed the symlinks in the /usr/bin directory. All calls on dnf point to dnf5, that way, but making that change will break the official OMLx scripts that call dnf using options in an order that isn’t compatible with DNF5. If you only update using the proper command sequence in the terminal, it’s not a problem, or if you change the system scripts it isn’t a problem. Any updates pulled from the OMLx repos will overwrite changes you may make to the official script, though.

All of that aside, if you want to get dnf5, here is the process:

sudo dnf install dnf5

Aliasing

If you follow the aliasing route, the aliases are as follows

echo 'alias dnf="dnf5"' >> /home/$USER/.bashrc && echo 'alias sudo="sudo "' >> /home/$USER/.bashrc

This will enable dnf5 to run all calls made to dnf, even when performed by sudo.

This only works in bash, so any shell scripts are unaffected, such as the official system scripts. If you change the official script for updating, it is here: (if you don’t like nano use something else)

sudo nano /usr/share/om-welcome/apps/updatesys.run

and change the two dnf calls to dnf 5:

#!/bin/sh
konsole -e sh -c "pkexec dnf5 clean all ; pkexec dnf5 distro-sync --refresh --allowerasing; echo 'Press enter to close konsole'; read"

The above has also been modified to compliment the dnf5 order of options (--refresh --allowerasing) after the command (distro-sync).

Symlinking

On the other hand, if you want to change the symlinks in /usr/bin so any systemwide calls to dnf will be dnf5, here are the steps. Don’t worry about symlinking, it is already used in /usr/bin to modify the dnf command. In fact, dnf is a symlink already to dnf-3, the actual binary which is called. At any rate, do the following commands in the terminal:

cd /usr/bin
sudo ln -s dnf-3 dnf-orig
sudo rm dnf
sudo ln -s dnf5 dnf

In doing this, we’ve made a “backup” of the original symlink, dnf, as dnf-org. One could also rename the symlink, sudo mv dnf dnf-orig, for the same effect, so long as the final command (sudo ln -s dnf5 dnf) is also run. Now all system calls to dnf will run the dnf5 binary. However, because we haven’t modified the system update script, do the following:

sudo nano /usr/share/om-welcome/apps/updatesys.run

and change the order of the options to after the command, as such:

#!/bin/sh
konsole -e sh -c "pkexec dnf clean all ; pkexec dnf distro-sync --refresh --allowerasing; echo 'Press enter to close konsole'; read"

You’ll notice in this we’ve kept dnf instead of modifying it to dnf5. This is because in calling dnf, it will symlink to dnf5. At any rate, this is temporary at best, because any updates to the script will override the change. If you only update via the terminal, the best order of operations, as given by @zeroability,

sudo dnf clean all ; dnf distro-sync --refresh --allowerasing

Concluding statement

I would not suggest doing both aliasing AND symlinking. Do one or the other. This is certainly not an official idea and only an example of what I’ve implemented on my own system in different phases.

1 Like

Thank you! I just set this up on my cooker VM, and I’ll do my laptop later tonight.

1 Like

I should add, to test to see if you’ve gotten it set up, run both:

dnf --version
sudo dnf --version

both should return that you are running dnf version 5, something like this:
image

If you get old information, like this:
image
You most likely have aliased using the above instructions, but did not have bash reinitialize. You can either start a new terminal and rerun the dnf --version commands or in the same terminal, run:

exec bash

and rerun the dnf --version commands.

2 Likes