Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dnf info --releasever=XX ignores releasever when package is installed #1975

Open
mihawk90 opened this issue Dec 23, 2024 · 4 comments
Open
Labels
Priority: LOW Triaged Someone on the DNF 5 team has read the issue and determined the next steps to take

Comments

@mihawk90
Copy link

I am now on Fedora 41 using DNF5, and I wanted to get the available package version of a package in Fedora 40.
On F40 I would simply do dnf info <package-spec> --releasever=XX to check for package version available in Fedora XX.
However, it seems some behaviour has changed or this is possibly a bug, I'm not sure.

When I do this now, DNF downloads metadata for the supplied releasever, but it lists the package information for the current release if <package-spec> is installed:

 rpm -E "Current: %fedora" && dnf info --releasever=40 --repo=fedora,updates --refresh mpv
Current: 41
Updating and loading repositories:
 Fedora 40 - x86_64 - Updates                                                                               100% |  32.4 KiB/s |  24.5 KiB |  00m01s
 Fedora 40 - x86_64                                                                                         100% |  53.0 KiB/s |  27.3 KiB |  00m01s
Repositories loaded.
Installed packages
Name            : mpv
Epoch           : 0
Version         : 0.39.0
Release         : 1.fc41     <<<<<
[...]

Conversely, a <package-spec> that is not installed outputs the correct information:

 rpm -E "Current: %fedora" && dnf info --releasever=40 --repo=fedora,updates --refresh vlc
Current: 41
Updating and loading repositories:
 Fedora 40 - x86_64 - Updates                                                                               100% |  35.7 KiB/s |  24.5 KiB |  00m01s
 Fedora 40 - x86_64                                                                                         100% |  36.7 KiB/s |  27.3 KiB |  00m01s
Repositories loaded.
Available packages
Name           : vlc
Epoch          : 1
Version        : 3.0.21
Release        : 7.fc40     <<<<<
[...]

Compared to the old DNF4 behaviour:

$ rpm -E "Current: %fedora" && dnf info --releasever=41 --repo=fedora,updates --refresh mpv
Current: 40
Fedora 41 - x86_64                                                             54 kB/s |  27 kB     00:00    
Fedora 41 - x86_64 - Updates                                                   33 kB/s |  19 kB     00:00    
Installed Packages
Name         : mpv
Version      : 0.37.0
Release      : 4.fc40
[...]

Available Packages
Name         : mpv
Version      : 0.39.0
Release      : 1.fc41     <<<<<
[...]

Even though the currently installed version is also not what I was looking for, at least it is showing the information that I actually wanted as well.

One can supply --showduplicates to (sort of) get the old behaviour back:

 rpm -E "Current: %fedora" && dnf info --releasever=40 --repo=fedora,updates --refresh mpv --showduplicates
Current: 41
Updating and loading repositories:
 Fedora 40 - x86_64                                                                                         100% |  58.0 KiB/s |  27.3 KiB |  00m00s
 Fedora 40 - x86_64 - Updates                                                                               100% |  46.9 KiB/s |  24.5 KiB |  00m01s
Repositories loaded.
Installed packages
Name            : mpv
Epoch           : 0
Version         : 0.39.0
Release         : 1.fc41
[...]

Available packages
Name           : mpv
Epoch          : 0
Version        : 0.37.0
Release        : 4.fc40     <<<<<

However, I would still consider this a regression because (when not using --showduplicates) it is not actually showing the information requested, especially because the man page does not mention this change in behaviour, and the behaviour changes depending on whether <package-spec> is installed or not.

@ppisar
Copy link
Contributor

ppisar commented Jan 3, 2025

I think what you are looking for is "--available" option which limits searching among repositories, i.e. not among installed packages:

root@fedora-41:~ # dnf5 --repo fedora --releasever 40 info --available bash
Updating and loading repositories:
Repositories loaded.
Available packages
Name           : bash
Epoch          : 0
Version        : 5.2.26
Release        : 3.fc40
Architecture   : x86_64
Download size  : 1.8 MiB
Installed size : 8.1 MiB
Source         : bash-5.2.26-3.fc40.src.rpm
Repository     : fedora
Summary        : The GNU Bourne Again shell
URL            : https://www.gnu.org/software/bash
License        : GPL-3.0-or-later
Description    : The GNU Bourne Again shell (Bash) is a shell or command language
               : interpreter that is compatible with the Bourne shell (sh). Bash
               : incorporates useful features from the Korn shell (ksh) and the C shell
               : (csh). Most sh scripts can be run by bash without modification.
Vendor         : Fedora Project

The thing is that "dnf info" actually searches among repositories and installed packages by default, but hides older versions (unless --showduplicates is given). And thus it depends which package version is newer and which is older. Observe how the section name changes between "Installed packages" and "Available packages":

root@fedora-41:~ # dnf5 --repo fedora --releasever 42 info bash
Updating and loading repositories:
Repositories loaded.
Installed packages
Name            : bash
Epoch           : 0
Version         : 5.2.32
Release         : 1.fc41
Architecture    : x86_64
Installed size  : 8.2 MiB
Source          : bash-5.2.32-1.fc41.src.rpm
From repository : f41-build
Summary         : The GNU Bourne Again shell
URL             : https://www.gnu.org/software/bash
License         : GPL-3.0-or-later
Description     : The GNU Bourne Again shell (Bash) is a shell or command language
                : interpreter that is compatible with the Bourne shell (sh). Bash
                : incorporates useful features from the Korn shell (ksh) and the C shell
                : (csh). Most sh scripts can be run by bash without modification.
Vendor          : Fedora Project

Available packages
Name           : bash
Epoch          : 0
Version        : 5.2.37
Release        : 1.fc42
Architecture   : x86_64
Download size  : 1.8 MiB
Installed size : 8.2 MiB
Source         : bash-5.2.37-1.fc42.src.rpm
Repository     : fedora
Summary        : The GNU Bourne Again shell
URL            : https://www.gnu.org/software/bash
License        : GPL-3.0-or-later
Description    : The GNU Bourne Again shell (Bash) is a shell or command language
               : interpreter that is compatible with the Bourne shell (sh). Bash
               : incorporates useful features from the Korn shell (ksh) and the C shell
               : (csh). Most sh scripts can be run by bash without modification.
Vendor         : Fedora Project
root@fedora-41:~ # dnf5 --repo fedora --releasever 40 info bash
Updating and loading repositories:
Repositories loaded.
Installed packages
Name            : bash
Epoch           : 0
Version         : 5.2.32
Release         : 1.fc41
Architecture    : x86_64
Installed size  : 8.2 MiB
Source          : bash-5.2.32-1.fc41.src.rpm
From repository : f41-build
Summary         : The GNU Bourne Again shell
URL             : https://www.gnu.org/software/bash
License         : GPL-3.0-or-later
Description     : The GNU Bourne Again shell (Bash) is a shell or command language
                : interpreter that is compatible with the Bourne shell (sh). Bash
                : incorporates useful features from the Korn shell (ksh) and the C shell
                : (csh). Most sh scripts can be run by bash without modification.
Vendor          : Fedora Project

The same applies to DNF4. Except there is actually a bug in DNF4 which prevents from listing any version from repositories if a newer one is installed:

root@fedora-41:~ # dnf4 --repo fedora --releasever 40 info --available bash
Last metadata expiration check: 0:24:38 ago on Fri 03 Jan 2025 01:27:54 PM CET.
Error: No matching Packages to list

While it works with DNF5:

# dnf5 --repo fedora --releasever 40 info --available bash
Updating and loading repositories:
Repositories loaded.
Available packages
Name           : bash
Epoch          : 0
Version        : 5.2.26
Release        : 3.fc40
Architecture   : x86_64
Download size  : 1.8 MiB
Installed size : 8.1 MiB
Source         : bash-5.2.26-3.fc40.src.rpm
Repository     : fedora
Summary        : The GNU Bourne Again shell
URL            : https://www.gnu.org/software/bash
License        : GPL-3.0-or-later
Description    : The GNU Bourne Again shell (Bash) is a shell or command language
               : interpreter that is compatible with the Bourne shell (sh). Bash
               : incorporates useful features from the Korn shell (ksh) and the C shell
               : (csh). Most sh scripts can be run by bash without modification.
Vendor         : Fedora Project

In other words, the difference you reported is a difference between F40 and F41 systems where you have installed different package versions. It's not a change between DNF4 and DNF5.

@ppisar
Copy link
Contributor

ppisar commented Jan 3, 2025

I forgot to paste how DNF4 behaves:

root@fedora-41:~ # dnf4 --repo fedora --releasever 42 info bash
Last metadata expiration check: 0:43:04 ago on Fri 03 Jan 2025 01:25:55 PM CET.
Installed Packages
Name         : bash
Version      : 5.2.32
Release      : 1.fc41
Architecture : x86_64
Size         : 8.2 M
Source       : bash-5.2.32-1.fc41.src.rpm
Repository   : @System
Summary      : The GNU Bourne Again shell
URL          : https://www.gnu.org/software/bash
License      : GPL-3.0-or-later
Description  : The GNU Bourne Again shell (Bash) is a shell or command language
             : interpreter that is compatible with the Bourne shell (sh). Bash
             : incorporates useful features from the Korn shell (ksh) and the C shell
             : (csh). Most sh scripts can be run by bash without modification.

Available Packages
Name         : bash
Version      : 5.2.37
Release      : 1.fc42
Architecture : x86_64
Size         : 1.8 M
Source       : bash-5.2.37-1.fc42.src.rpm
Repository   : fedora
Summary      : The GNU Bourne Again shell
URL          : https://www.gnu.org/software/bash
License      : GPL-3.0-or-later
Description  : The GNU Bourne Again shell (Bash) is a shell or command language
             : interpreter that is compatible with the Bourne shell (sh). Bash
             : incorporates useful features from the Korn shell (ksh) and the C shell
             : (csh). Most sh scripts can be run by bash without modification.

root@fedora-41:~ # dnf4 --repo fedora --releasever 40 info bash
Last metadata expiration check: 0:41:13 ago on Fri 03 Jan 2025 01:27:54 PM CET.
Installed Packages
Name         : bash
Version      : 5.2.32
Release      : 1.fc41
Architecture : x86_64
Size         : 8.2 M
Source       : bash-5.2.32-1.fc41.src.rpm
Repository   : @System
Summary      : The GNU Bourne Again shell
URL          : https://www.gnu.org/software/bash
License      : GPL-3.0-or-later
Description  : The GNU Bourne Again shell (Bash) is a shell or command language
             : interpreter that is compatible with the Bourne shell (sh). Bash
             : incorporates useful features from the Korn shell (ksh) and the C shell
             : (csh). Most sh scripts can be run by bash without modification.

As you can see in the latest command, DNF4 also hides available packages if they are older than the installed one.

I also find the asymmetry strange, but at least it's not regression comparing to DNF4. I wouldn't be surprised if it were a feature.

I will ask veteran DNF developers for the explanation, and we will either document it properly in dnf5-info manual, or change the behavior.

@mihawk90
Copy link
Author

mihawk90 commented Jan 3, 2025

Thanks for the explanation.
You're right, DNF4 does behave the same. I should have checked with both from the same system instead of comparing F40 and F41.
Both do indeed output the same (installed) package version:

 rpm -E "Current: %fedora" && dnf info --releasever=40 --repo=fedora,updates --refresh mpv 
Current: 41
Updating and loading repositories:
 Fedora 40 - x86_64                                                             100% |  37.7 KiB/s |  27.3 KiB |  00m01s
 Fedora 40 - x86_64 - Updates                                                   100% |  33.8 KiB/s |  23.6 KiB |  00m01s
Repositories loaded.
Installed packages
Name            : mpv
Epoch           : 0
Version         : 0.39.0
Release         : 1.fc41
[…]

 rpm -E "Current: %fedora" && dnf4 info --releasever=40 --repo=fedora,updates --refresh mpv
Current: 41
Fedora 40 - x86_64                                                                       37 kB/s |  27 kB     00:00    
Fedora 40 - x86_64 - Updates                                                             31 kB/s |  24 kB     00:00    
Installed Packages
Name         : mpv
Version      : 0.39.0
Release      : 1.fc41
[...]

I'm not sure if the varying output depending on the situation is ideal, but then again I hadn't really noticed it until now and there are options to specify further.

@ppisar
Copy link
Contributor

ppisar commented Jan 6, 2025

DNF team has discussed this issue and the current behavior seems to be intended: If "dnf info" and "dnf list" are not explicitly instructed with --available or --installed options, the commands prints an installed version and a newer available one. The primary use case for the commands is to tell what version is installed and if there is an update available.

We will document this behavior.

@ppisar ppisar added Priority: LOW Triaged Someone on the DNF 5 team has read the issue and determined the next steps to take labels Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: LOW Triaged Someone on the DNF 5 team has read the issue and determined the next steps to take
Projects
None yet
Development

No branches or pull requests

2 participants