RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2119691 - Lack of "leaves options" in the DNF replacement for package-cleanup
Summary: Lack of "leaves options" in the DNF replacement for package-cleanup
Keywords:
Status: CLOSED DUPLICATE of bug 2134638
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: dnf
Version: 8.6
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Jaroslav Mracek
QA Contact: swm-qe
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-08-19 07:45 UTC by Christophe Besson
Modified: 2023-03-20 13:49 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-03-20 11:17:08 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-131515 0 None None None 2022-08-19 07:48:14 UTC

Description Christophe Besson 2022-08-19 07:45:46 UTC
Description of problem:
RHEL 7 (and RHEL 6 as well) provided a set of features for which there is no obvious replacement. The customer was using the below command to find out the RPMs that were installed on the host on which nothing else currently installed depends.

On RHEL 6/7:
# /usr/bin/package-cleanup --disablerepo="*" --enablerepo="ipgtest" --noplugins --leaves --leaf-regex="^(ipg)"
ipg-foo-1.0-1.noarch

On RHEL 8:
# /usr/bin/package-cleanup --disablerepo="*" --enablerepo="ipgtest" --noplugins --leaves --leaf-regex="^(ipg)"
usage: dnf repoquery [-c [config file]] [-q] [-v] [--version]
 <--cut-->
dnf repoquery: error: unrecognized arguments: --leaf-regex=^(ipg)

The command "package-cleanup --leaves" has been mapped to "dnf repoquery --unneeded". Both commands return the same output, which is limited to the libraries. It seems there are no alternatives for the --all and --leaf-regex options:

LEAVES OPTIONS
       --all  When listing leaf nodes also list leaf nodes that are not libraries.

       --leaf-regex
              A package name that matches this regular expression will be considered a leaf.

       --exclude-devel
              When listing leaf nodes do not list development packages.

       --exclude-bin
              When listing leaf nodes do not list packages with files in bin directories.


Version-Release number of selected component (if applicable):
dnf-4.7.0-8.el8.noarch
libdnf-0.63.0-8.el8.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Create a set of 3 fake RPMs, ipg-foo depending on ipg-bar, itself depending on ipg-baz (without any dep)
2. Put them in a repo and install them
3. Run the command mentioned in the description

Actual results:
dnf repoquery: error: unrecognized arguments: --leaf-regex=^(ipg)

Expected results:
Implement old options or provides an alternative.

Additional info:
As a workaround, the customer uses the RPM command to see which packages have no deps on the installed system:

# for i in `rpm -q -g ipg` ; do rpm --test -e $i 2>/dev/null && echo $i ; done

Comment 1 Jaroslav Mracek 2022-08-27 17:23:42 UTC
Thank you very much for the report. There are two different approaches how to manage leave packages on the system. The first of all - using reason - internal information how package was installed to the system. The information is used for removal operation or by `dnf autoremove` to remove unused dependencies.

Or using leave plugin that compute dependencies tree and then report the top packages as leave.

For systems that are deployed and maintain by dnf (including Anaconda) the first approach is sufficient.

To check all reasons for installed packages you can use 'dnf repoquery --installed --qf "%{name}.%{arch} %{reason}"'

As you can see it is not easy subject therefore we need more specific information what the customer want to achieved rather how it was achieved in the past.

Comment 2 Christophe Besson 2022-08-31 13:58:40 UTC
The reason can give the same result most of the time, but it's not the same.
If the user installed all packages with a glob (dnf install ipg-*), the reason will be "user" for the 3 pkgs.
Whereas the previous command printed only "ipg-foo" in both cases because it has no dependency.

--unneeded gives only a subset (the libs) of `package-cleanup --leaves --all`.
Indeed the DNF leave plugin would help to provide the same feature but AFAICS it does not seem shipped with RHEL 8.
I can see leaves.py in the src.rpm, but the file is not included in the dnf-plugins-core rpm or in a separate pkg (python3-dnf-leaves?)

Comment 4 Jaroslav Mracek 2023-02-17 09:26:04 UTC
Leave plugin is not yet available in RHEL but it is available in Fedora - therefore for testing you can use a fedora build (documentation - https://dnf-plugins-core.readthedocs.io/en/latest/leaves.html). We've got a request to delivery the leave plugin to RHEL -Bug 2134638 - Please enable the leaves and show-leaves DNF plugins. If you think that this is a solution, I will close the bug as a duplicate.

Do you need anything specific for testing for leave plugin?

What we could - add leave and show-leaves plugin to RHEL9

What would be very difficult - add a new option, plugin to RHEL8 - to late in lifecycle of RHEL8

I have suggestion for RHEL8

If you use `dnf install ipg-*` all of packages matching `ipg-*` are marked as user installed. If user don't want to handle them as user installed - it is possible to mark them as dependency -
`dnf mark remove ipg-*` and then mark some of the packages from them as a user installed `dnf mark install ipg-<something>`. See documentation - https://dnf.readthedocs.io/en/latest/command_ref.html#mark-command-label


If the workaround is ok and the solution for RHEL9 is not acceptable for the customer - then I will close it as wontfix.

May I ask you to share with me your preferences how to handle the bug report?

Comment 5 Jaroslav Mracek 2023-03-20 11:17:08 UTC
Because there is no response I am closing the bug as duplicate with bug requesting Leave and show leave plugin in RHEL9.

*** This bug has been marked as a duplicate of bug 2134638 ***

Comment 6 Christophe Besson 2023-03-20 13:49:21 UTC
Sorry for the late reply, it has been suggested to the customer last week but no feedback.
It is indeed late for the RHEL 8 lifecycle.


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