yum 可以告诉我哪个存储库提供特定的软件包吗?

发布于 2024-07-15 02:12:44 字数 284 浏览 6 评论 0原文

希望问题的简短版本:如果我在一台安装了特定软件包的机器上,是否有一个 yum 命令可以告诉我提供了该软件包的配置存储库中的哪个? (或者,哪个存储库将提供尚未安装的软件包。)

背景,以防需要某些上下文:我们有一个迷宫般的 yum 存储库可供我们从中提取。 我有一台机器安装了特定的 rpm 软件包,而另一台机器配置的存储库明显不足,因此我无法将我想要的软件包安装到该机器上。 我需要向新机器添加最少的必要存储库。 我不能只是将存储库从一台机器转移到另一台机器。 仅仅出去获取转速并不是一个选择,因为我需要它是可重现的。

Hopefully short version of the question: If I'm on a machine that has a particular package installed, is there a yum command that will tell me which of it's configured repositories provided that package? (Or alternately, what repository would provide a yet-to-be-installed package.)

Background in case some context is needed: We have a maze of yum repositories that we draw from. I have a machine that has a particular rpm package installed, and another machine with an apparently insufficient maze of repositories configured, and so I am not able to install the package I want onto that machine. I need to add the minimal necessary repositories to the new machine. I can't just shotgun the repositories from one machine to the other. And just going out and grabbing the rpm isn't an option because I need this to be reproducible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

昔日梦未散 2024-07-22 02:12:45

EL7

这应该相当于 yum list located,但具有机器可读的输出:

repoquery --installed '*' --queryformat='%{name} %{evr} %{ui_from_repo}' | column -t

显然,生成列出可能字段的手册页太麻烦了; 但您可以查看 https://github.com /rpm-software-management/yum/blob/master/yum/packages.py 并使用您列出的对象类存在的任何属性。

例如,如果您列出已安装的软件包,则可以使用 YumInstalledPackage 的字段,以及其基类 YumHeaderPackageYumAvailablePackage 的字段、PackageObjectRpmBase

这是一个例子:

$ repoquery --installed '*' --qf='%{name} %{evr} %{ui_from_repo}' | head -n 10 | column -t
GeoIP                         1.5.0-14.el7    @rhos-13.0-rhel-7-signed
MySQL-python                  1.2.5-1.el7     @rhos-13.0-rhel-7-signed
NetworkManager                1:1.18.0-5.el7  @anaconda/7.7
NetworkManager-config-server  1:1.18.0-5.el7  @anaconda/7.7
NetworkManager-libnm          1:1.18.0-5.el7  @anaconda/7.7
NetworkManager-team           1:1.18.0-5.el7  @anaconda/7.7
NetworkManager-tui            1:1.18.0-5.el7  @anaconda/7.7
OpenIPMI                      2.0.27-1.el7    @rhos-13.0-rhel-7-signed
OpenIPMI-libs                 2.0.27-1.el7    @rhos-13.0-rhel-7-signed
OpenIPMI-modalias             2.0.27-1.el7    @rhos-13.0-rhel-7-signed

值得阅读 评论记录 ui_from_repo 属性,以便了解该字段的可能格式。

EL8& EL9

我发现添加 --installed 导致 ui_from_repo 的值变成 @System。 但有一个 from_repo 字段似乎有效。

(事实证明,可以使用 dnf repoquery --querytags 输出有效字段)。

$ dnf repoquery --installed '*' --qf='%{name} %{evr} %{from_repo}' | head -n 10 | column -t
389-ds-base              1.4.3.16-19.module+el8.4.0+11894+f5bb5c43  rhel-8-for-x86_64-appstream-rpms                                 
389-ds-base-libs         1.4.3.16-19.module+el8.4.0+11894+f5bb5c43  rhel-8-for-x86_64-appstream-rpms                                 
NetworkManager           1:1.30.0-10.el8_4                          rhel-8-for-x86_64-baseos-rpms                                    
NetworkManager-libnm     1:1.30.0-10.el8_4                          rhel-8-for-x86_64-baseos-rpms                                    
NetworkManager-team      1:1.30.0-10.el8_4                          rhel-8-for-x86_64-baseos-rpms                                    
NetworkManager-tui       1:1.30.0-10.el8_4                          rhel-8-for-x86_64-baseos-rpms                                    
PackageKit               1.1.12-6.el8                               rhel-8-for-x86_64-appstream-rpms                                 
PackageKit-glib          1.1.12-6.el8                               rhel-8-for-x86_64-appstream-rpms                                 
abattis-cantarell-fonts  0.0.25-6.el8                               rhel-8-for-x86_64-appstream-rpms                                 

EL7

This should be equivalent to yum list installed, but with machine-readable output:

repoquery --installed '*' --queryformat='%{name} %{evr} %{ui_from_repo}' | column -t

Apparantly it's too much trouble to produce a man page listing the possible fields; but you can look through https://github.com/rpm-software-management/yum/blob/master/yum/packages.py and use whatever properties exist for the class of object you're listing.

e.g., if you're listing installed packages, you can use the fields of YumInstalledPackage, and hence the fields of its base classes YumHeaderPackage, YumAvailablePackage, PackageObject and RpmBase.

Here's an example:

$ repoquery --installed '*' --qf='%{name} %{evr} %{ui_from_repo}' | head -n 10 | column -t
GeoIP                         1.5.0-14.el7    @rhos-13.0-rhel-7-signed
MySQL-python                  1.2.5-1.el7     @rhos-13.0-rhel-7-signed
NetworkManager                1:1.18.0-5.el7  @anaconda/7.7
NetworkManager-config-server  1:1.18.0-5.el7  @anaconda/7.7
NetworkManager-libnm          1:1.18.0-5.el7  @anaconda/7.7
NetworkManager-team           1:1.18.0-5.el7  @anaconda/7.7
NetworkManager-tui            1:1.18.0-5.el7  @anaconda/7.7
OpenIPMI                      2.0.27-1.el7    @rhos-13.0-rhel-7-signed
OpenIPMI-libs                 2.0.27-1.el7    @rhos-13.0-rhel-7-signed
OpenIPMI-modalias             2.0.27-1.el7    @rhos-13.0-rhel-7-signed

It's worth reading the comment that documents the ui_from_repo property, in order to understand the possible format of this field.

EL8 & EL9

I found that adding --installed caused the value of the ui_from_repo to become @System. But there is a from_repo field that seems to work.

(It turns out valid fields can be output with dnf repoquery --querytags).

$ dnf repoquery --installed '*' --qf='%{name} %{evr} %{from_repo}' | head -n 10 | column -t
389-ds-base              1.4.3.16-19.module+el8.4.0+11894+f5bb5c43  rhel-8-for-x86_64-appstream-rpms                                 
389-ds-base-libs         1.4.3.16-19.module+el8.4.0+11894+f5bb5c43  rhel-8-for-x86_64-appstream-rpms                                 
NetworkManager           1:1.30.0-10.el8_4                          rhel-8-for-x86_64-baseos-rpms                                    
NetworkManager-libnm     1:1.30.0-10.el8_4                          rhel-8-for-x86_64-baseos-rpms                                    
NetworkManager-team      1:1.30.0-10.el8_4                          rhel-8-for-x86_64-baseos-rpms                                    
NetworkManager-tui       1:1.30.0-10.el8_4                          rhel-8-for-x86_64-baseos-rpms                                    
PackageKit               1.1.12-6.el8                               rhel-8-for-x86_64-appstream-rpms                                 
PackageKit-glib          1.1.12-6.el8                               rhel-8-for-x86_64-appstream-rpms                                 
abattis-cantarell-fonts  0.0.25-6.el8                               rhel-8-for-x86_64-appstream-rpms                                 
北斗星光 2024-07-22 02:12:44
yum list packagename

这将在输出的第三列中显示该包来自哪个存储库。

对于已经安装的软件包,这将不起作用,因为第三列仅显示已安装。 在这种情况下,您可以执行例如 rpm -qi packagename,通常 Vendor、Packager 和 Build Host 标签将指示该包属于哪个存储库。 此外,某些存储库符号附加到包版本号上也很常见。

yum list packagename

That will show from which repository the package is in the third column of the output.

For already installed packages, that won't work, as the third column shows just installed. In that case you can do e.g. rpm -qi packagename, typically the Vendor, Packager and Build Host tags will give an indication to which repository the package belongs. Also it's quite common for some repo symbol being appended to the package version number.

許願樹丅啲祈禱 2024-07-22 02:12:44
repoquery -i {packagename} 

这将为您提供实际的存储库名称,而不是 yum 返回的无用的“已安装”名称。
repoquery 由 yum-utils 提供。

repoquery -i {packagename} 

This will give you the actual repo name vs the unhelpful "installed" that yum returns.
repoquery is provided by yum-utils.

花想c 2024-07-22 02:12:44

您可以使用 yum -v search 来显示软件包及其所在的存储库。如果您还添加 --showduplicates ,您将看到该软件包的所有版本。

归功于:http://www.spinics.net/linux/fedora/yum/ msg11975.html

You can use yum -v search that would show you packages along with repo it is present in. If you also add --showduplicates you will see all versions of that package.

Credit to: http://www.spinics.net/linux/fedora/yum/msg11975.html

小苏打饼 2024-07-22 02:12:44

对于单个包,您可以通过

PACKAGE=ruby-enterprise
repoquery --qf "%{repoid}" $PACKAGE

$PACKAGE 替换为您关心的包的名称来找到它。

查找来自特定存储库的所有包

REPO=ruby-enterprise-opt
repoquery --repoid=$REPO -a --qf "%{name}" | sort > repo_packages
rpm -qa --qf "%{name}\n" | sort > installed_packages
comm -1 -2 repo_packages installed_packages

您可以通过将 $REPO 替换为您关心的存储库的 ID 来 ; 您可以使用 yum repolist 查看所有启用的存储库的 ID。

For a single package, you can find this with

PACKAGE=ruby-enterprise
repoquery --qf "%{repoid}" $PACKAGE

Replace $PACKAGE with the name of the package you care about.

You can find all packages that came from a specific repository with

REPO=ruby-enterprise-opt
repoquery --repoid=$REPO -a --qf "%{name}" | sort > repo_packages
rpm -qa --qf "%{name}\n" | sort > installed_packages
comm -1 -2 repo_packages installed_packages

Replace $REPO with the id of the repository you care about; you can see the ids of all your enabled repositories with yum repolist.

岁月无声 2024-07-22 02:12:44

以下是发现给定已安装软件包的存储库的一些方法:

rpm -qi {packagename}

repoquery -i {packagename}

参考:

Here are some ways of discovering the repository for a given installed package:

rpm -qi {packagename}

or

repoquery -i {packagename}

References:

永不分离 2024-07-22 02:12:44
yum reinstall [package_name]

然后,当要求确认时,您可以选择 N 不更改您的系统:

centos 上的示例输出:

Resolving Dependencies
--> Running transaction check
---> Package mc.x86_64 1:4.6.1a-35.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================
 Package                      Arch                             Version                                   Repository                      Size
==============================================================================================================================================
Reinstalling:
 mc                           x86_64                           1:4.6.1a-35.el5                           base                           2.1 M

Transaction Summary
==============================================================================================================================================
Remove        0 Package(s)
Reinstall     1 Package(s)
Downgrade     0 Package(s)

Total download size: 2.1 M
Is this ok [y/N]:
yum reinstall [package_name]

Then when asked to confirm, you can choose N to not change your system:

Sample output on a centos:

Resolving Dependencies
--> Running transaction check
---> Package mc.x86_64 1:4.6.1a-35.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================
 Package                      Arch                             Version                                   Repository                      Size
==============================================================================================================================================
Reinstalling:
 mc                           x86_64                           1:4.6.1a-35.el5                           base                           2.1 M

Transaction Summary
==============================================================================================================================================
Remove        0 Package(s)
Reinstall     1 Package(s)
Downgrade     0 Package(s)

Total download size: 2.1 M
Is this ok [y/N]:
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文