Can yum tell me which of my repositories provide a particular package?
Asked Answered
W

7

43

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.

Wilburwilburn answered 11/3, 2009 at 18:54 Comment(0)
U
46
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.

Unpeopled answered 11/3, 2009 at 19:3 Comment(1)
Atomic Repo users: Vendor is blank for Atomic RPMs, but if the "Build Host" is "archelon", it's from Atomic.Hag
R
30
repoquery -i {packagename} 

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

Rottenstone answered 6/1, 2012 at 15:40 Comment(0)
S
15

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

Sicken answered 29/8, 2013 at 16:18 Comment(0)
P
4

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.

Plowman answered 11/4, 2012 at 4:16 Comment(0)
B
1

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

rpm -qi {packagename}

or

repoquery -i {packagename}

References:

Bawdy answered 10/9, 2017 at 16:43 Comment(0)
B
0
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]:
Bisson answered 24/10, 2014 at 6:48 Comment(1)
Thanks. As all the other solutions failed for any reason, this fallback saved my day :)Did
B
0

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                                 
Barnet answered 26/1, 2021 at 10:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.