The standard RPM package management tool in Fedora, Red Hat Enterprise Linux, and CentOS is the yum package manager. Yum works quite well. Using it with official and third-party repositories is a breeze to set up, but what if you want to use your own repository? Perhaps you manage a large computer lab or network and need to have — or want to have — certain packages available to these systems that you maintain in-house. Or perhaps you simply want to set up your own repository to share a few RPM packages.

Creating your own yum repository is very simple, and very straightforward. In order to do it, you need the createrepo tool, which can be found in the createrepo package, so to install it, execute as root:

# yum install createrepo

Once the package is installed, you can begin creating your repository. You will also need some RPM packages to create the repository with. Decide where you want to store your repository; let’s say, /var/ftp/repo will be the base directory.

Depending on how particular you want to get, you can dump everything to a single repository or keep things organized. So let’s assume you will be creating a repository for Fedora 10 and have i386 package you want to be made available with it. I would create an appropriate directory tree using the following commands:

# mkdir -p /var/ftp/repo/Fedora/10/{SRPMS,i386,x86_64}

Now copy your i386 packages to /var/ftp/repo/Fedora/10/i386, your x86_64 packages to /var/ftp/repo/Fedora/10/x86_64, and the SRPMS you have (if wanted) to /var/ftp/repo/Fedora/10/SRPMS. To easily automate the creation of the repository metadata, create a shell script called create-my-repo and place it somewhere in your PATH:

#!/bin/sh

destdir=”/var/ftp/repo/Fedora/10″

for arch in i386

do

pushd ${destdir}/${arch} >/dev/null 2>&1

createrepo .

popd >/dev/null 2>&1

done

Make the script executable and whenever you run it, it will call the createrepo tool on the directories: /var/ftp/repo/Fedora/10/i386. Once this is done, your repository is ready for use.

If /var/ftp is the available FTP root, then ftp://hostname.com/repo/Fedora/10/i386 would be the download URL for the i386 packages. To make this available to the other client systems, create a yum repository configuration file called /etc/yum.repos.d/my.repo with the following contents:

[myrepo]

name=My Repository

baseurl=ftp://hostname.com/repo/Fedora/10/$basearch

enabled=1

This file can be used on i386 client due to the “$basearch” specifier. It will be enabled the next time “yum update” is run.

Creating your own yum repository is very easy and very straightforward, and is a great way for administrators to distribute specialized packages within an organization.