How to check RPM package dependencies on Fedora, CentOS or RHEL

Last updated on September 24, 2020 by Dan Nanni

A typical RPM package on Red Hat-based systems requires all its dependent packages be installed to function properly. For end users, the complexity of such RPM dependency is hidden by package managers (e.g., yum or dnf) during package install/upgrade/removal process. However, if you are a sysadmin or a RPM maintainer, you need to be well-versed in RPM dependencies to maintain run-time environment for the system or roll out up-to-date RPM specs.

In this tutorial, I am going to show how to check RPM package dependencies. Depending on whether a package is installed or not, there are several ways to identify its RPM dependencies.

Method One: rpm

One way to find out RPM dependencies for a particular package is to use rpm command. The following command lists all dependent packages for a target package.

$ rpm -qR <package-name>

Note that this command will work only if the target package is already installed. If you want to check package dependencies for any uninstalled package, you first need to download the RPM package locally (no need to install it).

To download an RPM package without installing it, use a command-line utility called yumdownloader. Install yumdownloader as follows.

$ sudo yum install yum-utils

Now let's check RPM depenencies of a uninstalled package (e.g., tcpdump). First download the package in the current folder with yumdownloader:

$ yumdownloader --destdir=. tcpdump

Then use rpm command with -qpR options to list dependencies of the downloaded package.

# rpm -qpR tcpdump-4.4.0-2.fc19.i686.rpm

Method Two: repoquery

You can also get a list of dependencies for a RPM package using repoquery tool. repoquery works whether or not a target package is installed. This tool is included in yum-utils package.

$ sudo yum install yum-utils

To show all required packages for a particular package:

$ repoquery --requires --resolve <package-name>

For repoquery to work, your computer needs network connectivity since repoquery pulls information from Yum repositories.

Method Three: rpmreaper

The third method to show RPM package dependencies is to use rpmreaper tool. Originally this tool is developed to clean up unnecessary packages and their dependencies on RPM-based systems. rpmreaper has an ncurses-based intuitive interface for browsing installed packages and their dependency trees.

To install rpmrepater, use yum command. On CentOS, you need to set up EPEL repo first.

$ sudo yum install rpmreaper

To browser RPM dependency trees, simply run:

$ rpmreaper

The rpmrepater interface will show you a list of all installed packages. You can navigate the list using up/down arrow keys. Press r on a highlighted package to show its dependencies. You can expand the whole dependency tree by recursively pressing r keys on individual dependent packages. The L flag indicates that a given package is a leaf, meaning that no other package depends on this package. The o flag implies that a given package is in the middle of dependency chain. Pressing b on such a package will show you what other packages require the highlighted package.

Method Four: rpmdep

Another way to show package dependencies on RPM-based systems is to use rpmdep which is a command-line tool for generating a full package dependency graph of any installed RPM package. The tool analyzes RPM dependencies, and produce partially ordered package lists from topological sorting. The output of this tool can be fed into dotty graph visualization tool to generate a dependency graph image.

To install rpmdep and dotty on Fedora:

$ sudo yum install rpmorphan graphviz

To install the same tools on CentOS:

$ wget http://downloads.sourceforge.net/project/rpmorphan/rpmorphan/1.14/rpmorphan-1.14-1.noarch.rpm
$ sudo rpm -ivh rpmorphan-1.14-1.noarch.rpm
$ sudo yum install graphviz

To generate and plot a dependency graph of a particular installed package (e.g., gzip):

$ rpmdep.pl -dot gzip.dot gzip
$ dot -Tpng -o output.png gzip.dot

In this tutorial I demonstrate several ways to check what other packages a given RPM package relies on. If you want to know more about DEB package dependencies for Debian-based systems, you can refer to this guide instead.

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean