How can I correlate dnf list and repoquery results?

When I want to find out which group a package is a member of, I use the below command:

[root@localhost ~]# dnf repoquery --groupmember gcc
Last metadata expiration check: 0:35:10 ago on Tue 07 May 2024 09:44:34 AM EDT.
  @buildsys-build
  **@c-development**
  @milkymist
  @python-classroom

But it returns information that is not found in the group list:

[root@localhost ~]# dnf group list
Last metadata expiration check: 0:35:18 ago on Tue 07 May 2024 09:44:34 AM EDT.
Available Groups:
   3D Printing
   Ansible node
   Audio Production
   Authoring and Publishing
   Books and Guides
   **C Development Tools and Libraries**
   Cloud Infrastructure
   Cloud Management Tools
...

Is it possible to display the same items in the output of either command, i.e. @c-development in group list or vice versa: C Development Tools and Libraries in repoquery --groupmember?

1 Like

Use for example dnf group info c-development.

dnf grouplist --verbose shows snake case group names shown on your first output.

Although it does append groupspecs to group names, it also dumps tons of crap before the groups which makes the scripting of the output much more difficult.

As in:

Loaded plugins: builddep, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, needs-restarting, playground, repoclosure, repograph, repomanage, reposync, system-upgrade
DNF version: 2.7.5
cachedir: /var/tmp/dnf-use0-zsd3ywk1
repo: using cache for: updates
updates: using metadata from Mon 27 May 2019 09:02:49 PM EDT.
repo: using cache for: fedora
not found deltainfo for: Fedora ...
...
rpmfusion-nonfree: using metadata from Tue 24 Apr 2018 07:02:59 PM EDT.
Last metadata expiration check: 0:26:18 ago on Tue 07 May 2024 03:09:36 PM EDT.
Missing file *modules.yaml in metadata cache dir: /var/tmp/dnf-user01-zsd3ywk1/updates-8bd9ef368505a5fd
Missing file *modules.yaml in metadata cache dir: /var/tmp/dnf-user01-zsd3ywk1/fedora-f21308f6293b3270
Missing file *modules.yaml in metadata cache dir: /var/tmp/dnf-user01-zsd3ywk1/packages-microsoft-com-prod-4fe2e54c8519f2a2
Missing file *modules.yaml in metadata cache dir: /var/tmp/dnf-user01-zsd3ywk1/rpmfusion-free-updates-18aab6236926d6fd
Missing file *modules.yaml in metadata cache dir: /var/tmp/dnf-user01-zsd3ywk1/rpmfusion-free-340f27dbf4d9eb4b
Missing file *modules.yaml in metadata cache dir: /var/tmp/dnf-user01-zsd3ywk1/rpmfusion-nonfree-updates-a045b1cc32738165
Missing file *modules.yaml in metadata cache dir: /var/tmp/dnf-user01-zsd3ywk1/rpmfusion-nonfree-fcea624146a658fc
group persistor md version: 0.6.0

The man page says the --ids arg, so how about this:

sudo dnf grouplist --ids | sed 's|^.*(\(.*\))|@\1|'
Last metadata expiration check: 0:37:02 ago on Wed 08 May 2024 10:18:11 BST.
Available Environment Groups:
@custom-environment
@minimal-environment
@server-product-environment
@cloud-server-environment
@kde-desktop-environment
@xfce-desktop-environment
@phosh-desktop-environment
@lxde-desktop-environment
@lxqt-desktop-environment
@cinnamon-desktop-environment
@mate-desktop-environment
@sugar-desktop-environment
@deepin-desktop-environment
@budgie-desktop-environment
@developer-workstation-environment
@web-server-environment
@infrastructure-server-environment
@basic-desktop-environment
@i3-desktop-environment
@sway-desktop-environment
Installed Environment Groups:
@workstation-product-environment
Installed Groups:
@c-development
@container-management
@desktop-accessibility
@libreoffice
@python-science
@gnome-desktop
@fonts
@hardware-support
@sound-and-video
Available Groups:
@3d-printing
@admin-tools
@audio
@authoring-and-publishing
@budgie-desktop
@budgie-desktop-apps
@cloud-infrastructure
@cloud-management
@compiz
@d-development
@design-suite
@development-tools
@domain-client
@editors
@education
@electronic-lab
@engineering-and-scientific
@freeipa-server
@headless-management
@kf6-software-development
@mate-applications
@milkymist
@network-server
@neuron-modelling-simulators
@office
@python-classroom
@robotics-suite
@rpm-development-tools
@security-lab
@swaywm-extended
@text-internet
@vlc
@window-managers
@graphical-internet
@kde-desktop
@games
@system-tools
1 Like

dnf group: error: unrecognized arguments: --ids

dnf [...] --ids works for me in F40:

% dnf --version
4.19.2
  Installed: dnf-0:4.19.2-1.fc40.noarch at Sat 20 Apr 2024 03:00:15 PM
  Built    : Fedora Project at Fri 29 Mar 2024 05:54:01 PM

  Installed: rpm-0:4.19.1.1-1.fc40.x86_64 at Sat 20 Apr 2024 02:29:43 PM
  Built    : Fedora Project at Wed 07 Feb 2024 03:55:53 PM
1 Like

Uh, how about this without the --ids:

dnf grouplist --verbose | sed 's|^.*(\(.*\))|@\1|' | grep -o "^@.*$" | sed '/Fedora Linux/ d'

I’m on F40, though, so I don’t know what the outputs on F39 are like :frowning: