Is there any way to retrieve a dependency tree from yum?

Sean Allred picture Sean Allred · May 30, 2013 · Viewed 45.4k times · Source

To reduce the chance of the XY problem, I'm trying to install PostGIS on a clean, virtual RHEL5 installation with heavy restrictions. I do not know if we (as a company) have a RH subscription.

# yum install postgis
Loaded plugins: product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
No package postgis available.
Nothing to do.

It throws the same error when I try to install emacs, so I'm relatively certain that it doesn't matter which package I'm trying to install.

The VM has internet access.

All I want to do is retrieve a complete dependency graph for a piece of software I specify (obviously, i.e. postgis). yum must already compute this dependency graph (or have one available for retrieval) to do its job, so how can I tap into this resource?

Answer

ZaSter picture ZaSter · Jun 14, 2013

Per the RHEL5 manual pages: "repoquery is a program for querying information from YUM repositories similarly to rpm queries."

For your specific case of postgis:

# repoquery --requires --recursive --resolve  postgis
postgresql-libs-0:8.1.23-6.el5_8.i386
geos-0:2.2.3-3.el5.i386
glibc-0:2.5-107.el5_9.5.i686
proj-0:4.5.0-3.el5.i386

You can drop the ".i386" and ".i686" off of the package names if your system is 64-bit.

The output from repoquery is not perfect since, for example, it fails to list glibc-common in the above list. But your system would not be running if it did not have both glibc and glibc-common already installed.

EDIT: Although it does not cause an error, the --recursive flag appears to do nothing in RHEL5.11 and can be omitted. Also, use the --pkgnarrow=all flag to ensure that all (installed, available, etc) packages are considered for the query. Lastly, for one step of recursion to get more of the dependency tree, in a bash shell, pass the output of the repoquery command to a second repoquery command using tee and xargs like so:

# repoquery --requires  --resolve --pkgnarrow=all postgis.i386 | tee >(xargs -r -n 1 -- repoquery --requires  --resolve --pkgnarrow=all) | sort | uniq
basesystem-0:8.0-5.1.1.noarch
geos-0:2.2.3-3.el5.i386
glibc-0:2.5-123.el5_11.3.i686
glibc-common-0:2.5-123.el5_11.3.i386
krb5-libs-0:1.6.1-80.el5_11.i386
libgcc-0:4.1.2-55.el5.i386
libstdc++-0:4.1.2-55.el5.i386
openssl-0:0.9.8e-40.el5_11.i686
postgresql-libs-0:8.1.23-10.el5_10.i386
proj-0:4.5.0-3.el5.i386