2

Linux distribution: Red Hat Enterprise Linux Server release 6.10 (Santiago)

Context:
I need to uninstall all old versions of Java in my server.
I have the list of java paths, example:

/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.201.b09-2.el6_10.x86_64/jre/bin/java

I can find the pacakage owning this file by:

rpm -qf /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.201.b09-2.el6_10.x86_64/jre/bin/java
java-1.8.0-openjdk-headless-1.8.0.201.b09-2.el6_10.x86_64

Now, how to find all packages depending on java-1.8.0-openjdk-headless-1.8.0.201.b09-2.el6_10.x86_64 , so that I can see whether it is safe to remove the package ?

Below command says no other packages depends on this openjdk package (Ref: Question-166343):

rpm -q --whatrequires  java-1.8.0-openjdk-headless-1.8.0.201.b09-2.el6_10.x86_64
no package requires java-1.8.0-openjdk-headless-1.8.0.201.b09-2.el6_10.x86_64

But, mysql-connector-java depends on this package.
Reason: rpm --whatrequires option's argument is CAPABILITY provided by a package , not package name and searching using CAPABILITY is not straightforward.

Below command was also not returning any results:

repoquery --requires --resolve --recursive java-1.8.0-openjdk-headless-1.8.0.201.b09-2.el6_10.x86_64

So, is there any simple way to identify all rpm packages which depends on a particular package?
By package , I mean java-1.8.0-openjdk-headless-1.8.0.201.b09-2.el6_10.x86_64 (not java-1.8.0-openjdk-headless)

5
  • Did you install the java package via yum? Mar 28, 2019 at 0:43
  • Yes. Installed via yum.
    – penguin
    Mar 28, 2019 at 0:44
  • Add the script that you have so far to your question. Mar 28, 2019 at 2:06
  • I see in other questions the "yum deplist" option; alternatively, you could run a test-remove: yum --assumeno ... or rpm --test ...
    – Jeff Schaller
    Mar 28, 2019 at 2:26
  • @JeffSchaller yum deplist would show the packages on which it depends but not what depends on the package itself. Mar 28, 2019 at 2:49

1 Answer 1

3

Try this,

Normally rpm -e doesn't uninstall a package if there are other packages that are dependent on this package [ of course --nodeps can be used to by pass this ]. As @JeffSchaller mentioned rpm -e can also be used in conjunction with --test to see if there are any error: Failed dependencies:

--test Don’t really uninstall anything, just go through the motions.  Useful in conjunction with the -vv option for debugging.

rpm -e -vv <package_name> -- check for error: Failed dependencies:

or

rpm -e -vv --test <package_name> -- check for error: Failed dependencies:

For more refer man rpm

1
  • An example I used: rpm -e mysql --test -vv 2>&1 | grep 'Failed dependencies'
    – penguin
    Mar 28, 2019 at 22:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .