17

I have a set of packages (*.rpm). For each package I can do rpm -qRp <package> to list requires, but I would like to install them (those requires) without installing the packages themselves. The requires all live in enabled repositories. Is there some easy way to do this without writing my own script that would parse output of rpm -qRp ... for example.

I know I could do it by installing everything with requires (yum localinstall) and then uninstalling the original packages, but the problem is that my set contains packages with both dependencies and conflicts in between them. The required packages however don't conflict. I would have to do multiple yum localinstall <list> followed by yum remove <list> and make sure the packages in list don't conflict.

I there a better way? I would basically like something like yum-builddep, but for requires, not buildrequires.

My distros are Fedora/RHEL

22

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
  • 1
    Thanks. Seems to be working even on rpm files. Exactly what I was looking for. – Miroslav Franc Aug 6 '15 at 21:54
  • 1
    Anybody want to own up to the -1? Is there something I can fix? – larsks Aug 7 '15 at 20:47
4

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.

  • yum -y might be needed. – caot Feb 7 at 16:58
  • -y isn't the default for a few reasons, and the important ones don't change by the above. – James Antill Feb 27 at 3:02

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.