Search:  
Gentoo Wiki

Gentoo_Server_Serving_Gentoo

Contents

What we'd need

Set up an ftp server

We first need to setup an ftp server. Anonymous ftp could work or not, it depends on what exactly are going to distribute. Some packages can put you in legal trouble if you redistribute them in compiled form when compiled with certain options (e.g.: the Mozilla stuff). So, we are going to setup a non-anonymous ftp server only for personal use. If you want, you can setup something simpler, like oftpd which just allow anonymous ftp, but then you are the one that take the responsibility about the contents of the BINHOST. You have been warned.

So, as a example, we will use pure-ftpd, but any other with at least unix or pam authentication would do. You can use whatever you prefer:

emerge pure-ftpd

Edit the config file: /etc/conf.d/pure-ftpd. Look for these lines, and make sure they are not commented out:

IS_CONFIGURED="yes"
SERVER="-S 21"
AUTH="-l pam"
MISC_OTHER="-A -x -j -R -Z -Y -P"

Most options for MISC_OTHER are explained at the end of the file. I just added -Y for tls (make sure you have the gnutls USE flag enabled) and -P to allow passive mode.

Finally, rise up your ftp server and add it to the default runlevel if you wish:

/etc/init.d/pure-ftpd start && rc-update add pure-ftpd default

And here is a sample iptables rule in case you have a firewall (you should):

#Allow access to our ftp server from the WAN
iptables -A INPUT -p TCP --dport ftp -i eth0 -j ACCEPT
iptables -A INPUT -p UDP --dport ftp -i eth0 -j ACCEPT

Make sure that the interface is correct. You can add more rules if you need to serve files via ftp on many NICs.

Now, we create a new user, the one that will be accesing your portage using ftp. Make sure you use a correct path to your portage directory:

useradd foo
usermod --groups portage --home /usr/portage/ foo
passwd foo
[enter a password here, twice]

Now, try to login via ftp, you can use mc, a web browser or any command line ftp client to do so. Usually, the syntax is as follows:

ftp://foo@servername.org

Or for mc:

/#ftp:foo:password@servername.org

If you can't login, make sure that pure-ftpd is running, and that your firewall is allowing traffic though port 21 on both, the client and the server.

Configure your make.conf (server side)

Now, we will prepare portage to build binary packages from now on:

FEATURES="buildpkg"

Or just add "buildpkg" somewhere in between the quotes if a FEATURES lines is already present. If buildpkg was not previously set in make.conf then you need to manually create the binary tarfiles that will be used by the clients. This makes binaries of everything in 'world':

cd /var/db/pkg/; for i in */*; do echo $i; done | while read package; do quickpkg --include-config=y =$package; done

Or if you prefer, a more compact form:

cd /var/db/pkg/; for i in */*; do quickpkg --include-config=y =$i; done

You might need to emerge gentoolkit to be able to use quickpkg, if it is not already present on your system.

Built packages can be found under /usr/portage/packages/All/.

This little workaround is needed because now we are acting as root:

chown -R portage:portage /usr/portage/packages/

Depending on your settings, you might need to do this as well:

find /usr/portage/packages/ -type d -exec chmod 755 '{}' \;
find /usr/portage/packages/ -type f -exec chmod 644 '{}' \;

From now on, as we will be using the buildpkg feature, all the permissions *should* be correct. But have this in mind just in case.

Configure client boxes

Edit /etc/make.conf on the client box and add this:

PORTAGE_BINHOST="ftp://foo:password@servername.org/packages/All/"

Of course, change the password and server name to match yours.

On your make.conf, use this so portage will check your binhost first:

GENTOO_MIRRORS="ftp://servername.org/ <...the rest of your mirrors here...>"

Finally, emerge anything you want with:

emerge -avGK some-package
Retrieved from "http://www.gentoo-wiki.info/HOWTO_setup_a_PORTAGE_BINHOST_server"

Last modified: Thu, 02 Oct 2008 20:04:00 +0000 Hits: 10,660