Bug 1613696 - yum-plugin-remove-with-leaves does not work any more
Summary: yum-plugin-remove-with-leaves does not work any more
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: yum
Version: 7.5
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: rc
: ---
Assignee: Packaging Maintenance Team
QA Contact: BaseOS QE Security Team
URL:
Whiteboard:
Depends On:
Blocks: 1630909
TreeView+ depends on / blocked
 
Reported: 2018-08-08 07:35 UTC by GV
Modified: 2019-07-26 07:46 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-07-26 07:46:01 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 532185 0 low CLOSED --remove-leaves doesn't remove all original dependencies of python-mwlib 2021-02-22 00:41:40 UTC

Internal Links: 532185

Description GV 2018-08-08 07:35:20 UTC
Description of problem:
yum erase --remove-leaves <package-name>
fail to remove dependencies.

Version-Release number of selected component (if applicable):
1.1.31-46.el7_5

How reproducible:
# yum install java-1.8.0-openjdk-devel.x86_64
# yum erase --remove-leaves java-1.8.0-openjdk-devel

Only java-1.8.0-openjdk-devel is selected and erased.

Comment 2 Michal Domonkos 2018-08-08 16:05:43 UTC
I cannot reproduce this.  Are you sure the dependencies aren't required by anything else installed on your system?

Comment 3 GV 2018-08-08 17:22:47 UTC
[root@centos7 ~]# yum erase --remove-leaves java-1.8.0-openjdk-devel.x86_64
Loaded plugins: aliases, changelog, fastestmirror, keys, list-data, post-transaction-actions, priorities, protectbase, ps, remove-with-leaves, rpm-warm-cache, show-leaves, tmprepo, upgrade-helper, verify, versionlock
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk-devel.x86_64 1:1.8.0.181-3.b13.el7_5 will be erased
--> Finished Dependency Resolution
removing 1:java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64. It is not required by anything else.
--> Running transaction check
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.181-3.b13.el7_5 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================================================================================================
 Package                                                              Arch                                               Version                                                             Repository                                            Size
========================================================================================================================================================================================================================================================
Removing:
 java-1.8.0-openjdk                                                   x86_64                                             1:1.8.0.181-3.b13.el7_5                                             @updates                                             501 k
 java-1.8.0-openjdk-devel                                             x86_64                                             1:1.8.0.181-3.b13.el7_5                                             @updates                                              40 M

Transaction Summary
========================================================================================================================================================================================================================================================
Remove  2 Packages

Installed size: 41 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 1:java-1.8.0-openjdk-devel-1.8.0.181-3.b13.el7_5.x86_64                                                                                                                                                                              1/2 
  Erasing    : 1:java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64                                                                                                                                                                                    2/2 
  Verifying  : 1:java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64                                                                                                                                                                                    1/2 
  Verifying  : 1:java-1.8.0-openjdk-devel-1.8.0.181-3.b13.el7_5.x86_64                                                                                                                                                                              2/2 

Removed:
  java-1.8.0-openjdk.x86_64 1:1.8.0.181-3.b13.el7_5                                                                       java-1.8.0-openjdk-devel.x86_64 1:1.8.0.181-3.b13.el7_5                                                                      

Complete!
New leaves:
  giflib.x86_64
  java-1.8.0-openjdk-headless.x86_64
  libXtst.x86_64
  xorg-x11-fonts-Type1.noarch
[root@centos7 ~]#

Comment 4 GV 2018-08-08 17:27:56 UTC
But, if I restore the virtual machine to original state I always have this behaviour (multiple machines):

ssh ...
# yum update --exclude=kernel* -y
....
Complete!
New leaves:
  java-1.8.0-openjdk-devel.x86_64

[root@centos7 ~]# yum erase --remove-leaves java-1.8.0-openjdk-devel.x86_64
Loaded plugins: aliases, changelog, fastestmirror, keys, list-data, post-transaction-actions, priorities, protectbase, ps, remove-with-leaves, rpm-warm-cache, show-leaves, tmprepo, upgrade-helper, verify, versionlock
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk-devel.x86_64 1:1.8.0.181-3.b13.el7_5 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================================================================================================
 Package                                                              Arch                                               Version                                                             Repository                                            Size
========================================================================================================================================================================================================================================================
Removing:
 java-1.8.0-openjdk-devel                                             x86_64                                             1:1.8.0.181-3.b13.el7_5                                             @updates                                              40 M

Transaction Summary
========================================================================================================================================================================================================================================================
Remove  1 Package

Installed size: 40 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 1:java-1.8.0-openjdk-devel-1.8.0.181-3.b13.el7_5.x86_64                                                                                                                                                                              1/1 
  Verifying  : 1:java-1.8.0-openjdk-devel-1.8.0.181-3.b13.el7_5.x86_64                                                                                                                                                                              1/1 

Removed:
  java-1.8.0-openjdk-devel.x86_64 1:1.8.0.181-3.b13.el7_5                                                                                                                                                                                               

Complete!
New leaves:
  java-1.8.0-openjdk.x86_64
[root@centos7 ~]# yum erase --remove-leaves java-1.8.0-openjdk.x86_64
Loaded plugins: aliases, changelog, fastestmirror, keys, list-data, post-
              : transaction-actions, priorities, protectbase, ps, remove-with-
              : leaves, rpm-warm-cache, show-leaves, tmprepo, upgrade-helper,
              : verify, versionlock
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.181-3.b13.el7_5 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package               Arch      Version                      Repository   Size
================================================================================
Removing:
 java-1.8.0-openjdk    x86_64    1:1.8.0.181-3.b13.el7_5      @updates    501 k
Transaction Summary
================================================================================
Remove  1 Package

Installed size: 501 k
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 1:java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64            1/1 
  Verifying  : 1:java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64            1/1 

Removed:
  java-1.8.0-openjdk.x86_64 1:1.8.0.181-3.b13.el7_5                             

Complete!
New leaves:
  alsa-lib.x86_64
  giflib.x86_64
  java-1.8.0-openjdk-headless.x86_64
  libXtst.x86_64
  xorg-x11-fonts-Type1.noarch
[root@centos7 ~]# 

An so on (java-1.8.0-openjdk-headless.x86_64, etc).

Comment 5 Michal Domonkos 2018-08-09 10:50:24 UTC
Could you please post the output of the following commands (from before you do "yum erase"):

# rpm -q --whatrequires alsa-lib giflib java-1.8.0-openjdk-headless
# yum erase -d10 --remove-leaves java-1.8.0-openjdk.x86_64

Comment 6 GV 2018-08-09 11:02:58 UTC
[root@centos7 ~]# rpm -q --whatrequires alsa-lib giflib java-1.8.0-openjdk-headless
no package requires alsa-lib
no package requires giflib
no package requires java-1.8.0-openjdk-headless
[root@centos7 ~]# yum erase -d10 --remove-leaves java-1.8.0-openjdk.x86_64
Loading "aliases" plugin
Loading "changelog" plugin
Loading "fastestmirror" plugin
Loading "keys" plugin
Loading "list-data" plugin
Loading "post-transaction-actions" plugin
Loading "priorities" plugin
Loading "protectbase" plugin
Loading "ps" plugin
Loading "remove-with-leaves" plugin
Loading "rpm-warm-cache" plugin
Loading "show-leaves" plugin
Loading "tmprepo" plugin
Loading "upgrade-helper" plugin
Loading "verify" plugin
Loading "versionlock" plugin
Config time: 0.037
Yum version: 3.4.3
rpmdb time: 0.000
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.171-7.b10.el7 will be erased
Checking deps for java-1.8.0-openjdk.x86_64 1:1.8.0.171-7.b10.el7 - e
1:java-1.8.0-openjdk-devel-1.8.0.171-7.b10.el7.x86_64 requires: java-1.8.0-openjdk(x86-64) = 1:1.8.0.171-7.b10.el7
--> Processing Dependency: java-1.8.0-openjdk(x86-64) = 1:1.8.0.171-7.b10.el7 for package: 1:java-1.8.0-openjdk-devel-1.8.0.171-7.b10.el7.x86_64
Needed Require is not a package name. Looking up: java-1.8.0-openjdk(x86-64) = 1:1.8.0.171-7.b10.el7
Potential Provider: java-1.8.0-openjdk.x86_64 1:1.8.0.171-7.b10.el7
Mode is e for provider of java-1.8.0-openjdk(x86-64) = 1:1.8.0.171-7.b10.el7: java-1.8.0-openjdk.x86_64 1:1.8.0.171-7.b10.el7
Mode for pkg providing java-1.8.0-openjdk(x86-64) = 1:1.8.0.171-7.b10.el7: e
TSINFO: 1:java-1.8.0-openjdk-devel-1.8.0.171-7.b10.el7.x86_64 package requiring java-1.8.0-openjdk(x86-64) marked as erase
1:java-1.8.0-openjdk-devel-1.8.0.171-7.b10.el7.x86_64 requires: libawt_xawt.so()(64bit)
--> Processing Dependency: libawt_xawt.so()(64bit) for package: 1:java-1.8.0-openjdk-devel-1.8.0.171-7.b10.el7.x86_64
1:java-1.8.0-openjdk-devel-1.8.0.171-7.b10.el7.x86_64 requires: libawt_xawt.so(SUNWprivate_1.1)(64bit)
--> Processing Dependency: libawt_xawt.so(SUNWprivate_1.1)(64bit) for package: 1:java-1.8.0-openjdk-devel-1.8.0.171-7.b10.el7.x86_64
--> Running transaction check
---> Package java-1.8.0-openjdk-devel.x86_64 1:1.8.0.171-7.b10.el7 will be erased
Checking deps for java-1.8.0-openjdk-devel.x86_64 1:1.8.0.171-7.b10.el7 - e
--> Finished Dependency Resolution
Dependency Process ending
Depsolve time: 0.835

Dependencies Resolved

================================================================================
 Package                    Arch     Version                   Repository  Size
================================================================================
Removing:
 java-1.8.0-openjdk         x86_64   1:1.8.0.171-7.b10.el7     @updates   501 k
Removing for dependencies:
 java-1.8.0-openjdk-devel   x86_64   1:1.8.0.171-7.b10.el7     @updates    40 M

Transaction Summary
================================================================================
Remove  1 Package (+1 Dependent package)

Installed size: 41 M
Is this ok [y/N]: 
Downloading packages:
Member: java-1.8.0-openjdk.x86_64 1:1.8.0.171-7.b10.el7 - e
Removing Package 1:java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64
Member: java-1.8.0-openjdk-devel.x86_64 1:1.8.0.171-7.b10.el7 - e
Removing Package 1:java-1.8.0-openjdk-devel-1.8.0.171-7.b10.el7.x86_64
Running transaction check
Transaction check time: 0.003
Running transaction test
Transaction test succeeded
Transaction test time: 0.140
Running transaction
  Erasing    : 1:java-1.8.0-openjdk-devel-1.8.0.171-7.b10.el7.x86_64        1/2 
  Erasing    : 1:java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64              2/2 
  Verifying  : 1:java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64              1/2 
  Verifying  : 1:java-1.8.0-openjdk-devel-1.8.0.171-7.b10.el7.x86_64        2/2 
VerifyTransaction time: 0.164
Transaction time: 1.853

Removed:
  java-1.8.0-openjdk.x86_64 1:1.8.0.171-7.b10.el7                               

Dependency Removed:
  java-1.8.0-openjdk-devel.x86_64 1:1.8.0.171-7.b10.el7                         

Complete!
New leaves:
  alsa-lib.x86_64
  giflib.x86_64
  java-1.8.0-openjdk-headless.x86_64
  libXtst.x86_64
  xorg-x11-fonts-Type1.noarch
[root@centos7 ~]#

Comment 7 Michal Domonkos 2018-08-09 16:42:17 UTC
It seems that the leaf packages (such as giflib) required by java-1.8.0-openjdk that you would normally expect to be removed by the plugin have been installed manually via a "yum install <pkgname>" (so-called "user-installed").  Looking at the code, I cannot see any other reason for the plugin not picking these up.

Whether that's the case, you can check with yumdb (shipped with yum-utils):
# yumdb get reason giflib
giflib-4.1.6-9.el7.x86_64
     reason = user

The remove-with-leaves plugin skips such user-installed packages (and it's not possible to configure it otherwise, unfortunately).

Comment 8 GV 2018-08-10 07:05:36 UTC
[root@centos7 ~]# yum history info 35
Loaded plugins: aliases, changelog, fastestmirror, keys, list-data, post-
              : transaction-actions, priorities, protectbase, ps, remove-with-
              : leaves, rpm-warm-cache, show-leaves, tmprepo, upgrade-helper,
              : verify, versionlock
Transaction ID : 35
Begin time     : Fri Sep 15 21:02:41 2017
Begin rpmdb    : 398:67b56f52c4b10dec8f1ce902f47defaeb1f188b8
End time       :            21:02:47 2017 (6 seconds)
End rpmdb      : 414:cb6d6ff37bf955d7e82b4971c79736ee08ba74f1
User           : root <root>
Return-Code    : Success
Command Line   : install alsa-lib.x86_64 copy-jdk-configs.noarch giflib.x86_64 java-1.8.0-openjdk-devel.x86_64 java-1.8.0-openjdk-headless.x86_64 java-1.8.0-openjdk.x86_64 javapackages-tools.noarch libXtst.x86_64 lksctp-tools.x86_64 ncurses-devel.x86_64 nss-pem.x86_64 python-javapackages.noarch python-lxml.x86_64 ttmkfdir.x86_64 tzdata-java.noarch xorg-x11-fonts-Type1.noarch
Transaction performed with:
    Updated       rpm-4.11.3-21.el7.x86_64                      @base
    Updated       yum-3.4.3-150.el7.centos.noarch               @base
    Updated       yum-plugin-aliases-1.1.31-40.el7.noarch       @base
    Updated       yum-plugin-fastestmirror-1.1.31-40.el7.noarch @base
Packages Altered:
    Install alsa-lib-1.1.3-3.el7.x86_64                                @base
    Install copy-jdk-configs-2.2-3.el7.noarch                          @base
    Install giflib-4.1.6-9.el7.x86_64                                  @base
    Install java-1.8.0-openjdk-1:1.8.0.144-0.b01.el7_4.x86_64          @updates
    Install java-1.8.0-openjdk-devel-1:1.8.0.144-0.b01.el7_4.x86_64    @updates
    Install java-1.8.0-openjdk-headless-1:1.8.0.144-0.b01.el7_4.x86_64 @updates
    Install javapackages-tools-3.4.1-11.el7.noarch                     @base
    Install libXtst-1.2.3-1.el7.x86_64                                 @base
    Install lksctp-tools-1.0.17-2.el7.x86_64                           @base
    Updated ncurses-5.9-13.20130511.el7.x86_64                         @anaconda
    Update          5.9-14.20130511.el7_4.x86_64                       @updates
    Updated ncurses-base-5.9-13.20130511.el7.noarch                    @anaconda
    Update               5.9-14.20130511.el7_4.noarch                  @updates
    Install ncurses-devel-5.9-14.20130511.el7_4.x86_64                 @updates
    Updated ncurses-libs-5.9-13.20130511.el7.x86_64                    @anaconda
    Update               5.9-14.20130511.el7_4.x86_64                  @updates
    Updated nspr-4.11.0-1.el7_2.x86_64                                 @base
    Update       4.13.1-1.0.el7_3.x86_64                               @base
    Updated nss-3.21.3-2.el7_3.x86_64                                  @updates
    Update      3.28.4-11.el7_4.x86_64                                 @updates
    Install nss-pem-1.0.3-4.el7.x86_64                                 @base
    Updated nss-softokn-3.16.2.3-14.4.el7.x86_64                       @base
    Update              3.28.3-8.el7_4.x86_64                          @updates
    Updated nss-softokn-freebl-3.16.2.3-14.4.el7.x86_64                @base
    Update                     3.28.3-8.el7_4.x86_64                   @updates
    Updated nss-sysinit-3.21.3-2.el7_3.x86_64                          @updates
    Update              3.28.4-11.el7_4.x86_64                         @updates
    Updated nss-tools-3.21.3-2.el7_3.x86_64                            @updates
    Update            3.28.4-11.el7_4.x86_64                           @updates
    Updated nss-util-3.21.3-1.1.el7_3.x86_64                           @updates
    Update           3.28.4-3.el7.x86_64                               @base
    Install python-javapackages-3.4.1-11.el7.noarch                    @base
    Install python-lxml-3.2.1-4.el7.x86_64                             @base
    Install ttmkfdir-3.0.9-42.el7.x86_64                               @base
    Install tzdata-java-2017b-1.el7.noarch                             @base
    Install xorg-x11-fonts-Type1-7.5-9.el7.noarch                      @base
history info
[root@centos7 ~]# 

It seems strange that yum-plugin-show-leaves can identify leaves but yum-plugin-remove-with-leaves is not able to. I always based on this (since the early times then yum-plugin-remove-with-leaves was added to repository in Fedora).

Comment 9 Michal Domonkos 2018-08-10 12:54:34 UTC
(In reply to Gabriel VLASIU from comment #8)
> [root@centos7 ~]# yum history info 35
> Loaded plugins: aliases, changelog, fastestmirror, keys, list-data, post-
>               : transaction-actions, priorities, protectbase, ps,
> remove-with-
>               : leaves, rpm-warm-cache, show-leaves, tmprepo, upgrade-helper,
>               : verify, versionlock
> Transaction ID : 35
> Begin time     : Fri Sep 15 21:02:41 2017
> Begin rpmdb    : 398:67b56f52c4b10dec8f1ce902f47defaeb1f188b8
> End time       :            21:02:47 2017 (6 seconds)
> End rpmdb      : 414:cb6d6ff37bf955d7e82b4971c79736ee08ba74f1
> User           : root <root>
> Return-Code    : Success
> Command Line   : install alsa-lib.x86_64 copy-jdk-configs.noarch
> giflib.x86_64 java-1.8.0-openjdk-devel.x86_64
> java-1.8.0-openjdk-headless.x86_64 java-1.8.0-openjdk.x86_64
> javapackages-tools.noarch libXtst.x86_64 lksctp-tools.x86_64
> ncurses-devel.x86_64 nss-pem.x86_64 python-javapackages.noarch
> python-lxml.x86_64 ttmkfdir.x86_64 tzdata-java.noarch
> xorg-x11-fonts-Type1.noarch

Yup, this explains it.  Those packages were recorded as "user-installed" and thus won't be removed by the yum-plugin-remove-with-leaves plugin.

> It seems strange that yum-plugin-show-leaves can identify leaves but
> yum-plugin-remove-with-leaves is not able to. I always based on this (since
> the early times then yum-plugin-remove-with-leaves was added to repository
> in Fedora).

Actually, looking at the commit log, it turns out this check wasn't always present; it was only introduced later (in 2010):

commit 90ea69cc7589160735fc67f341db210403bc7f6f
Author: Casey Jao <cjao.edu>
Date:   Mon Sep 20 09:35:40 2010 -0400

    Remove-with-leaves plugin: check install reason

diff --git a/plugins/remove-with-leaves/remove-with-leaves.py b/plugins/remove-with-leaves/remove-with-leaves.py
index a808aef..db6d489 100644
--- a/plugins/remove-with-leaves/remove-with-leaves.py
+++ b/plugins/remove-with-leaves/remove-with-leaves.py
@@ -88,6 +88,11 @@ def postresolve_hook(conduit):
                             continue # skip ones already marked for remove, kinda pointless
                         if pkg.name in ignore_list: # there are some pkgs which are NEVER going to be leafremovals
                             continue
+
+                        # Skip manually installed packages.
+                        if pkg.yumdb_info.get('reason') == 'user':
+                            continue
+
                         non_removed_requires = []
                         for req_pkgtup in _requires_this_package(rpmdb,pkg):
                             pkgtups = [ txmbr.po.pkgtup for txmbr in tsInfo.getMembersWithState(output_states=[TS_ERASE]) ]

Comment 10 Karel Srot 2018-11-12 08:36:35 UTC
So this is not a bug then?

Comment 11 Michal Domonkos 2018-11-12 12:03:47 UTC
Yes, I believe it has been explained clearly why this is expected behavior (I just forgot to close the BZ as such), thanks for the reminder, Karel.

Comment 12 GV 2018-11-12 12:46:02 UTC
What use can someone have for this plugin if it cannot erase with all leaves a package anymore? It does not matter how the rpm package has been installed.

The plugin does not nothing by default until instructed to do so. And if someone_explicity_ ask for removal of all packages that are leaves for that package (--remove-leaves switch) it does nothing. 

What's next? yum erase does not erase packages because they are manually installed?

This is A bug!

Comment 13 Michal Domonkos 2018-11-12 13:46:50 UTC
As per the plugin's description:

"This plugin removes any unused dependencies that were brought in by an install but would not normally be removed."

Note the word "unused".  User-installed packages can be thought of as "used" since the user deliberately installed them at some point and it's likely they don't want those packages to be removed just because no other package requires them any more (the user still does, in fact).

The root cause of your issue is that you installed all those packages (including their dependencies) manually with "yum install" (Comment 8).  The plugin simply didn't consider such corner cases; normally, the dependencies are resolved and pulled into the transaction by yum itself, in which case they are not marked as user-installed.

Since there was no reply to my last comment 9 with the reasoning, I considered the issue resolved.  I'm sorry if it didn't meet your expectations.  I'm open to suggestions as to how this should be fixed then.  Please note we cannot simply revert the 2010 patch now because we would break for a lot of people out there who count on it.

However, I do agree it's not clearly documented, and that we can fix.  I'll reopen this BZ to track that.

Comment 14 GV 2018-11-12 14:11:40 UTC
> The root cause of your issue is that you installed all those packages (including their dependencies) manually with "yum install" (Comment 8).

No entirely true.

Let's say I do "yum install xxx".
xxx will bring dependencies yyy and zzz.

Now, "yum erase --remove-leaves xxx" will not remove yyy and zzz. I did not ask for them to be installed in the first place but they must be installed.

I would like them to be removed if I remove xxx package if they are not required by any other installed package.

To remove a java package and all dependencies I have to run yum erase several times (7 or 8 - I don't remember). 

It's not like I can't fix this crap with a single line of perl (remove the two lines of code) and make this permanent with yum-plugin-post-transaction-actions. I just don't to do that.

Thank you.

Comment 15 Michal Domonkos 2018-11-12 16:14:31 UTC
(In reply to GV from comment #14)
> No entirely true.
> 
> Let's say I do "yum install xxx".
> xxx will bring dependencies yyy and zzz.
> 
> Now, "yum erase --remove-leaves xxx" will not remove yyy and zzz. I did not
> ask for them to be installed in the first place but they must be installed.

Can you please give me a concrete example (steps to reproduce) where this doesn't work for you?  The use case you described above is the very basic one that really should work.

Comment 16 Michal Domonkos 2018-11-13 08:13:35 UTC
I have looked into the implementation of the plugin a bit more.  This is the outline of the algorithm:

for each package to be removed:
    for each requirement of package:
        if requirement not required by anything not to be removed:
            mark it for removal

This has a few issues:

1) it only removes the first level of the dependency tree; for example, if X requires Y which requires Z, only X and Y will be removed (not Z)

2) it doesn't consider reverse dependencies; for example, if X requires Y which requires Z and Z requires Y, only X will be removed (not Y or Z); that's because the algorithm simply sees that Y is required by something (even though the something is actually a dependency brought by Y)

Fixing these issues would mean changing the default behavior (and rewriting the whole plugin almost from scratch), which we cannot afford at this point, as I previously mentioned.

What I also didn't realize initially is that, in 2010, the plugin was deprecated and the same functionality was added to YUM core as the clean_requirements_on_remove config option:

commit 862cde3a0cca43824c30c57b0af5dc330eb58fff
Author: Seth Vidal <skvidal>
Date:   Fri Nov 5 17:39:28 2010 -0400

    add the functionality of remove_with_leaves to core

    - works much better than remove_with_leaves
    - better output
    - config makes more sense: clean_requirements_on_remove = BoolOption(False)
    - uses yumdb.reason to drive it - dep-installs only
    - testing and opt required

You can use it as follows:

# yum --setopt=clean_requirements_on_remove=1 remove java-1.8.0-openjdk-devel

This algorithm is much more robust and doesn't suffer from the issues mentioned above.

Comment 17 GV 2018-11-13 08:36:09 UTC
# yum --setopt=clean_requirements_on_remove=1 remove java-1.8.0-openjdk-devel
Loaded plugins: aliases, changelog, fastestmirror, keys, list-data, post-
              : transaction-actions, priorities, protectbase, ps, remove-with-
              : leaves, rpm-warm-cache, show-leaves, tmprepo, upgrade-helper,
              : verify, versionlock
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk-devel.x86_64 1:1.8.0.191.b12-0.el7_5 will be erased
--> Finished Dependency Resolution
--> Finding unneeded leftover dependencies
Found and removing 0 unneeded dependencies

Dependencies Resolved

================================================================================
 Package                    Arch     Version                   Repository  Size
================================================================================
Removing:
 java-1.8.0-openjdk-devel   x86_64   1:1.8.0.191.b12-0.el7_5   @updates    40 M

Transaction Summary
================================================================================
Remove  1 Package

Installed size: 40 M
Is this ok [y/N]: 

So, it does not work.

I can understand that rewriting the plugin is not feasible.

But, maybe, adding an option like --remove-all-leaves / clean_all_requirements_on_remove that will bypass the code from commit 90ea69cc7589160735fc67f341db210403bc7f6f / 862cde3a0cca43824c30c57b0af5dc330eb58fff will do.

Since the yum/yum plugin is written in python I can't do it myself.

So, for now, I will stick to removing the code from commit 90ea69cc7589160735fc67f341db210403bc7f6f and make-it permanent with yum-plugin-post-transaction-actions. It's not nice but I have no choice.

Thank you.

Comment 18 Michal Domonkos 2018-11-13 09:01:47 UTC
(In reply to GV from comment #17)
> Dependencies Resolved
> 
> =============================================================================
> ===
>  Package                    Arch     Version                   Repository 
> Size
> =============================================================================
> ===
> Removing:
>  java-1.8.0-openjdk-devel   x86_64   1:1.8.0.191.b12-0.el7_5   @updates   
> 40 M
> 
> Transaction Summary
> =============================================================================
> ===
> Remove  1 Package

I'm sorry, I forgot to note that, regarding user-installed dependencies, clean_requirements_on_remove applies the same logic as the original remove-with-leaves plugin (see Comment 7 for details).  That's hard-coded and cannot be overridden with any setting at the moment (other than editing source code).

Yes, there could be an option to override that check.  We will consider that.

Comment 19 Michal Domonkos 2018-11-13 14:48:46 UTC
(In reply to Michal Domonkos from comment #18)
> Yes, there could be an option to override that check.  We will consider that.

OK, we will not.

It turns out the ability to ignore user-installed packages with clean_requirements_on_remove=1 would not be as trivial as I thought initially.  It's not a matter of adding a simple if-condition; the whole logic would have to be reworked.

On the other hand, doing this in the remove-with-leaves plugin would be trivial, however it would still not fix the scenarios with reverse deps (see Comment 16), and fixing the latter is not trivial either.  It would help in this particular scenario with the java-1.8.0-openjdk-devel package, however it doesn't really make sense to introduce a new option just to cover for this specific corner case.

As I mentioned in Comment 13, we still plan to improve the documentation, though.

Comment 20 GV 2018-11-13 14:54:55 UTC
OK. Thank you anyway.

Comment 21 Michal Domonkos 2018-11-13 14:58:19 UTC
(In reply to GV from comment #20)
> OK. Thank you anyway.

Np, thank you, too!

Comment 22 Daniel Mach 2019-07-26 07:46:01 UTC
There is no plan to fix this bug during RHEL 7 life cycle.
If you still consider the issue important, please contact your support representative.


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