40

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?

40

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

  • 3
    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 '17 at 17:17
  • 1
    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 '18 at 20:53
  • 4
    --installed is an option for repoquery but is invalid for rpm. – Dan Rice Sep 10 '18 at 16:25
27

Answer

repoquery -q --installed --whatrequires sqlite

Explanations

rpm -q --whatrequires sqlite only reports dependencies on package names.

On the contrary, repoquery acts as follow (from manpages):

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

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 the package, but on file libdb-5.3.so()(64bit) provided by it.

Finally, here is 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
  • 1
    This answer is better than the accepted answer – Pancho Aug 23 '18 at 20:55
7

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
  • 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 '18 at 23:49
5

You could also try this command out.

repoquery --whatrequires sqlite

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

  • This returned packages I didn't have installed. – 2rs2ts Apr 5 '16 at 22:35
2

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
0

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

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.