Getting yum to show all packages that match

by Karanbir Singh Email

One issue that lots of people run into is when they want a list of all pacakges in the repositories that match their requirements. By default yum will only show you the 'newest' or the 'highest version'. So looking for kernel-devel does this:

[root@chamkaur ~]# yum list kernel-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * fasttrack: mirror.ukhost4u.com
 * extras: mirror.ukhost4u.com
 * updates: mirror.ukhost4u.com
 * base: mirror.ukhost4u.com
 * addons: mirror.ukhost4u.com
Installed Packages
kernel-devel.x86_64                2.6.18-8.1.10.el5                   installed
kernel-devel.x86_64                2.6.18-53.1.4.el5                   installed
kernel-devel.x86_64                2.6.18-92.1.10.el5                  installed
Available Packages
kernel-devel.x86_64                2.6.18-128.1.10.el5                 updates  



Thats all good, except we have :

[root@chamkaur ~]# uname -r
2.6.18-128.1.6.el5



So what we are looking for is kernel-devel that matches our running kernel. Now, one way to do this is to run 'yum list kernel-devel-2.6.18-128.1.6.el5'; and if its there, we can install it. However, yum also has option called '--showduplicates', which will list all matches, not only the latest. Trying yum with that option gives us:

[root@chamkaur ~]# yum --showduplicates list kernel-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * fasttrack: mirror.ukhost4u.com
 * extras: mirror.ukhost4u.com
 * updates: mirror.ukhost4u.com
 * base: mirror.ukhost4u.com
 * addons: mirror.ukhost4u.com
Installed Packages
kernel-devel.x86_64            2.6.18-8.1.10.el5                      installed 
kernel-devel.x86_64            2.6.18-53.1.4.el5                      installed 
kernel-devel.x86_64            2.6.18-92.1.10.el5                     installed 
Available Packages
kernel-devel.x86_64            2.6.18-53.1.19.el5.bz321111            c5-testing
kernel-devel.x86_64            2.6.18-92.1.1.el5.bz444759             c5-testing
kernel-devel.x86_64            2.6.18-92.1.6.el5.bz_pre53             c5-testing
kernel-devel.x86_64            2.6.18-128.el5                         base      
kernel-devel.x86_64            2.6.18-128.1.1.el5                     updates 
kernel-devel.x86_64            2.6.18-128.1.6.el5                     updates 
kernel-devel.x86_64            2.6.18-128.1.10.el5                    updates  



Which gives us all the various versions of kenel-devel visible to yum, in enabled repos for the machine. And we can then go ahead run 'yum install kernel-devel-`uname -r`; and know its going to pull in the right version. The --showduplicates is also a good way to check the history of a package during its release cycle. And this option should become a lot more useful when you have the vault repos enabled.

1 comment

Comment from: Hanieh [Visitor]
Dear Karanbir
thank you so much, it was really helpful.
05/Sep/2009 @ 14:37

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)