Listing packages in Yum that depend on another installed package
Solution 1
The rpm option you want is:
rpm -q --whatrequires sqlite
Edited: added --installed per discussion in other answers/comments
Edited: removed --installed as it is an invalid option for rpm
Solution 2
Answer
repoquery -q --installed --whatrequires sqlite
Explanations
The problem with alternative command rpm -q --whatrequires sqlite
is that it only reports dependencies on package names.
On the contrary, repoquery
also looks for non-explicit dependencies. Excerpt from manpage:
--alldeps
When used with --whatrequires, look for non-explicit dependencies in addition to explicit ones (e.g. files and Provides in addition to package names).
This is the default.
Example
Let's take package libdb
.
# rpm -q --whatrequires libdb
no package requires libdb
If we trust rpm
, no package depends on libdb
so we should be able to remove it smoothly. However...
# yum remove -y libdb
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package libdb.x86_64 0:5.3.21-19.el7 will be erased
--> Processing Dependency: libdb(x86-64) = 5.3.21-19.el7 for package: libdb-utils-5.3.21-19.el7.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: pam-1.1.8-12.el7_1.1.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: rpm-4.11.3-17.el7.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: rpm-libs-4.11.3-17.el7.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: libdb-utils-5.3.21-19.el7.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: cyrus-sasl-lib-2.1.26-20.el7_2.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: rpm-python-4.11.3-17.el7.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: python-libs-2.7.5-39.el7_2.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: rpm-devel-4.11.3-17.el7.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: rpm-build-libs-4.11.3-17.el7.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: iproute-3.10.0-54.el7_2.1.x86_64
--> Running transaction check
. . .
. . .
. . .
Error: Trying to remove "systemd", which is protected
Error: Trying to remove "yum", which is protected
As you can see some other packages were depending not directly on package libdb
, but on file libdb-5.3.so()(64bit)
provided by it.
Finally, when using repoquery
we get the real list of packages depending on libdb
:
# repoquery -q --installed --whatrequires libdb
cyrus-sasl-lib-0:2.1.26-20.el7_2.x86_64
iproute-0:3.10.0-54.el7_2.1.x86_64
libdb-utils-0:5.3.21-19.el7.x86_64
pam-0:1.1.8-12.el7_1.1.x86_64
postfix-2:2.10.1-6.el7.x86_64
python-libs-0:2.7.5-39.el7_2.x86_64
rpm-0:4.11.3-17.el7.x86_64
rpm-build-libs-0:4.11.3-17.el7.x86_64
rpm-devel-0:4.11.3-17.el7.x86_64
rpm-libs-0:4.11.3-17.el7.x86_64
rpm-python-0:4.11.3-17.el7.x86_64
Solution 3
For dnf (new version of yum) you may try with repoquery wrapper command:
dnf repoquery --whatrequires sqlite
If it is not available you may install it with command:
dnf -y install dnf-plugins-core
Solution 4
You could also try this command out.
repoquery --whatrequires sqlite
I got this command from ServerFault and also from The Fedora Forums.
Solution 5
I think what you really want to know is "what are the packages which require sqlite-3.3.6, but won't be happy with sqlite-3.4.z" ... and the only good way of finding that out, is to try it. Like:
echo | yum upgrade sqlite
Related videos on Youtube
Rich
Updated on September 18, 2022Comments
-
Rich over 1 year
I am trying to install a 3rd-party RPM package on RHEL5 which depends on version 3.4 of sqlite. According to Yum I already have 3.3.6 installed.
Is there a way to list the installed packages that depend on sqlite 3.3.6?
-
2rs2ts about 8 yearsThis returned packages I didn't have installed.
-
pdp over 6 yearsFurther,
repoquery
can be used to generate a nice tree like structure of all packages that require a particular package, for example:repoquery --pkgnarrow=installed --tree-whatrequires sqlite
-
Pancho over 5 yearsI don't agree that this answer is reliable - certainly not on CentOS 7.x . To test, install ImageMagick. OpenEXR-libs will also be installed as ImageMagick depends on it. Now run rpm -q --whatrequires OpenEXR-libs and the return is "no package requires OpenEXR-libs" which is INCORRECT. Now run "repoquery -q --installed --whatrequires OpenEXR-libs" and it correctly returns "ImageMagick-0:6.7.8.9-15.el7_2.x86_64". @just a random guy's answer below should be the correct answer here.
-
Pancho over 5 yearsThis answer is better than the accepted answer
-
Dan Rice over 5 years
--installed
is an option forrepoquery
but is invalid forrpm
. -
Hashbrown over 5 yearsYou need
--installed --recursive
at the end so it only returns what's actually installed and doesn't pull from the repositories -
hilltothesouth over 3 yearsAs @Hashbrown mentioned, add --installed at the end.
-
stolenmoment almost 3 yearsI think that rpm -q only reports package dependencies and not library (*.so) dependencies.
-
Jon V over 2 yearsWas using this a while ago, and came across a specific instance - installed
docker-compose
(via epel) in Centos7 - using the above to figure out what depends on python3-pip, and it only included python3 (which was expected). However, further recursion on python3 (now answer, "what is removed if you removepython3-pip
"), and everything that relied on python was also included (due topython(abi) = 3.6
line, I think). So take the results with a grain of salt :) Things get weird when you get to "base" capabilities (like python) -
sparrowt about 2 yearsIf
repoquery
command doesn't exist tryyum install yum-utils