[CentOS] Create a Yum repository for CentOS 5?

Sat Feb 9 09:16:17 UTC 2008
Johnny Hughes <johnny at centos.org>

Niki Kovacs wrote:
> Hi,
> 
> I'm using CentOS 5.1 on both server and desktops. I have a series of 
> packages that I either rebuilt from CentOS SRPMS to modify them 
> according to my needs (PHP for example), or that I built from Fedora 
> Core SRPMS because they're not available on CentOS nor in the RPMForge 
> repos (Seamonkey, MPD with libshout support, xmms-wma, ...).
> 
> I want to create my own remote Yum repository for these packages, but I 
> don't quite know how to achieve that. I've done something similar with 
> Slackware and swaret before, though, so I sort of grasp the logic behind 
> it.
> 
> Is it possible to do that on a remote server where I only have FTP 
> access? E. g. somehow create the repo locally on one build box, copy the 
> whole tree over to the remote machine and then add some according 
> file/stanza in /etc/yum.repos.d/ ?

Yes, it is easy to do.

You just put the RPMS in a directory ... it would be nice to separate 
them by arch and version.

You then run the command:

createrepo .

 From withing that directory is fine ... or like we do, one level up is 
also fine, as createrepo will descend down to all LOWER directories too.

When you run createrepo, it will generate a directory called repodata in 
the directory where it is run.  This is where you will point your yum to 
in order to get the updates ... so if you had:

so .. if you had:

<webdir>/repos/-|
                 |-4/-|
                 |    |-/i386/---|
                 |    |          |-/RPMS/
                 |    |          |-/repodata
                 |    |
                 |    |-/X86_64/-|
                 |               |-/RPMS/
                 |               |-/repodata
                 |
                 |-5/-|
                 |    |-/i386/---|
                 |    |          |-/RPMS/
                 |    |          |-/repodata
                 |    |
                 |    |-/X86_64/-|
                 |               |-/RPMS/
                 |               |-/repodata

In this case, you would just go inside the i386 and x86_64 dirs (at the 
same level as the RPM dir) and run "createrepo ."

you would then ftp the entire repo tree into the webdir and publish

Then you would point to i386 or x86_64 dir to get the updates.

There is a switch called -g for groups, you can add an xml file in a 
comps format to i386 directory for an example of this, see the comps.xml 
file here:

http://mirror.centos.org/centos/5/os/i386/repodata/comps.xml

here is group (comps) file that we created for extras:

http://mirror.centos.org/centos/5/extras/i386/yumgroups.xml

You would just do this to include group info (once you have the file):

createrepo -g <path>/<group_file_name>.xml .

In the above example, I would run createrepo 4 times (once in each i386 
and x86_64 dir).

Then you have a yum repo ... copy it wherever you want.

Thanks,
Johnny Hughes

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <http://lists.centos.org/pipermail/centos/attachments/20080209/a33c1355/attachment-0004.sig>