TechnologyWeb

Changing RHEL6 to CentOS packages

CentOS 4.2 Welcome en 3Recently I was using a canned VM that had RedHat EL6 loaded on it, and needed to add a package, only to find that the package had been moved to the RedHat base repository.

 

 

 

 

First, I tried simply installing what I needed:

[root@hipchat ~]# yum install haproxy
Loaded plugins: product-id, refresh-packagekit, rhnplugin, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
There was an error communicating with RHN.
RHN Satellite or RHN Classic support will be disabled.

Error Message:
 Please run rhn_register as root on this client
Error Class Code: 9
Error Class Info: Invalid System Credentials.
Explanation:
 An error has occurred while processing your request. If this problem
 persists please enter a bug report at bugzilla.redhat.com.
 If you choose to submit the bug report, please be sure to include
 details of what you were trying to do when this error occurred and
 details on how to reproduce this problem.

Setting up Install Process
No package haproxy available.
Error: Nothing to do

So the first thing I noticed was that this was a cloned machine that has a bad systemid, so it wants to be registered with RedHat. Just to get rid of the initial message, I tried removing the systemid from /etc/sysconfig/rhn:

[root@hipchat rhn]# yum install haproxy
Loaded plugins: product-id, refresh-packagekit, rhnplugin, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
This system is not registered with RHN Classic or RHN Satellite.
You can use rhn_register to register.
RHN Satellite or RHN Classic support will be disabled.
Setting up Install Process
No package haproxy available.
Error: Nothing to do

So next I needed to add the CentOS repositories and remove the RedHat ones (since I have no subscription for this VM. So going to the /etc/yum.repos.d, I simply renamed the .repo to .repo.save:

[root@hipchat etc]# cd yum.repos.d/
[root@hipchat yum.repos.d]# ls
rhel-source.repo
[root@hipchat yum.repos.d]# mv rhel-source.repo rhel-source.repo.save

Next, I copied the CentOS repo files from an existing machine, which put the basic file in place, but since this file relies on the $releasever, it still errors out:

[root@hipchat yum.repos.d]# yum install haproxy
Loaded plugins: product-id, refresh-packagekit, rhnplugin, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
This system is not registered with RHN Classic or RHN Satellite.
You can use rhn_register to register.
RHN Satellite or RHN Classic support will be disabled.
http://mirror.centos.org/centos/6Server/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again

In order to get this to work, I simply have to edit the CentOS-Base.repo file again, and replace the variable with the number of the release I want:

# 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

#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

#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-6

#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-6

#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-6

In “vi” I just typed:

:%s/$releasever/6/g

And the file was updated to:

# 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-6 - Base
mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
baseurl=http://mirror.centos.org/centos/6/os/$basearch/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

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

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

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

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

This now sets the repositories to point properly, so running the command again should work, but of course I forgot the GPG file:

[root@hipchat yum.repos.d]# yum install haproxy
Loaded plugins: product-id, refresh-packagekit, rhnplugin, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
This system is not registered with RHN Classic or RHN Satellite.
You can use rhn_register to register.
RHN Satellite or RHN Classic support will be disabled.
base                                                                                                                                                                      | 3.7 kB     00:00
base/primary_db                                                                                                                                                           | 4.4 MB     00:05
extras                                                                                                                                                                    | 3.4 kB     00:00
extras/primary_db                                                                                                                                                         |  19 kB     00:00
updates                                                                                                                                                                   | 3.4 kB     00:00
updates/primary_db                                                                                                                                                        | 3.7 MB     00:03
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package haproxy.x86_64 0:1.4.24-2.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================================
 Package                                       Arch                                         Version                                             Repository                                  Size
=================================================================================================================================================================================================
Installing:
 haproxy                                       x86_64                                       1.4.24-2.el6                                        base                                       457 k

Transaction Summary
=================================================================================================================================================================================================
Install       1 Package(s)

Total download size: 457 k
Installed size: 1.5 M
Is this ok [y/N]: y
Downloading Packages:
haproxy-1.4.24-2.el6.x86_64.rpm                                                                                                                                           | 457 kB     00:00
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6


GPG key retrieval failed: [Errno 14] Could not open/read file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

So all I need to do is add the signature file, which I can do using rpm directly (there’s probably a way to do this with yum, but I don’t know it, so I’ll resynch after the import):

rpm --import http://isoredirect.centos.org/centos/6/os/x86_64/RPM-GPG-KEY-CentOS-6

Once that is done, the update succeeds:

[root@hipchat yum.repos.d]# yum install haproxy
Loaded plugins: product-id, refresh-packagekit, rhnplugin, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
This system is not registered with RHN Classic or RHN Satellite.
You can use rhn_register to register.
RHN Satellite or RHN Classic support will be disabled.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package haproxy.x86_64 0:1.4.24-2.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================================
 Package                                       Arch                                         Version                                             Repository                                  Size
=================================================================================================================================================================================================
Installing:
 haproxy                                       x86_64                                       1.4.24-2.el6                                        base                                       457 k

Transaction Summary
=================================================================================================================================================================================================
Install       1 Package(s)Total size: 457 k
Installed size: 1.5 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : haproxy-1.4.24-2.el6.x86_64                                                                                                                                                   1/1
  Verifying  : haproxy-1.4.24-2.el6.x86_64                                                                                                                                                   1/1Installed:
  haproxy.x86_64 0:1.4.24-2.el6Complete!

Then to make the system completely up to date, you just run “yum update”, and voila, you have a running CentOS box.

Hi, I’m Rob Weaver