Blog

  • 2014
    • 12
    • 11
    • 10
    • 09
    • 08
    • 07
    • 06
    • 05
  • 2010
    • 12
    • 11
    • 10
    • 09
    • 08
    • 07
    • 06
    • 05
    • 04
    • 03
    • 02
    • 01
  • 2009
    • 12
    • 11
    • 10
    • 09
    • 08
    • 07
    • 06
    • 05
    • 04
    • 03
    • 02
    • 01
  • 2008
    • 08
    • 07
    • 06
    • 05
    • 04
    • 03
    • 02
    • 01
  • 2007
    • 12
    • 11
    • 10
    • 09
    • 08
    • 07
    • 06
    • 05
    • 04
    • 03
    • 02
    • 01
  • 2006
    • 12
    • 11
    • 10
    • 09
    • 08
    • 07
    • 06
    • 05
    • 04
    • 03
    • 02
    • 01
  • 2005
    • 12
    • 11
    • 10
    • 09
    • 04
    • 03
    • 02
    • 01
Posted 2005/01/26

Running a Gentoo Portage mirror on FreeBSD


When I was doing my Ph.D a few of us in our research group used Gentoo Linux and rather than beat up the official Portage mirrors I decided to provide a local mirror (like good a citizen). We had a moderately specced FreeBSD machine to do this on. This doc explains how I set up a Portage mirror on FreeBSD 5.3, it might not be the best way but it did work.

What this is not... This is not a guide to getting Portage working on FreeBSD so you can use ebuilds. It just lets you keep the Portage directories in sync and explains how to run the rsync daemon.

I used these webpages to help work out what to do: "Setting up Portage on FreeBSD" [1] [2] and "HOWTO to do a Local Rsync Mirror" [3].

Step 1: Installing Portage


I started with a basic installation of FreeBSD 5.3, you need to add a group for Portage and download and unpack the Portage software (tweaked for FreeBSD).
t-toaster:/root/# echo 'portage:*:250:root' >> /etc/group
t-toaster:/root/# pw useradd portage -g 250 -u 250 -s /sbin/nologin -d /nonexistent
ttoaster:/root/# cd /
t-toaster:/# wget http://dev.gentoo.org/~g2boojum/fbsd/gentoo-fbsd.tgz
t-toaster:/# tar xvzf gentoo-fbsd.tgz
t-toaster:/# ln -s /lib/libutil.so.4 /lib/libutil.so.3
t-toaster:/# echo virtual/libc sys-libs/glibc >> /var/cache/edb/virtuals
t-toaster:/# emerge inject sys-libs/glibc-2.3.2
Don't forget the shared library symbolic link. Now you should make sure that emerge runs.
t-toaster:/# emerge info
Portage 2.0.49 (unavailable, gcc-3.4.2, glibc-2.3.2-r0, 5.3-RELEASE)
=================================================================
System uname: 5.3-RELEASE i386 i386
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CFLAGS="-O2 -pipe"
CHOST="i686-pc-linux-gnu"
COMPILER="gcc"
CONFIG_PROTECT="/etc /var/qmail/control /usr/share/config /usr/kde/2/share/config /usr/kde/3/share/config"
CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d"
CXXFLAGS="-O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="-sandbox ccache -sandbox buildpkg noauto"
GENTOO_MIRRORS="http://gentoo.oregonstate.edu http://distro.ibiblio.org/pub/Linux/distributions/gentoo"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY=""
SYNC="rsync://rsync.us.gentoo.org/gentoo-portage"
USE="bsd"
Now you can use the emerge tool to download a copy of Portage files and directories. In this configuration the files will be put in /usr/portage/. It took up 250mb of space (Feb/2005).
t-toaster:/# emerge sync
>>> starting rsync with rsync://rsync.us.gentoo.org/gentoo-portage...
MOTD: Welcome to NetNITCO's Mirroring Server!
MOTD:
MOTD: aka - rsync15.us.gentoo.org [216.176.132.235]
MOTD:
receiving file list ...
110707 files to consider
app-admin/
...
...
[snipped]
...
...
wrote 5813 bytes read 2682772 bytes 26230.10 bytes/sec
total size is 86280153 speedup is 32.09

>>> Updating Portage cache: Done
#
Choose how frequently you would like to update Portage and add emerge sync to your crontab.

Stage 2: Setting up rsyncd


You need to configure the rsync daemon to provide access to the Portage tree and to make life. The config file I use is shown below, if you want a message to be displayed when people sync with this mirror put something in /etc/rsync/rsyncd.motd.
t-toaster:/# cat /etc/rsync/rsyncd.conf
uid = nobody
gid = nobody
use chroot = yes
max connections = 15
pid file = /var/run/rsyncd.pid
motd file = /etc/rsync/rsyncd.motd
log file = /var/log/rsync.log
log format = %t %a %m %f %b
syslog facility = local3
timeout = 300

[gentoo-portage]
path = /usr/portage
comment = Gentoo Linux Portage tree mirror
exclude = distfiles/ packages/
Coming from the Linux world I wrote an init script to start and stop the rsync daemon, no doubt there is a more "FreeBSD way" to do this.
t-toaster:/# cat /etc/init.d/rsyncd
#!/bin/bash
case "$1" in
start)
echo "Starting rsyncd"
rsync --daemon --config=/etc/rsync/rsyncd.conf --address=148.197.nnn.nnn
echo "Done"
;;
stop)
echo "Shutting down rsyncd"
kill -s 9 `cat /var/run/rsyncd.pid`
echo "Done"
;;
restart)
/etc/init.d/rsyncd stop
/etc/init.d/rsyncd start
;;
*)
echo "Usage: rsyncd (start|stop|restart)"
;;
esac
When started without the --address= parameter the daemon refused to listen on any interfaces (the way I read the manual I thought it would listen on all interfaces by default). So make sure you put the IP address of the interface you want rsyncd to listen on in the init script. You can test quickly by telneting to the service on port 873. To use the new mirror log onto a Gentoo box and edit /etc/make.conf, you need a line saying SYNC="rsync://148.197.nnn.nnn/gentoo-portage", obviously substitute the correct IP address.