如何获得rpm的完整依赖项列表?

时间:2020-01-09 10:39:15  来源:igfitidea点击:

本文将介绍获取rpm的完整依赖项列表的步骤,以防万一我们无法访问存储库手动下载并安装缺少的依赖项。

获取rpm的完整依赖项列表(已安装)

如果已经安装了rpm,请使用以下命令获取该rpm的依赖项列表

# rpm -qR glibc
/sbin/ldconfig
/usr/sbin/glibc_post_upgrade.x86_64
basesystem
config(glibc) = 2.17-222.el7
glibc-common = 2.17-222.el7
ld-linux-x86-64.so.2()(64bit)
ld-linux-x86-64.so.2(GLIBC_2.2.5)(64bit)
ld-linux-x86-64.so.2(GLIBC_2.3)(64bit)
libCNS.so()(64bit)
libGB.so()(64bit)
libIStheitroad165.so()(64bit)
libJIS.so()(64bit)
libJISX0213.so()(64bit)
libKSC.so()(64bit)
libc.so.6()(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.3.2)(64bit)
libc.so.6(GLIBC_2.3.3)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libdl.so.2()(64bit)
libdl.so.2(GLIBC_2.2.5)(64bit)
libfreebl3.so()(64bit)
libfreebl3.so(NSSRAWHASH_3.12.3)(64bit)
libgcc
libnsl.so.1()(64bit)
libnsl.so.1(GLIBC_2.2.5)(64bit)
libnss_files.so.2()(64bit)
libpthread.so.0()(64bit)
libpthread.so.0(GLIBC_2.2.5)(64bit)
libpthread.so.0(GLIBC_2.3.2)(64bit)
libresolv.so.2()(64bit)
libresolv.so.2(GLIBC_2.2.5)(64bit)
libresolv.so.2(GLIBC_2.9)(64bit)
rpmlib(BuiltinLuaScripts) <= 4.2.2-1
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PartialHardlinkSets) <= 4.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsXz) <= 5.2-1

这里的-q表示查询,而-R表示Require,这将列出此程序包所依赖的功能。

获取rpm的完整依赖项列表(在仓库中可用)

如果rpm是某些联机或者脱机Repo的一部分,则可以使用yum deplist

# yum deplist glibc
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
package: glibc.i686 2.17-196.el7_4.2
  dependency: basesystem
   provider: basesystem.noarch 10.0-7.el7
  dependency: glibc-common = 2.17-196.el7_4.2
   provider: glibc-common.x86_64 2.17-196.el7_4.2
  dependency: libfreebl3.so
   provider: nss-softokn-freebl.i686 3.28.3-8.el7_4
  dependency: libfreebl3.so(NSSRAWHASH_3.12.3)
   provider: nss-softokn-freebl.i686 3.28.3-8.el7_4
  dependency: libgcc
   provider: libgcc.x86_64 4.8.5-16.el7_4.2
   provider: libgcc.i686 4.8.5-16.el7_4.2
package: glibc.x86_64 2.17-196.el7_4.2
  dependency: basesystem
   provider: basesystem.noarch 10.0-7.el7
  dependency: glibc-common = 2.17-196.el7_4.2
   provider: glibc-common.x86_64 2.17-196.el7_4.2
  dependency: libfreebl3.so()(64bit)
   provider: nss-softokn-freebl.x86_64 3.28.3-8.el7_4
  dependency: libfreebl3.so(NSSRAWHASH_3.12.3)(64bit)
   provider: nss-softokn-freebl.x86_64 3.28.3-8.el7_4
  dependency: libgcc
   provider: libgcc.x86_64 4.8.5-16.el7_4.2
   provider: libgcc.i686 4.8.5-16.el7_4.2

但这给出了模块列表,这些模块是glibcrpm的依赖项,如果我们打算手动安装这些依赖项,这并不是很有用。

在这种情况下,更好的工具是repoquery

# repoquery -R --resolve --recursive glibc
pcre-0:8.32-15.el7.x86_64
glibc-0:2.17-157.el7_3.4.i686
bash-0:4.2.46-28.el7.x86_64
libselinux-0:2.2.2-6.el7.x86_64
basesystem-0:10.0-7.el7.noarch
tzdata-0:2014f-1.el7.noarch
pcre-0:8.32-12.el7.i686
libstdc++-0:4.8.3-9.el7.x86_64
libgcc-0:4.8.5-4.el7.x86_64
ncurses-libs-0:5.9-13.20130511.el7.x86_64
ncurses-base-0:5.9-14.20130511.el7_4.noarch
nss-softokn-freebl-0:3.16.2.3-14.4.el7.i686
glibc-0:2.17-106.el7_2.4.x86_64
filesystem-0:3.2-20.el7.x86_64
redhat-release-server-0:7.0-1.el7.x86_64
libsepol-0:2.5-6.el7.x86_64
setup-0:2.8.71-5.el7.noarch
libgcc-0:4.8.2-16.2.el7_0.i686
glibc-common-0:2.17-196.el7_4.2.x86_64

如我们所见,它以rpm的格式而不是库或者模块的形式提供了glibc rpm的所有依赖项列表。
因此,如果我们无权访问yum repo,则可以手动下载并安装这些rpm列表。

获取rpm的完整依赖项列表(本地可用,但未安装)

如果服务器上本地有rpm,则可以使用rpm -qpR获取依赖项列表。

# rpm -qpR glibc-2.17-222.el7.x86_64.rpm
/sbin/ldconfig
/usr/sbin/glibc_post_upgrade.x86_64
basesystem
config(glibc) = 2.17-222.el7
glibc-common = 2.17-222.el7
ld-linux-x86-64.so.2()(64bit)
ld-linux-x86-64.so.2(GLIBC_2.2.5)(64bit)
ld-linux-x86-64.so.2(GLIBC_2.3)(64bit)
libCNS.so()(64bit)
libGB.so()(64bit)
libIStheitroad165.so()(64bit)
libJIS.so()(64bit)
libJISX0213.so()(64bit)
libKSC.so()(64bit)
libc.so.6()(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.3.2)(64bit)
libc.so.6(GLIBC_2.3.3)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libdl.so.2()(64bit)
libdl.so.2(GLIBC_2.2.5)(64bit)
libfreebl3.so()(64bit)
libfreebl3.so(NSSRAWHASH_3.12.3)(64bit)
libgcc
libnsl.so.1()(64bit)
libnsl.so.1(GLIBC_2.2.5)(64bit)
libnss_files.so.2()(64bit)
libpthread.so.0()(64bit)
libpthread.so.0(GLIBC_2.2.5)(64bit)
libpthread.so.0(GLIBC_2.3.2)(64bit)
libresolv.so.2()(64bit)
libresolv.so.2(GLIBC_2.2.5)(64bit)
libresolv.so.2(GLIBC_2.9)(64bit)
rpmlib(BuiltinLuaScripts) <= 4.2.2-1
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PartialHardlinkSets) <= 4.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsXz) <= 5.2-1