199

After I have installed a package by yum (with multiple repositories configured), how can I find from which repository it has been installed?

If I run yum info package-name (or yum list package-name), I can only see that the package is "installed".

techraf
  • 4,403
lg.
  • 4,759

15 Answers15

109

With yum-utils installed, repoquery (with the --info option) will provide the information you seek (here 'epel' being the repository).

$ repoquery --info cherokee

Name : cherokee Version : 0.99.49 Release : 1.el5 Architecture: i386 Size : 8495964 Packager : Fedora Project Group : Applications/Internet URL : http://www.cherokee-project.com/ Repository : epel Summary : Flexible and Fast Webserver Description : Cherokee is a very fast, flexible and easy to configure Web Server. It supports the widespread technologies nowadays: FastCGI, SCGI, PHP, CGI, TLS and SSL encrypted connections, Virtual hosts, Authentication, on the fly encoding, Apache compatible log files, and much more.

breversa
  • 105
60

What version of yum?

On the current version if the installed package is the same version as the most recent one available then the repo it was installed from is shown.

$ yum info irssi
Installed Packages
Name       : irssi
Arch       : i586
Version    : 0.8.14
Release    : 1.fc11
Size       : 2.3 M
Repo       : installed
From repo  : updates
Summary    : Modular text mode IRC client with Perl scripting
URL        : http://irssi.org/
License    : GPLv2+
Description: Irssi is a modular IRC client with Perl scripting. Only text-mode
           : frontend is currently supported. The GTK/GNOME frontend is no
           : longer being maintained.

$ yum --version
3.2.23

If there is a newer package available, then it will be shown separately, with the new version showing the repo it's available from.

27

Coming way to late but (at least on Fedora 15) one can use yumdb for similar queries:

yumdb info 'python*'

And what I actually needed to list packages from given repo(s):

yumdb search from_repo 'my-*-repo'
Martian
  • 1,110
16

If all else fails, you can inspect the yumdb manually. It's located in /var/lib/yum/yumdb and contains detailed information on every installed package. You'll be particularly interested in from_repo. For example, for the bind-utils package:

# for i in /var/lib/yum/yumdb/b/*bind-utils*/*; do echo $i: `cat $i`; done
/var/lib/yum/yumdb/b/73ea08770fa666e18c59842bf65fa0f3a0b103d8-bind-utils-9.8.2-0.23.rc1.el6_5.1-x86_64/checksum_data: 39f7840f93d3d76825a9e8da79cfe0366f7fad68f018a273477aee62cccfa3f4
/var/lib/yum/yumdb/b/73ea08770fa666e18c59842bf65fa0f3a0b103d8-bind-utils-9.8.2-0.23.rc1.el6_5.1-x86_64/checksum_type: sha256
/var/lib/yum/yumdb/b/73ea08770fa666e18c59842bf65fa0f3a0b103d8-bind-utils-9.8.2-0.23.rc1.el6_5.1-x86_64/command_line: install bind-utils
/var/lib/yum/yumdb/b/73ea08770fa666e18c59842bf65fa0f3a0b103d8-bind-utils-9.8.2-0.23.rc1.el6_5.1-x86_64/from_repo: updates
/var/lib/yum/yumdb/b/73ea08770fa666e18c59842bf65fa0f3a0b103d8-bind-utils-9.8.2-0.23.rc1.el6_5.1-x86_64/from_repo_revision: 1397654451
/var/lib/yum/yumdb/b/73ea08770fa666e18c59842bf65fa0f3a0b103d8-bind-utils-9.8.2-0.23.rc1.el6_5.1-x86_64/from_repo_timestamp: 1397654759
/var/lib/yum/yumdb/b/73ea08770fa666e18c59842bf65fa0f3a0b103d8-bind-utils-9.8.2-0.23.rc1.el6_5.1-x86_64/installed_by: 0
/var/lib/yum/yumdb/b/73ea08770fa666e18c59842bf65fa0f3a0b103d8-bind-utils-9.8.2-0.23.rc1.el6_5.1-x86_64/reason: user
/var/lib/yum/yumdb/b/73ea08770fa666e18c59842bf65fa0f3a0b103d8-bind-utils-9.8.2-0.23.rc1.el6_5.1-x86_64/releasever: 6

To get just the information you want:

# cat /var/lib/yum/yumdb/b/*bind-utils*/from_repo
updates

Later versions will provide even more data; for instance in EL 7 the exact mirror and URL from which the package was downloaded is stored here.

Michael Hampton
  • 252,907
9

To see what installed from repo epel: (Should work under Centos 5.5) note, if you have no repo named epel, it will spit out everything installed.

repoquery --repoid=epel -a | xargs yum list installed
KyleMit
  • 498
7
rpm -qi packagename

Will tell you the vendor and packager

Esmail
  • 71
7

The simplest and most straightforward approach without installing any extra tools, greping or outputting extraneous information is simply:

yum list installed [package name]

The third column will provide the ID of the repository the package was installed from.

This was mentioned in a comment on the original question using grep, but that's not necessary. You can just pass the package name directly to yum to filter.

5

Based on and answer by Swoogan
On RedHat and CentOS one can do

sudo grep -ir PACKAGE_NAME /var/cache/yum/

The results should look something like

Binary file /var/cache/yum/REPOSITORY_NAME/primary.xml.gz.sqlite matches

Where repository_name is the repository where your package can be found, and it was probably installed from the first one in a list (see yum repolist)

iddqd
  • 203
5

If the package was installed recently, you can look in /var/cache/yum.

Within that directory, there is a directory for each repo, and in that a packages directory. So, you would do something like:

find /var/cache/yum -name [package-name]*

However, cache has to be enabled in your /etc/yum.conf file:

cachedir=/var/cache/yum
keepcache=1

Note that a yum clean [packages|all] will clear out the cache directory.

If the cache directory is empty, there is an alternative way. The information that is read by yum info [package] comes from /var/cache/yum/[repo]/primary.xml.gz

You can look through the file by entering:

gunzip -d -c /var/cache/yum/[repo]/primary.xml.gz | grep '<name>[package]'

However, on machines where yum info [package] does not display "From repo : ", as indicated by 'theotherreceive', it is because it is not in the file primary.xml, so there will be no way to retrieve that information. Therefore, if the package is in two or more primary.xml files, you will have to determine the repo priority on you system.

Swoogan
  • 2,107
3

So I know this is a somewhat old question - but it comes up on the google search for what I was looking for.

There is also a method to get a unique list of repos used:

# repoquery -ai | grep 'Repository  : ' | sort | uniq

This will list the repositories that have had packages installed from.

3

None of the above commands worked for me. This is what I had to do.

yum provides "*compat-libstdc*"

A good reference is here.

https://access.redhat.com/sites/default/files/attachments/rh_yum_cheatsheet_1214_jcs_print-1.pdf

cokedude
  • 131
2

Is that information captured anywhere? The package doesn't have that information, and yum doesn't care after it finds the package. You could probably piece it together by figuring out what repos have the package and then determine which one has priority.

Alex
  • 6,723
2

Not a great solution, but I found that yum list available will show you where the most up to date version of each package is available, e.g.:

yum list available | grep gstreamer

PackageKit-gstreamer-plugin.x86_64 0.3.16-1.fc10          updates               

bluez-gstreamer.i386 4.30-2.fc10 updates
gstreamer.i386 0.10.21-2.fc10 fedora
gstreamer-devel.i386 0.10.21-2.fc10 fedora
gstreamer-devel.x86_64 0.10.21-2.fc10 fedora
gstreamer-plugins-bad-devel.i386 0.10.9-1.fc10 rpmfusion-free
gstreamer-plugins-bad-devel.x86_64 0.10.9-1.fc10 rpmfusion-free

So you could do a yum list available on your package, then compare your installed version using yum list installed, and have a good idea of which repo it came from if the versions match.

2

You can add the verbose flag to "yum info":

yum info -v <package_name>

The installation repository will be under the "From repo" output.

smw
  • 21
-1

The easiest way is this:

rpm -qa --qf '%{NAME} %{VENDOR}\n'

More tips and tricks are available here: http://wiki.centos.org/TipsAndTricks/YumAndRPM

Greg Dubicki
  • 1,415
  • 1
  • 20
  • 34