Build a Custom Repository for CentOS 5

This will walk you through the steps of creating a local repository. We did this initially to allow for a Custom out of band version of a package. It’s not officially supported, nor is it part of the various Centos 5.3 depots (os, updates, CentOSPlus, CentOS Extras, etc.)

1 – Create a new directory in the same places are your OS and Upgrades depots. This isn’t necessary, and in fact the repo could be placed anywhere. However, doing it this way will greatly simplify things. I called this “local”

2 – Copy your files into the local repository. These have to be RPM files and you should probably make sure they are fully functional before you attempt to either build the repodata or install the files.

3 – If you haven’t previously installed the createrepo program, you must do so now. It can be downloaded from HERE. Once installed, the executable lives in /usr/bin/createrepo.

4 – Let’s create the repository. Since createrepo isn’t in my path, I’m going to use the fully qualified paths, and I’m going to make sure to run it from within the directory for correct placement of the repodata. Whenever you add a new file, you’ll need to recreate the repo data.

cd /opt/depot/CentOS/5.3/local
/usr/bin/createrepo /opt/depot/CentOS/5.3/local

5 – Create the correct .repo file. You can either create a new file, or add it to an existing file. I chose to add it to an existing file, for simplicities sake. At the end of the file, add

[local]
name=CentOS-$releasever – local
baseurl=http://your kickstart or patching server/ks/CentOS/$releasever/local/
gpgcheck=0
enabled=1

gpgcheck is disabled because I didn’t generate a GPG key, and enabled just means this repository is enabled.

6 – Push the updated .repo file to your environment and you are done.