How to configure repos to not overwrite base packages?

The greatest fear with adding additional and especially third party repos such as EPEL (we did a blog post on how to install EPEL earlier) is that it MAY overwrite base packages and bring the system to an unstable state.

We can fix this issue by installing Yum Priorities plugin

on CentOS 5:

yum install yum-priorities

on CentOS 4 or CentOS 6:

yum install yum-plugin-priorities

Then make sure that the plugin is enabled

nano /etc/yum/pluginconf.d/priorities.conf

Now there are two ways to do it, either set HIGHEST priority to CentOS repos OR set lowest priority to other repos. This is done by adding the line

# N=1 highest priority
# N=99 lowest priority
priority=N

In this blog post, I will set 1 as the priority (highest) for my CentOS Base repo

nano /etc/yum.repos.d/CentOS-Base.repo

So that it becomes

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[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-6
priority=1

#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-6
priority=1
...
...
...

Other repos do not need updating since I have assigned CentOS repos with the highest priority. The default priority for repositories is 99.

Leave a Reply