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?
repoquery -q --installed --whatrequires sqlite
There is another command, rpm -q --whatrequires sqlite
, but it doesn't really work since 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.
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
repoquery
command doesn't exist try yum install yum-utils
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
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
--installed
is an option for repoquery
but is invalid for rpm
.
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
--installed --recursive
at the end so it only returns what's actually installed and doesn't pull from the repositories
Commented
Dec 17, 2018 at 23:49
You could also try this command out.
repoquery --whatrequires sqlite
I got this command from ServerFault and also from The Fedora Forums.
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
As Wes Hardaker said, a good built-in method is by using rpm -q --whatrequires <package>
. The thing is, rpm
operates on capabilities for dependency resolution, not just simply on packages, as e.g. dpkg
does in the Debian/Ubuntu family of Linux distributions. As others have noted, simply doing rpm -q --whatrequires sqlite
doesn't tell the whole story, hence why some suggested using repoquery
. repoquery
, however, isn't installed by default in RHEL/CentOS 7 minimal (maybe desktop too?), so it may not be available for everyone.
A user can do rpm -q --provides <pkgname>
to see all the capabilities a package provides, then use rpm -q --whatrequires <capability>
to see what installed packages require that capability. This info can be succinctly queried using a BASH one-liner (separated here into two lines for length):
capabilities=($(rpm -q --provides sqlite | awk -F= '{print $1}'));
for c in "${capabilities[@]}"; do rpm -q --whatrequires "$c"; done
This only uses options built-in to rpm
itself, and so it doesn't require installing any additional packages (e.g. yum-utils
in CentOS 7, which is the package that contains repoquery
).
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 remove python3-pip
"), and everything that relied on python was also included (due to python(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)