How to install dependencies of an rpm package without installing the package itself? (rhel/fedora)

You can use the yum deplist command to generate a list of package dependencies:

$ yum deplist bind
  dependency: /bin/bash
   provider: bash.x86_64 4.3.39-5.fc21
  dependency: /bin/sh
   provider: bash.x86_64 4.3.39-5.fc21
  dependency: bind-libs(x86-64) = 32:9.9.6-10.P1.fc21
   provider: bind-libs.x86_64 32:9.9.6-10.P1.fc21
  dependency: coreutils
   provider: coreutils.x86_64 8.22-22.fc21
[...]

Grab the provider: lines from this for a list of packages:

$ yum deplist bind | awk '/provider:/ {print $2}' | sort -u
bash.x86_64
bind-libs.x86_64
coreutils.x86_64
glibc.i686
glibc.x86_64
grep.x86_64
krb5-libs.x86_64
libcap.x86_64
libcom_err.x86_64
libxml2.x86_64
openssl-libs.x86_64
shadow-utils.x86_64
systemd.x86_64
zlib.x86_64

Send this output to yum install to install the packages:

$ yum deplist bind | awk '/provider:/ {print $2}' | sort -u |
  xargs yum -y install

The best way is:

yum shell <<EOF
install foo
ts solve
remove foo
run
EOF

...using deplist/etc. will mostly work, but isn't guaranteed to get the exact same result.

Tags:

Rpm

Yum