[英]Is there any way to retrieve a dependency tree from yum?
To reduce the chance of the XY problem, I'm trying to install PostGIS on a clean, virtual RHEL5 installation with heavy restrictions. 为了减少XY问题的可能性,我正在尝试在严格限制的干净,虚拟RHEL5安装上安装PostGIS。 I do not know if we (as a company) have a RH subscription.
我不知道我们(作为公司)是否有RH订阅。
# 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. 当我尝试安装
emacs
时它会抛出相同的错误,所以我相对肯定我正在尝试安装哪个包并不重要。
The VM has internet access. VM可以访问Internet。
All I want to do is retrieve a complete dependency graph for a piece of software I specify (obviously, ie postgis
). 我想要做的就是为我指定的一个软件检索一个完整的依赖图(显然,即
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? yum
必须已经计算了这个依赖图(或者有一个可用于检索)才能完成它的工作,那么我该如何利用这个资源呢?
Per the RHEL5 manual pages: " repoquery is a program for querying information from YUM repositories similarly to rpm queries." 根据RHEL5手册页:“ repoquery是一个用于查询来自YUM存储库的信息的程序,类似于rpm查询。”
For your specific case of postgis: 对于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. 如果系统是64位,则可以从软件包名称中删除“.i386”和“.i686”。
The output from repoquery is not perfect since, for example, it fails to list glibc-common in the above list. repoquery的输出并不完美,因为例如,它无法在上面的列表中列出glibc-common。 But your system would not be running if it did not have both glibc and glibc-common already installed.
但是如果没有安装glibc和glibc-common,你的系统将无法运行。
EDIT : Although it does not cause an error, the --recursive
flag appears to do nothing in RHEL5.11 and can be omitted. 编辑 :虽然它不会导致错误,但是
--recursive
标志似乎在RHEL5.11中什么都不做,可以省略。 Also, use the --pkgnarrow=all
flag to ensure that all (installed, available, etc) packages are considered for the query. 此外,使用
--pkgnarrow=all
标志可确保为查询考虑所有(已安装,可用等)包。 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: 最后,对于获取更多依赖树的一步递归,在bash shell中,使用
tee
和xargs
将repoquery命令的输出传递给第二个repoquery命令,如下所示:
# 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
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 添加 - 使用--tree-requires时,递归没有任何作用
The best option out there is the --tree-requires
option. 最好的选择是
--tree-requires
选项。 That is the ONLY way I have found to get repoquery to provide a 100% complete dependency tree, including dependencies of dependencies . 这是我发现获得repoquery以提供100%完整依赖关系树的唯一方式, 包括依赖关系的依赖关系 。
FROM MAN: --recursive, When used with --whatrequires , query packages recursively.
FROM MAN:--recursive, 当与--whatrequires一起使用时 ,递归查询包。
As far as I can tell, for a --requires
will return the same result, both with and without the --recursive
option. 据我所知,对于
--requires
将返回相同的结果,无论是否有--recursive
选项。
If you want to get a list of ALL dependencies, you MUST do a repoquery --tree-requires <My-Package>
. 如果要获取所有依赖项的列表,则必须执行
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.
使用libxcb包查看此示例。 This list is ALL dependencies, and includes dependencies of dependencies.
此列表是所有依赖项,包括依赖项的依赖项。
I have found no difference in results with --recursive
or --resolve
when not using the --whatrequires
command. 我发现在不使用
--whatrequires
命令时,使用--recursive
或--resolve
结果没有区别。 --whatrequires
serves a different purpose than a standard dependency tree or dependency list. --whatrequires
用于与标准依赖关系树或依赖关系列表不同的目的。 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. 目前有一个功能请求是向repoquery添加“树格式”命令,但此刻似乎不是一个选项。 Hopefully this helps fill the gap.
希望这有助于填补空白。
All I want to do is retrieve a complete dependency graph for a piece of software I specify (obviously, ie postgis).
我想要做的就是为我指定的一个软件检索一个完整的依赖图(显然,即postgis)。
For this, you might try the rpmreaper tool recommended from this article: How to check RPM package dependencies on Fedora, CentOS or RHEL 为此,您可以尝试本文推荐的rpmreaper工具: 如何检查Fedora,CentOS或RHEL上的RPM包依赖性
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. 它提供了一个基于curses的界面,允许您有选择地深入了解包的要求或“向上钻取”并查看取决于给定包的内容。
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. 基于ASCII的
repoquery --tree-requires
的典型输出非常难以理解,因为它有几层深度和数千行长。 The rpmreaper display is much easier to read and traverse. rpmreaper显示更容易阅读和遍历。
Here is a brief example of using the "drill up" (aka "Required by") to find a cycle in the Samba RPMs for reference: 以下是使用“向上钻取”(又名“必需”)在Samba RPMs中查找循环以供参考的简短示例:
This will help clean up the --tree-requires
for (x86_64): 这将有助于清除(x86_64)的
--tree-requires
:
for i in `repoquery --tree-requires --recursive --resolve postgis \
| perl -nle '/([a-z]+-\d+\.\d+((\.|\-)?\d+)?.*x86_64)/;print "$1"'`; \
do yumdownloader $i; \
done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.