148

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".

14 Answers 14

80

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.
  • 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
  • 8
    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
  • user158844 is right. This will tell you what repos provide a given package, but not what repo a specific package came from. If you installed a package from a certain repo, removed that repo, then installed another repo that provides a package with the same name, running 'repoquery -i' like this would return to you packages listing the newly installed repo, not the one that you actually installed the package from. The asker wants to know what package the installed software actually came from. Not what current repos happen to have packages with the same name. – Todd Walton Jun 12 at 16:31
40

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.

  • 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
21

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

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.

  • +1. But it's even better to do something like: for i in /var/lib/yum/yumdb/b/*bind-utils*/*; do echo $i: `cat $i` | grep -oP 'from_repo:\ \K.*'; done, which in the above example returns: updates - much more readable! – Greg Dubicki Jan 27 '16 at 21:10
  • 1
    @GregDubicki The point of the command was to show more of the context of what is going on and how things are stored. It apparently failed to do so: There is no need to grep anything here, and you can even drop the loop. A very simple cat /var/lib/yum/yumdb/b/*bind-utils*/from_repo is all you need. – Michael Hampton Jan 27 '16 at 21:14
6
rpm -qi packagename

Will tell you the vendor and packager

5

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

  • 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
4

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.

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

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)

1

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.

  • 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
1

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.

  • 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 '14 at 4:09
1

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

yum info -v <package_name>

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

  • This seems to be the only solution that does not require installing yum-utils. – Mark Edington Jan 3 '17 at 21:25
  • This only lists "installed" for me. – frogstarr78 Mar 19 at 19:14
1

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.

1

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.

-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

  • 2
    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
  • 1
    The vendor has (almost) nothing to do with the repository. – Matteo Jul 20 '12 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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