72

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?

6 Answers 6

71

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

4
  • 4
    Further, 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
    – pdp
    Oct 23, 2017 at 17:17
  • 4
    I 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
    Aug 23, 2018 at 20:53
  • 6
    --installed is an option for repoquery but is invalid for rpm.
    – Dan Rice
    Sep 10, 2018 at 16:25
  • 1
    I think that rpm -q only reports package dependencies and not library (*.so) dependencies. Jun 9, 2021 at 11:02
69

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
2
  • 3
    This answer is better than the accepted answer
    – Pancho
    Aug 23, 2018 at 20:55
  • If repoquery command doesn't exist try yum install yum-utils
    – sparrowt
    Apr 12 at 9:52
14

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
1
  • 1
    You need --installed --recursive at the end so it only returns what's actually installed and doesn't pull from the repositories
    – Hashbrown
    Dec 17, 2018 at 23:49
7

You could also try this command out.

repoquery --whatrequires sqlite

I got this command from ServerFault and also from The Fedora Forums.

2
  • 1
    This returned packages I didn't have installed.
    – 2rs2ts
    Apr 5, 2016 at 22:35
  • 1
    As @Hashbrown mentioned, add --installed at the end. Sep 30, 2020 at 14:55
3

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
1

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).

1
  • 1
    Was 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 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)
    – Jon V
    Nov 24, 2021 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.