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

50,645

Solution 1

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

Solution 2

All I want to do is retrieve a complete dependency graph for a piece of software I specify (obviously, i.e. postgis).

For this, you might try the rpmreaper tool recommended from this article: How to check RPM package dependencies on Fedora, CentOS or RHEL

It provides a curses based interface that allows you to selectively drill down into a package's requirements or "drill up" and see what depends on a given package.

The typical output of the ASCII based repoquery --tree-requires is very difficult to follow when it's several level deep and thousands of lines long. The rpmreaper display is much easier to read and traverse.

Here is a brief example of using the "drill up" (aka "Required by") to find a cycle in the Samba RPMs for reference:

samba-client-cycle

Solution 3

Just adding an improvement to this answer that I wish had been here when I was dealing with this.

ADDING --recursive does NOTHING when using --tree-requires

The best option out there is the --tree-requires option. That is the ONLY way I have found to get repoquery to provide a 100% complete dependency tree, including dependencies of dependencies.

FROM MAN: --recursive, When used with --whatrequires, query packages recursively.

As far as I can tell, for a --requires will return the same result, both with and without the --recursive option.

If you want to get a list of ALL dependencies, you MUST do a repoquery --tree-requires <My-Package>. Otherwise you will not have all required dependencies.

If you want to have them in a easy to read list, you can run this command:

sort <(sed -e 's/ [| \\\_]\+\|-[[:digit:]]\+..*\|[[:digit:]]\://g' <(repoquery --tree-requires **YOUR-PACKAGE-HERE**)) | uniq

It will produce a legible, sorted, package-name only list. See this example with the libxcb package. This list is ALL dependencies, and includes dependencies of dependencies.

Example with libxcb

I have found no difference in results with --recursive or --resolve when not using the --whatrequires command. --whatrequiresserves a different purpose than a standard dependency tree or dependency list. I haven't found any answer on stack overflow that correctly explains this (there are some comments).

There is currently a feature request to add a "tree format" command to repoquery, but at the moment that doesn't seem to be an option. Hopefully this helps fill the gap.

Solution 4

This will help clean up the --tree-requires for (x86_64):

for i in `repoquery --tree-requires --recursive --resolve postgis \
  | perl -nle '/([a-z]+-\d+\.\d+((\.|\-)?\d+)?.*x86_64)/;print "$1"'`; \
  do yumdownloader $i; \
  done
Share:
50,645
Sean Allred
Author by

Sean Allred

Emacs Prophet; TeX Evangelist. God bless arara. I'm a TeX systems enthusiast. I don't just push serious authors to use LaTeX, but I advertise the capability of TeX systems for background-process publishing. I'm currently researching for an article on TeX in Industry. Recommended resources The TeXBook. LaTeX Wikibook Recommended TeX editors AUCTeX under Emacs. The best I've used by a wide margin. (If you have issues setting up inline preview, check out some of my questions on the issue.) TeXMaker TeXStudio (autocompletion is a little weird) FAQ: Why download the complete TeX distribution? It's so big! I'm on Linux. Why install 'vanilla' TeX Live when my package repositories already contain it? Believe me, unless you really know what you're doing, it's always simpler to just download the full, vanilla TeX Live from TUG. Space is cheap – your time is not. Don't believe me? http://tex.stackexchange.com/q/235677/17423 http://tex.stackexchange.com/q/240589/17423 http://tex.stackexchange.com/q/271212/17423 Interesting texdoc resources: errorlog Funny TeX-related tidbits around the internet The condition of Queen Victoria is stable. License fuddling It's come to my attention that all content on this site is automatically under Creative Commons -- a license not terribly useful for LaTeX. Thus, I here relicense all my TeX/LaTeX/expl3 code under the LaTeX Project Public License (LPPL), version 1.3c or later. Document-embedded code (i.e. Lua, Python, sh, etc. that is initially processed by TeX) is also licensed under the LPPL v1.3c or later.

Updated on August 03, 2022

Comments

  • Sean Allred
    Sean Allred almost 2 years

    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?