dnf mark group <package-spec>…
Marks the specified packages as installed by group. This can be useful if any package was installed as a dependency or a user and is desired to be protected and handled as a group member like during group remove.[1]
However after my saga on trying to understand the group mark [2], I’m kinda convinced that this is broken (or doesn’t do what it says).
$ dnf repoquery --whatdepends flatpak --installed
fedora-flathub-remote-0:1-6.fc39.noarch
gnome-software-0:45.2-1.fc39.x86_64
$ sudo dnf remove fedora-flathub-remote
$ sudo dnf remove gnome-software
# Wants to remove flatpak, cancelled.
$ dnf repoquery --groupmember flatpak
flatpak-1.15.6-1.fc39.x86_64
@container-management
# Fedora Workstation has container-management by default.
$ sudo dnf mark group flatpak
$ sudo dnf remove gnome-software
# Does not remove flatpak, good.
$ sudo dnf group remove container-management
# Does not want to remove flatpak, what?!
# Checking
$ dnf repoquery --whatdepends flatpak --installed
# Nothing
$ dnf repoquery --installed --qf='%{name}-%{evr}.%{arch} (%{reason})' flatpak
flatpak-1.15.6-1.fc39.x86_64 (group)