[mirrorbrain] Support for Yum mirror lists

From: Peter Pml <peter_at_poeml.de>
Date: Sat, 13 Nov 2010 00:59:37 +0100

there is a new feature in trunk, the idea of which came up on the CentOS
mirror mailing list.  I just committed it to trunk:
A review would be appreciated.

It works like this. Yum issues a request with appended query arguments like
?release=5.5&arch=x86_64&repo=os and expects a simple, plain text list of
mirror URLs, with the URLs pointing to the base of the requested repository.

Now, a mapping can be configured from the query arguments to a directory on the
server plus a file that is used as indicator of the mirror having the
repository or not.

In the below example, I configured some common mappings for (parts of) a CentOS
file tree:

  MirrorBrainYumDir release=(4|4\.8|5|5\.5) repo=(os|extras|addons|updates|centosplus|contrib) arch=i586    $1/$2/i386    repodata/repomd.xml
  MirrorBrainYumDir release=(4|4\.8|5|5\.5) repo=(os|extras|addons|updates|centosplus|contrib) arch=x86_64  $1/$2/x86_64  repodata/repomd.xml

The syntax of the new directive is:

     Specify query arguments mapping to a directory that must have a certain file.
     arg1=<regexp> [ arg2=<regexp> ... ] <basedir> <mandatory_file>
  Parts of basedir can be substituted with query arguments $1-$9.
  Patterns are forced to be anchored to start and end for security reasons.

In the snippet below, I'm requesting different repositories and it looks
just as it should. (The server always returns mirror.netcologne.de first
because the IP is in the same AS.)

 # curl -H "X-forwarded-for:" 'http://centos/?release=5&arch=x86_64&repo=os'
 # curl -H "X-forwarded-for:" 'http://centos/?release=4&arch=i586&repo=updates'

Helpful is that symlinks in the file tree are automatically handled;
thus, looking up a file in the database works regardless of whether one
of the query arguments points to a symlink. That's the case in the
CentOS tree, e.g.:
lrwxrwxrwx  1 root root    3 Nov 11 22:35 4 -> 4.8

Maybe the functionality can be also used for other clients than Yum.


mirrorbrain mailing list
Archive: http://mirrorbrain.org/archive/mirrorbrain/

Note: To remove yourself from this mailing list, send a mail with the content
to the address mirrorbrain-request_at_mirrorbrain.org
Received on Fri Nov 12 2010 - 23:59:45 GMT

This archive was generated by hypermail 2.3.0 : Sun Nov 14 2010 - 18:17:06 GMT