YUM-Priorities Configuration for a CentOS Desktop

When it comes to software for your CentOS installation, there is no such thing as a good yum configuration, but a configuration that can bring you the software you need, while, at the same time, causing the least possible trouble regarding core package upgrades. This small article goes into the details of configuring YUM using the yum-priorities plugin. I use the following yum configuration on my desktop running CentOS 5.3 (at the moment of writing), but i do not mean to advertise specific 3rd party repositories and undervalue the rest. I mainly focus on setting priorities for them, so to avoid the trouble later.

First of all, some notes about the yum-priorities plugin and why it is important. By default, YUM installs or upgrades the latest version of an RPM package, regardless of the repository it (the package) exists in. This is normal and complies with yum’s role, which is to update your system with newer versions of software. But, this behavior could easily result in many core packages being overridden by 3rd party RPMs. This may not seem like trouble at first, but there is high probability that, when you upgrade your system at a later time, the upgrade procedure might get stuck because of dependency issues. These issues might even happen to the packages of the same repository. So, imagine how easy it is to happen to packages created by two or more different vendors and how difficult the resolution might be in the latter case. Mixing different yum repositories avoiding as much dependency-related trouble as possible is what yum-priorities does. Here is the official description of the plugin:

This plugin allows repositories to have different priorities. Packages in a repository with a lower priority can’t be overridden by packages from a repository with a higher priority even if repo has a later version.

Here follows my yum repositories configuration:


# Custom builds
[local-rpms]
name=Local Yum Repository
baseurl=ftp://192.168.0.70/pub/linux/centos/$releasever/$basearch/
enabled=1
gpgcheck=0
#gpgkey=
priority=1

# core packages
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=10

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=10

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=10

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=10

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=20

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=20

[adobe-linux-i386]
name=Adobe Systems Incorporated
baseurl=http://linuxdownload.adobe.com/linux/i386/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux
priority=30

# Name: RPMforge RPM Repository for Red Hat Enterprise 5 - dag
# URL: http://rpmforge.net/
[rpmforge]
name = Red Hat Enterprise $releasever - RPMforge.net - dag
#baseurl = http://apt.sw.be/redhat/el5/en/$basearch/dag
mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1
priority=40

Here are some notes:

  • A repository’s priority is rated like this: the smaller the priority number, the higher the priority of the repository. Packages from a specific repository cannot override (upgrade) packages of a repository with higher priority (smaller priority number).
  • In the above setup, the repository with the highest priority is my Local RPM repository. This repo contains custom builds of packages. Custom builds means that I have enabled or disabled specific compilation-time switches or that I have used a patch that is not yet used in the mainstream package. Usually, when I create custom builds of RPMs, I know what I am doing and, of course, I do not want my custom RPMs to be overridden by packages from other repositories, even official ones. So, this repository has the highest priority (priority=1).
  • base, updates, addons, extras are the official CentOS repositories and they all have priority 10.
  • As you can see in the above setup, centosplus and contrib repositories are not enabled. However, I have set a priority number that is between (priority=20) the priority number of the official repositories and the priority number of the 3rd party repositories.
  • Next comes Adobe‘s yum repository (priority=30) and finally RPMforge (priority=40). These are both 3rd party repositories. I highly recommend that you choose your 3rd party repositories carefully and set their priorities wisely. I would also advise against setting the same priority on two or more 3rd party repositories, unless you are 100% certain that they complement each other. If I ever use any other 3rd party repository, it will get a priority higher than 40 and so on.

So, this is how I have configured priorities on yum repositories at the moment. Note that this configuration is used on my desktop. On my Xen Dom0 and the four DomUs, which by the way all run CentOS, I use EPEL instead of RPMforge. Remember, it’s your own software needs that govern the use of 3rd party repositories.

Your feedback is welcome.

YUM-Priorities Configuration for a CentOS Desktop by George Notaras is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Copyright © 2009 - Some Rights Reserved

George Notaras avatar

About George Notaras

George Notaras is the editor of the G-Loaded Journal, a technical blog about Free and Open-Source Software. George, among other things, is an enthusiast self-taught GNU/Linux system administrator. He has created this web site to share the IT knowledge and experience he has gained over the years with other people. George primarily uses CentOS and Fedora. He has also developed some open-source software projects in his spare time.

2 responses on “YUM-Priorities Configuration for a CentOS Desktop

  1. dan Permalink →

    Hey there –

    As you appear to be quite a yum wizard, hopefully you can point me in the right direction here. For my CentOS system I have been updating things via yum through Webmin for quite a while – and never had an issue till today. After realizing that the system was still sitting on the same “updating” page for two hours I restarted it — and then found all sorts of problems. I can login via an SSH terminal from another system on the network or get there via webmin, but the monitor on the server itself never gets to a login – just a spinning cursor. What I see from webmin or a terminal window when I run yum is an error – found a few posts on it too, but nothing as a clear fix.

    [root@trailrunner yum]# yum clean all
    Traceback (most recent call last):
    File “/usr/bin/yum”, line 28, in ?
    import yummain
    File “/usr/share/yum-cli/yummain.py”, line 29, in ?
    import cli
    File “/usr/share/yum-cli/cli.py”, line 30, in ?
    import output
    File “/usr/share/yum-cli/output.py”, line 26, in ?
    from i18n import _
    ImportError: No module named i18n
    [root@trailrunner yum]#

    Though I use to work at the Command line regularly, those skills are rusty these days. I suspect that I should try reinstalling Yum directly – but not entirely sure how to do that, and what I should blow out prior to doing that which might also get the server unstuck.

    Truly hoping you have a suggestion.

    1. George Notaras Post authorPermalink →

      Hi,

      Re-installing yum is definitely the first thing you should try, but, afterwards, make sure you investigate what might have caused the whole issue. Why is the i18n yum module missing?

      In order to re-install yum use the following rpm command directly as root:

      rpm --force --replacepkgs <url_to_yum.rpm>
      

      Hope this helps