Cain Manor

Your Guide To All Things Cain™

Build a Custom Repository for CentOS 5

This will walk you through the steps of cre­at­ing a local repos­i­tory. We did this ini­tially to allow for a Cus­tom out of band ver­sion of a pack­age. It’s not offi­cially sup­ported, nor is it part of the var­i­ous Cen­tos 5.3 depots (os, updates, Cen­tOSPlus, Cen­tOS Extras, etc.)

1 — Cre­ate a new direc­tory in the same places are your OS and Upgrades depots. This isn’t nec­es­sary, and in fact the repo could be placed any­where. How­ever, doing it this way will greatly sim­plify things. I called this “local”

2 — Copy your files into the local repos­i­tory. These have to be RPM files and you should prob­a­bly make sure they are fully func­tional before you attempt to either build the repo­data or install the files.

3 — If you haven’t pre­vi­ously installed the cre­aterepo pro­gram, you must do so now. It can be down­loaded from HERE. Once installed, the exe­cutable lives in /usr/bin/createrepo.

4 — Let’s cre­ate the repos­i­tory. Since cre­aterepo isn’t in my path, I’m going to use the fully qual­i­fied paths, and I’m going to make sure to run it from within the direc­tory for cor­rect place­ment of the repo­data. When­ever you add a new file, you’ll need to recre­ate the repo data.

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

5 — Cre­ate the cor­rect .repo file. You can either cre­ate a new file, or add it to an exist­ing file. I chose to add it to an exist­ing file, for sim­plic­i­ties sake. At the end of the file, add

[local]
name=CentOS-$releasever — local
baseurl=http://your kick­start or patch­ing server/ks/CentOS/$releasever/local/
gpgcheck=0
enabled=1

gpgcheck is dis­abled because I didn’t gen­er­ate a GPG key, and enabled just means this repos­i­tory is enabled.

6 — Push the updated .repo file to your envi­ron­ment and you are done.

Comments are closed.