Gentoo Portage Custom Mirror

Gentoo is awesome, we know. Maintaining it can be cumbersome for the unprepared. This document describes how to create a private rsync mirror and put your own custom ebuilds into it. The links at the bottom of this page were used as guides while writing this.

In this document, server is this new rsync mirror and client is a subscriber to the custom mirror.

Create Private Mirror

This is the mirror that all other systems in your domain/LAN/whatever will use. This will allow more control over the portage tree and reduce the load on Gentoo's own rsync mirrors. All you need to do is expose /usr/portage/ via rsync, super easy. Below is a copy of /etc/rsyncd.conf and /etc/conf.d/rsyncd, use those to start.

This Portage mirror must be updated before performing an emerge --sync on the clients.

pid file = /var/run/rsyncd.pid
uid = nobody
gid = nobody
use chroot = yes
read only = yes
hosts allow =
max connections = 5
syslog facility = local2
timeout = 120

  path = /usr/portage
  comment = Gentoo Linux Portage tree
  exclude = /distfiles /packages

RSYNC_OPTS="--config /etc/rsyncd.conf"

From another machine you can test it with:

rsync --list-only rsync://$rsync_server/

The output should look something like:

gentoo-portage  Gentoo Linux Portage tree

Customising the Mirror

At Edoceo we use many of our own custom ebuilds for our systems. These ebuilds are not part of the base Gentoo Portage tree, of course. To expose them we create a new ebuild category edoceo and put our packages in there. These couldn't be specified as Portage overlays as we would need to do that to all our systems and want this available to clients easily.

We are directly manipulating the Portage tree here, so be careful!

First, sync the local mirror against Gentoo:

emerge --sync

Add the custom categories; in this case, the vendor name:

echo edoceo >> /usr/portage/profiles/categories

Put your ebuilds and such into the local Portage mirror. A directory that stores the custom ebuilds is kept out the the Portage tree and copied in after each sync. A custom licence is also added:

cp -aiv /opt/edoceo/var/portage/* /usr/portage

That's it, now when the clients perform the sync they will get the tree that exists on this machine with all the custom goodies.

An automated update would look like this:

cat /opt/edoceo/sbin/portage-mirror-update
# Updates the mirror and replaces our stuffs

emerge --sync
# instead of the super easy 'emerge --sync' one could say:
# /usr/bin/rsync \
#   --exclude-from=/etc/portage/rsync_excludes \
#   --recursive --links --safe-links --perms --times --compress --force \
#   --whole-file --delete --delete-after --stats --timeout=180 \
#   --exclude=/distfiles --exclude=/local --exclude=/packages --verbose
#   rsync://rsync.gentoo.org/gentoo-portage/ /usr/portage

echo edoceo >> /usr/portage/profiles/categories
cp -a /opt/edoceo/var/portage/* /usr/portage

Using the Mirror

To use the mirror, the clients must know this host. Update /etc/make.conf on those system to contain this line.


See Also

Change Log

  • 27 Nov 2006 - Created /djb

Loading Comments from Disqus...