How to list dependencies of a rpm package via dnf

The other day while writing up the blog post How to install Oracle Database 18c XE on Linux 8 I stumbled across the question of how to list all the dependencies of a rpm package on Linux 8. The solution was easier than I thought but required some googling, so here is it for easy reference:

The dnf command provides a nice little sub command called repoquery which is equivalent to rpm -q and to the repoquery command provided by yum-utils on Linux 7. It’s quite a powerful little command which is reflected by the long list of parameters it takes. You can check for yourself by just typing dnf repoquery --help. One of these parameters is --requires which allows you to, as the documentation puts it “Display capabilities that the package depends on.

So the next time you want to know what dependencies a package has, all you have to type is dnf repoquery --requires <your package name>, for example:

[root@localhost ~]# dnf repoquery --requires vim
Last metadata expiration check: 0:36:36 ago on Wed 05 May 2021 09:24:46 PM PDT.
autoconf
desktop-file-utils >= 0.2.93
file
gcc
gettext
gpm-devel
gtk3-devel
libICE-devel
libSM-devel
libX11-devel
libXpm-devel
libXt-devel
libacl-devel
libappstream-glib
libselinux-devel
lua-devel
ncurses-devel
perl(ExtUtils::Embed)
perl(ExtUtils::ParseXS)
perl-devel
perl-generators
python2-devel
python3-devel
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
ruby
ruby-devel
[root@localhost ~]#

The package does not even have to be installed on the local machine, dnf will automatically resolve any packages dependencies based on the repository information from the web, which makes it my favorite over rpm -q:

[root@localhost ~]# dnf list installed | grep oracle-database-preinstall-19c
[root@localhost ~]# dnf repoquery --requires oracle-database-preinstall-19c
Last metadata expiration check: 0:40:03 ago on Wed 05 May 2021 09:24:46 PM PDT.
/bin/bash
/bin/sh
/etc/redhat-release
bash
bc
bind-utils
binutils
config(oracle-database-preinstall-19c) = 1.0-1.el8
config(oracle-database-preinstall-19c) = 1.0-2.el8
ethtool
glibc
glibc-devel
initscripts
ksh
libaio
libaio-devel
libgcc
libnsl
libstdc++
libstdc++-devel
make
module-init-tools
net-tools
nfs-utils
openssh-clients
openssl-libs
pam
procps
psmisc
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsXz) <= 5.2-1
smartmontools
sysstat
tar
unzip
util-linux-ng
xorg-x11-utils
xorg-x11-xauth
[root@localhost ~]#

So if you ever wonder again what dependencies a package has, dnf repoquery is your friend! 🙂

Author: Gerald

Developer, Oracle expert, performance enthusiast and genuine technology geek.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: