Bug 1371319 - No difference in output from dnf list --available [pkg] and dnf list --installed [pkg]
Summary: No difference in output from dnf list --available [pkg] and dnf list --instal...
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: 24
Hardware: x86_64
OS: Linux
high
unspecified
Target Milestone: ---
Assignee: Jaroslav Mracek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-08-29 22:19 UTC by fropeter
Modified: 2016-09-09 05:27 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-09-08 18:09:51 UTC
Type: Bug


Attachments (Terms of Use)

Description fropeter 2016-08-29 22:19:07 UTC
Description of problem:

The output of the three versions of 'dnf list' is identical, at least when specifying a package (with or without globbing).
When using dnf in a script, this makes it difficult to e.g. check if a package is installed, or available, using exit codes.

From the docs: (http://dnf.readthedocs.io/en/latest/command_ref.html#list-command-label)

<quote>
A package is installed if it is present in the RPMDB, and it is available if it is not installed but it is present in a repository that DNF knows about. 
...
dnf [options] list --installed [<package-name-specs>...]
    Lists installed packages.
dnf [options] list --available [<package-name-specs>...]
    Lists available packages.
</quote>

This is the real output:

~]$ dnf list gedit.x86_64
Installed Packages
gedit.x86_64                       2:3.20.2-1.fc24                       @fedora
~]$ dnf list --installed gedit.x86_64
Installed Packages
gedit.x86_64                       2:3.20.2-1.fc24                       @fedora
~]$ dnf list --available gedit.x86_64
Installed Packages
gedit.x86_64                       2:3.20.2-1.fc24                       @fedora
~]$ 

~]$ dnf list gedit
Installed Packages
gedit.x86_64                       2:3.20.2-1.fc24                       @fedora
Available Packages
gedit.i686                         2:3.20.2-1.fc24                       fedora 
~]$ dnf list --installed gedit
Installed Packages
gedit.x86_64                       2:3.20.2-1.fc24                       @fedora
Available Packages
gedit.i686                         2:3.20.2-1.fc24                       fedora 
~]$ dnf list --available gedit
Installed Packages
gedit.x86_64                       2:3.20.2-1.fc24                       @fedora
Available Packages
gedit.i686                         2:3.20.2-1.fc24                       fedora 
~]$

Also, in all cases the return code is 0 (success)

Version-Release number of selected component (if applicable):
~]$ dnf --version
1.1.10
  Installed: dnf-0:1.1.10-1.fc24.noarch at 2016-08-23 17:29
  Built    : Fedora Project at 2016-08-18 14:39

  Installed: rpm-0:4.13.0-0.rc1.27.fc24.x86_64 at 2016-07-29 12:19
  Built    : Fedora Project at 2016-04-25 13:45


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:

If the package is installed:
  dnf list --available [pkg] should fail
  dnf list --installed [pkg] should succeed

If the package is not installed, but available in a known repo:
  dnf list --available [pkg] should succeed
  dnf list --installed [pkg] should fail

If used with globbing, only packages relevant to the option should be listed.
Otherwise I don't see the point in having the separate options.

And it doesn't follow the (official?) documentation.

Additional info:

Comment 1 fropeter 2016-09-04 15:03:09 UTC
Maybe expected behaviour is a little unclear, hence this elaboration:

If the package is installed:
  dnf list --available [pkg] should fail

    ~]$ dnf list --available gedit.x86_64
    gedit.x86_64 is not available
    ~]$ 

  exit code !=0

I see that the wording in the output might be confusing, but it is 
the way the word 'available' is used in the documentation. Maybe the
wording should be different depending on whether the package is
installed or if it is in no known repo. The two results should
have different exit codes.


If the package is not installed, but available in a known repo:
  dnf list --installed [pkg] should fail

    ~]$ dnf list --installed gedit.x86_64
    gedit.x86_64 is not installed
    ~]$ 

  exit code !=0

If used with globbing, only packages relevant to {--installed,--available} should be listed.

In all these cases there would not be a need for the "Installed Packages"
or "Available Packages" headings in the output.

Comment 2 Jaroslav Mracek 2016-09-05 11:12:34 UTC
We will investigate but the issue with return code, we will inherit from YUM behavior.

Comment 3 Jaroslav Mracek 2016-09-07 17:35:25 UTC
Please, can you try dnf-2.0 from copt repo. Just use command ``dnf copr enable rpmsoftwaremanagement/dnf-nightly`` and then upgrade dnf to version 2.0. According to my investigation, the problem is solve in this upstream version. Even globing was working in format ``dnf list --available 'acp*' `` as expected.

Comment 4 Jaroslav Mracek 2016-09-08 18:09:51 UTC
Probably it will be better to close the bug report but if you will experience the reported problem with dnf-2.0, please don't hesitate to reopen it and provide please fresh data.

Comment 5 fropeter 2016-09-08 20:15:20 UTC
I tried dnf-2.0 from copt repo.

[~]$ dnf list --installed gedit.x86_64
Unknown configuration value: failovermethod=roundrobin; 'roundrobin' value is not implemented
Unknown configuration value: failovermethod=roundrobin; 'roundrobin' value is not implemented
Unknown configuration value: failovermethod=roundrobin; 'roundrobin' value is not implemented
Last metadata expiration check: 0:01:20 ago on Thu Sep 08 21:58:20 2016 CEST.
Installed Packages
gedit.x86_64                       2:3.20.2-1.fc24                       @fedora
[~]$ echo $?
0
[~]$

It works, and I suppose the warnings will disappear in released code.
Here are the rest of the results, without the warnings:

[~]$ dnf list --available gedit.x86_64
Last metadata expiration check: 0:00:50 ago on Thu Sep 08 21:58:20 2016 CEST.
Error: No matching Packages to list
[~]$ echo $?
1
[~]$

[~]$ dnf list --installed gedit.i686
Last metadata expiration check: 0:13:12 ago on Thu Sep 08 21:58:20 2016 CEST.
Error: No matching Packages to list
[frode@localhost ~]$ echo $?
1
[~]$ 

[~]$ dnf list --available gedit.i686
Last metadata expiration check: 0:14:36 ago on Thu Sep 08 21:58:20 2016 CEST.
Available Packages
gedit.i686                        2:3.20.2-1.fc24                         fedora
[frode@localhost ~]$ echo $?
0
[frode@localhost ~]$ 

I'd consider this fixed. Thank you!

Comment 6 fropeter 2016-09-08 20:24:24 UTC
BTW: I suppose the copt version of dnf isn't safe to use for day to day use, correct? Will dnf 2.0 make the F25 deadline?

Comment 7 Parag Nemade 2016-09-09 05:27:49 UTC
Its Copr not copt :)


Note You need to log in before you can comment on or make changes to this bug.