36

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?

Sean Allred
  • 3,558
  • 3
  • 32
  • 71
  • 2
    Without the redhat subscription to a repository, the list of dependencies will be useless. You might want to use CentOS 5 five instead because its is RHEL5 without the Red Hat branding and subscription is free. – ZaSter Jun 13 '13 at 19:18
  • @ZaSter Uncle Sam does like using free stuff, apparently. CentOS has its limitations, but to a great extent I agree with you. I need the list of dependencies so that I can download them manually, shove them on an ISO, and put them on the vm. – Sean Allred Jun 14 '13 at 03:08
  • "yum repolist" will tell you if you actually have any yum repositories available (via subscription or otherwise). If you don't, then there are no packages you can install via yum. If you are starting with a "clean, virtual" installation, there won't be any. CentOS and most other Linux platforms provide public repos and integrate them into the base install. Since RHEL updates are behind a subscription, you don't get that. And sharing the same subscription on a cloned VM image will get the subscription cancelled, so you can't really do that either. – sosiouxme May 02 '14 at 18:46
  • 1
    The solution is described here: http://unix.stackexchange.com/q/153327/16253 – Anthony Sep 02 '14 at 14:05

4 Answers4

36

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
ZaSter
  • 1,192
  • 14
  • 20
  • 4
    The `--recursive` flag applies only to the `--whatrequires` option, not to `--requires`. The answer as provided (`--recursive --requires`), will list only those packages that are required directly by the package you are querying for. It seems that the only `repoquery` command that will provide recursive resolution if `--treerequires`. The output will need some further processing to strip out the ascii art and make a minimal list. – Grisha Levit Jun 01 '15 at 22:22
  • The --tree-requires flag does not exist in the RHEL5/CentOS5 environment of the original question. Strangely enough, the --recursive flag is not defined in the current RHEL5 manual pages and is not required, but does not produce an error. – ZaSter Oct 23 '16 at 03:39
12

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.

njfife
  • 3,555
  • 1
  • 20
  • 31
  • 1
    I find your answer useful, but it is kind of odd that you are forming your command. I would flow left to right with pipes instead of temporary file handles like the following: `repoquery --tree-requires **YOUR-PACKAGE-HERE** | sed -e 's/ [| \\\_]\+\|-[[:digit:]]\+..*\|[[:digit:]]\://g' | sort -u` – Cinderhaze Apr 24 '19 at 21:33
  • 1
    That's fine, I barely have any idea what I'm doing at all times so feel free to iterate on this =) – njfife Apr 25 '19 at 22:03
11

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

Mark Edington
  • 6,484
  • 3
  • 33
  • 33
1

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
Sean Allred
  • 3,558
  • 3
  • 32
  • 71
John Doe
  • 11
  • 1
  • 1
    This actually has some errors in it and won't always provide an accurate list. Some package names get cut off. – njfife Feb 16 '17 at 23:17