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

Show which packages are installed in the search command output #1114

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

blazra
Copy link

@blazra blazra commented Dec 30, 2023

Apends " [installed]" to the end of the line if the package is installed.

Example output:

> dnf5 search dolphin
Updating and loading repositories:
Repositories loaded.
Matched fields: name (exact)
 dolphin.aarch64: KDE File Manager [installed]
Matched fields: name, summary
 dolphin-connector-devel.aarch64: Development files for Dolphin Connector
 dolphin-devel.aarch64: Developer files for dolphin
 dolphin-emu-data.noarch: Dolphin Emulator data files
 dolphin-emu-nogui.aarch64: Dolphin Emulator without a graphical user interface
 dolphin-emu-tool.aarch64: Dolphin Emulator CLI utility
 dolphin-libs.aarch64: Dolphin runtime libraries [installed]
 dolphin-plugins.aarch64: Dolphin plugins for revision control systems [installed]
 mat2-dolphin.noarch: Dolphin integration for mat2
 nextcloud-client-dolphin.aarch64: Dolphin overlay icons
 owncloud-client-dolphin.aarch64: Dolphin overlay icons
 tnef-dolphin.aarch64: Provides TNEF extract extension for KDE's Dolphin file manager
Matched fields: name
 dolphin-connector.aarch64: Simple MySQL C API wrapper for C++
 dolphin-emu.aarch64: GameCube / Wii / Triforce Emulator
 golang-github-seandolphin-bqschema-devel.noarch: Create Google Big Query schema directly from Go structs

Apends " [installed]" to the end of the line if the package is
installed.
@m-blaha m-blaha self-assigned this May 14, 2024
Copy link
Member

@m-blaha m-blaha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay.

Although I appreciate the idea of identifying the installed packages in the search command output, there is an issue with your implementation.

Here is a high-level overview of what the search command does:

  1. Prepares a query with all the packages.
  2. If the --showduplicates option is not used, it retains only the highest versions of packages in the query. (see
    if (!showdupes) {
    full_package_query.filter_latest_evr();
    }
    )
  3. Searches for the given patterns in this query and prints the results.

The problem arises when a package is installed in an older version (i.e. not upgraded) and the --showduplicates option is not used (which is the default setting). In this case, the installed package will not be part of the query (since the query contains only the highest version of the package, which is not installed), and thus, the [installed] flag will not be applied.

Here is an example to illustrate this:

❯ dnf repoquery acpi
Updating and loading repositories:
Repositories loaded.
acpi-0:1.0.1-0.x86_64
acpi-0:1.7-21.fc39.x86_64

❯ dnf install acpi-0:1.0.1-0.x86_64 -y
Updating and loading repositories:
Repositories loaded.
Package                  Arch    Version                  Repository        Size
Installing:
 acpi                    x86_64  1.0.1-0                  dummyrepo      0.0   B

Transaction Summary:
 Installing:        1 package

❯ ./dnf5/dnf5 search acpi
Updating and loading repositories:
Repositories loaded.
Matched fields: name (exact), summary
 acpi.x86_64: Command-line ACPI client

❯ upgrade acpi -y
Updating and loading repositories:
Repositories loaded.
Package                  Arch    Version                  Repository        Size
Upgrading:
 acpi                    x86_64  1.7-21.fc39              fedora        51.4 KiB
   replacing acpi        x86_64  1.0.1-0                  dummyrepo      0.0   B

Transaction Summary:
 Upgrading:         1 package
 Replacing:         1 package

❯ ./dnf5/dnf5 search acpi
Updating and loading repositories:
Repositories loaded.
Matched fields: name (exact), summary
 acpi.x86_64: Command-line ACPI client [installed]

As you can see, the results of the search command differ in terms of installed package identification, depending on the version of the acpi package that was installed.

@m-blaha
Copy link
Member

m-blaha commented May 14, 2024

With older version installed and --showduplicates used, the results are correct:

❯ ./dnf5/dnf5 search acpi --showduplicates
Updating and loading repositories:
Repositories loaded.
Matched fields: name (exact), summary
 acpi-0:1.0.1-0.x86_64: Provides acpi [installed]
 acpi-0:1.7-21.fc39.x86_64: Command-line ACPI client

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants