Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

After I have installed a package by yum (with multiple repository configured), how can I found from which repository it has been installed? If I run yum info package name (or yum list package name), I can found only that the package is "installed".

share|improve this question
1  
Great question! I installed yum-utils and tried one it's utils called repoquery, but no luck. –  Sean Staats Sep 3 '09 at 15:33
    
see also serverfault.com/questions/90409/… :) –  warren Dec 3 '09 at 12:43

11 Answers 11

up vote 35 down vote accepted

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

└─[$]> repoquery -i 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.
share|improve this answer
2  
repoquery does not seem to work right, i get different package versions then yum info package_name, it does not seem to query the repositories in the same order as yum. –  Mike Miller Nov 30 '10 at 16:38
    
Same here on a few servers. yum info package_name returns more results than repoquery apparently. This is why stack exchange should not lock in votes. –  reflexiv Dec 18 '12 at 5:51
2  
I found Xiong Chiamiov's answer not correct. repoquery -i $pkg gives repo from which a $pkg is available, not the repo from which the $pkg was installed. I did that command and rpm -qi $pkg and got different version numbers. rpm resulted in an earlier version number than that of repoquery. –  user158844 Feb 13 '13 at 18:48
    
It's possible your local copy is out-of-date, or it was installed with additional commands to yum (e.g. --use-mirror). I don't think it's possible to always get the right answer. –  Xiong Chiamiov Oct 5 '13 at 4:12

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.

share|improve this answer
    
I'm using yum 3.2.19 on CentOs 5.3 and "From repo" row doesn't exist. –  lg. Sep 3 '09 at 16:29
    
Yep...I was testing it on 3.2.21, which doesn't have that info anywhere. When I did it on my box that has 3.2.23, it worked. –  Alex Sep 3 '09 at 17:00
    
Now this is the best solution, but not applicable for RHEL/Centos 5.3. I accept this solution, but I ready to choose another answer if will be applicable also for RHEL/Centos 5.3. –  lg. Sep 4 '09 at 7:38
2  
This is a no-go in CentOS 5.5 either. –  Mike Miller Nov 30 '10 at 16:38
    
"From rep" is not available even in centos 5.8 –  sepehr Apr 7 '13 at 16:53

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'
share|improve this answer
    
It works also on Fedora 14 –  lg. Oct 28 '11 at 7:22
    
works on RHEL 6.2 –  pixelbeat Nov 8 '11 at 17:43

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.

share|improve this answer
    
This solution maybe an option (I vote it), but I am looking for a definitive answer. –  lg. Sep 4 '09 at 7:34

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 every thing installed.

repoquery --repoid=epel -a | xargs yum list installed

share|improve this answer
1  
This appears to work as long as there isn't an updated package in the repository. So you need to run yum update just before using it. –  codewaggle May 29 '12 at 9:22

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

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.

share|improve this answer

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.

share|improve this answer
    
This solution maybe an option (I vote it), but only for recent installed package, because I can change the repository and their priority. –  lg. Sep 4 '09 at 7:31

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.

share|improve this answer
    
This is true only is the package is not yet installed. –  lg. Sep 4 '09 at 7:20
    
While it doesn't answer the OPs question exactly, it was very helpful for me because it works in Centoss 5.5 with just yum and no other utils, and you can: 1. Uninstall the package then query to see where the repo is then reinstall, or 2. Query on a different machine without the package installed. –  lreeder Dec 4 at 4:09
rpm -qi packagename

Will tell you the vendor and packager

share|improve this answer

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)

share|improve this answer

The easiest way is this:

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

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

share|improve this answer
1  
In this way (adding a pipe whith grep -i package name) I discover the vendor, but not the repository. –  lg. Feb 7 '11 at 7:43
    
The vendor has (almost) nothing to do with the repository. –  Matteo Jul 20 '12 at 7:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.