Then use SLP!
I setup my home network with openslp and wrote a little script that writes a script for portage to execute. The concept goes a little like this:
You run a local rsync/distfile mirror. You have clients that want to use emerge and you don’t want it to suck up your bandwidth. Tell them to use your local services like this:
Server side:
emerge openslp
edit /etc/slp.reg so it looks like the following:
service:portage.rsync://192.168.1.1/gentoo-portage,en,65535
description=Gentoo Portage rsync tree
service:portage.http://192.168.1.1/distfiles,en,65535
description=Gentoo Portage distfiles mirror
(yes I know I shouldn’t have a /distfiles at the end of the URL, but I messed up my apache config and am too lazy to change it)
now do /etc/init.d/slpd start and you’re done with the server!
Client side:
emerge openslp
Using your favorite editor, create /usr/local/bin/portage-slp-services (or some other suitable location for a file to execute when a network device comes up) and add the following:
#!/bin/bash
PORTAGE_SOURCE_FILE=/etc/portage-slp.sh
rm ${PORTAGE_SOURCE_FILE}
touch ${PORTAGE_SOURCE_FILE}
SLP_SYNC=$(slptool findsrvs service:portage.rsync | sed -r -e 's/service:portage.(.*),(.*)/\1/g')
SLP_HTTP=$(slptool findsrvs service:portage.http | sed -r -e 's/service:portage.(.*),(.*)/\1/g')
SYNC=${SLP_SYNC}
GENTOO_MIRRORS="${SLP_HTTP} $(portageq gentoo_mirrors)"
echo "SYNC=${SYNC}" > ${PORTAGE_SOURCE_FILE}
echo "GENTOO_MIRRORS=\"${GENTOO_MIRRORS}\"" >> ${PORTAGE_SOURCE_FILE}
Then edit /etc/make.conf and add source /etc/portage-slp.sh to the end.
Finally, edit /etc/conf.d/net and add the following:
postup() {
/usr/local/bin/portage-slp-services
}
and you’re done!
do a touch /etc/portage-slp.sh the first time so portageq doesn’t barf(it barfs when trying to source a non-existent file) and restart your network device. You should find that you’ll use your local mirrors first if found when the network device came up.
There is one security concern: At this moment, we assume that whoever publishes a slp record is honest, there is no checking. until we have tree signing in place, you can use gpg to sign the slp record and then verify it on the client, both that the record is correct and signed by someone you trust.
That’s it for now, keep tuned for more developments!