Package-Management

在 Yum 中列出依賴於另一個已安裝包的包

  • March 18, 2022

我正在嘗試在 RHEL5 上安裝第 3 方 RPM 包,它依賴於 sqlite 的 3.4 版。根據 Yum,我已經安裝了 3.3.6。

有沒有辦法列出依賴於 sqlite 3.3.6 的已安裝包?

您想要的 rpm 選項是:

rpm -q --whatrequires sqlite

編輯:在其他答案/評論中添加–installed per discussion

已編輯:刪除 –installed 因為它是 rpm 的無效選項

回答

repoquery -q --installed --whatrequires sqlite

解釋

替代命令的問題rpm -q --whatrequires sqlite是它只報告包名稱的依賴關係。

相反,repoquery行為如下(來自聯機幫助頁):

  --alldeps
         When used with --whatrequires, look for non-explicit dependencies in addition to explicit ones (e.g. files and Provides  in  addition  to  package  names).
         This is the default.

例子

我們來打包吧libdb

# rpm -q --whatrequires libdb
no package requires libdb

如果我們信任rpm,則沒有包依賴,libdb因此我們應該能夠順利刪除它。然而…

# yum remove -y libdb
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package libdb.x86_64 0:5.3.21-19.el7 will be erased
--> Processing Dependency: libdb(x86-64) = 5.3.21-19.el7 for package: libdb-utils-5.3.21-19.el7.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: pam-1.1.8-12.el7_1.1.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: rpm-4.11.3-17.el7.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: rpm-libs-4.11.3-17.el7.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: libdb-utils-5.3.21-19.el7.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: cyrus-sasl-lib-2.1.26-20.el7_2.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: rpm-python-4.11.3-17.el7.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: python-libs-2.7.5-39.el7_2.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: rpm-devel-4.11.3-17.el7.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: rpm-build-libs-4.11.3-17.el7.x86_64
--> Processing Dependency: libdb-5.3.so()(64bit) for package: iproute-3.10.0-54.el7_2.1.x86_64
--> Running transaction check
. . .
. . .
. . .
Error: Trying to remove "systemd", which is protected
Error: Trying to remove "yum", which is protected

如您所見,其他一些包不直接依賴於 package libdb,而是依賴於libdb-5.3.so()(64bit)它提供的文件。

最後,在使用時,repoquery我們會根據以下條件獲得真正的包列表libdb

# repoquery -q --installed --whatrequires libdb
cyrus-sasl-lib-0:2.1.26-20.el7_2.x86_64
iproute-0:3.10.0-54.el7_2.1.x86_64
libdb-utils-0:5.3.21-19.el7.x86_64
pam-0:1.1.8-12.el7_1.1.x86_64
postfix-2:2.10.1-6.el7.x86_64
python-libs-0:2.7.5-39.el7_2.x86_64
rpm-0:4.11.3-17.el7.x86_64
rpm-build-libs-0:4.11.3-17.el7.x86_64
rpm-devel-0:4.11.3-17.el7.x86_64
rpm-libs-0:4.11.3-17.el7.x86_64
rpm-python-0:4.11.3-17.el7.x86_64

引用自:https://unix.stackexchange.com/questions/14589