Product SiteDocumentation Site

5.2. Checking for Dependencies

The rpm –q command queries the RPM database or RPM package files. With the right options to this command, you can check for the four types of package dependencies as well. These options are based on the concept of capabilities introduced previously.
You can query what capabilities a package requires. You can also query what capabilities a package provides. You can query for the obsoleting and conflicting information as well. Furthermore, given a capability, you can query which packages require this capability as well as which packages provide this capability.
Cross Reference
There are quite a few more options you can use with the rpm –q command for querying packages. See Chapter 4, Using the RPM Database for more on querying packages and package files.

5.2.1. Determining the capabilities a package requires

The first and most important step is to determine what capabilities a package requires. If all the required capabilities are met, you can safely install the package (barring other things that can go wrong, such as conflicts). The requires dependencies are by far the most important.
The --requires option to the rpm –q command lists the capabilities a given package requires. The basic syntax is:
rpm –q query_options --requires packages
For example:
$ rpm -qp --requires sendmail-8.12.5-7.i386.rpm
/usr/sbin/alternatives
rpmlib(VersionedDependencies) <= 3.0.3-1
chkconfig >= 1.3
/usr/sbin/useradd
/bin/mktemp
fileutils
gawk
sed
sh-utils
procmail
bash >= 2.0
/bin/sh
/bin/sh
/bin/sh
/bin/sh
/bin/sh
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(CompressedFileNames) <= 3.0.4-1
/bin/bash
libcrypto.so.2
libcrypt.so.1
libc.so.6
libc.so.6(GLIBC_2.0)
libc.so.6(GLIBC_2.1)
libc.so.6(GLIBC_2.1.3)
libc.so.6(GLIBC_2.2)
libdb-4.0.so
libgdbm.so.2
libhesiod.so.0
liblber.so.2
libldap.so.2
libnsl.so.1
libnsl.so.1(GLIBC_2.0)
libresolv.so.2
libresolv.so.2(GLIBC_2.0)
libresolv.so.2(GLIBC_2.2)
libsasl.so.7
libssl.so.2
This example tests an RPM package file, sendmail-8.12.5-7.i386.rpm, for the requires dependency, in other words, what capabilities the package requires. The sendmail package depends on a lot of other parts of the system, as you can see in the response to the command shown previously. Most of the dependencies are for system libraries (all the dependencies ending in .so or .so.number). This package requires other capabilities (packages in this case). It also requires the chkconfig package at a specific version, version 1.3 or higher, and the bash package at version 2.0 or higher. The sendmail package also requires a particular version of the RPM system (the rpmlib dependency).
Warning
Always check what a package requires before installing the package. You can also use the --test option when trying to install the package to first test whether the installation can proceed. See Chapter 3, Using RPM for details on installing packages and the --test option. The rpm command will perform all these checks for you anyway. Checking in advance, though, with the --test option, helps avoid dependency hell with circular dependencies.
You can also check for what an installed package requires with the --requires option. For example:
rpm -q --requires sendmail
You can use the -R short option in place of the --requires option.
This command returns the same data as the previous command but queries an installed package rather than an RPM package file.
You might assume that applications have the most dependencies, which is true. But even source packages may depend on other packages, often the packages needed to build the sources into an application. For example, the following command lists the capabilities required by a source RPM:
$ rpm -qp --requires telnet-0.17-23.src.rpm
ncurses-devel
Some packages require particular versions of other packages, for example:
rpm -qp --requires xcdroast-0.98a9-18.src.rpm
imlib-devel >= 1.9.13-9
gtk+-devel >= 1.2.10
desktop-file-utils >= 0.2.92
rpmlib(CompressedFileNames) <= 3.0.4-1
This example shows that the xcdroast source package requires the imlib-devel capability (in this case, a package) at version 1.9.13-9 or higher, the gtk+-devel package at version 1.2.10 or higher, and the desktop-file-utils package at version 0.2.92 or higher. This is a more stringent requirement than just depending on the given packages being installed. This RPM is also an older RPM package, based on the requirement for the rpmlib to be prior or equal to 3.0.4-1.
Some packages may require a particular version of the rpmlib, or RPM library. For example, the setup package contains special system configuration files, including the default password file, /etc/passwd.
$ rpm -q --requires setup
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(CompressedFileNames) <= 3.0.4-1
As shown in this example, this package depends only on capabilities of the RPM system itself. The particular requirements shown here specify how the rpm command should treat the package payload, including how the files are listed in the package and what type of compression is used.