Feb 252000

distfile sharing via anonymous FTP

# Distfile sharing using anonymous FTP
# By Will Andrews andrews@technologist.com
# Monday, February 21, 2000

I have a nice Fast Ethernet home network setup.  I also have two separate FreeBSD machines; one runs 4.0-CURRENT and the other runs 3.4-STABLE.  Now, I have a little problem: I like to use similar ports on both.   How can I prevent myself from having to redownload the distfiles if I already have a copy on my local network?

Dan Langille came up with a solution – NFS shares.  However, I think an easier method (in terms of setting up) would be to use FreeBSD’s builtin FTPD daemon.

Note that since we don’t always use the same machine to (originally) retrieve the distfiles, both machines should be setup the same way.

First things first. I had to setup my FTPD chroot to allow anonymous logins. I followed the instructions in the ftpd(8) manpage for this procedure.  Ignore the instruction to put a copy of /bin/ls in ~ftp/bin, though – your FTPD should be able to provide ls(1) output internally.  If not, recompile FTPD with the FTPD_INTERNAL_LS option.  Dan’s diary entry about how to do this explains it well.

Since we do not already have /usr/ports/distfiles under ~ftp, we must perform that task.  My method was to first create the ~ftp/dist directory, then move everything in /usr/ports/distfiles to ~ftp/dist. Then do a link between /usr/ports/distfiles and ~ftp/dist.  To summarize:

# mkdir ~ftp/dist
# mv -f /usr/ports/distfiles/* ~ftp/dist
# rm -rf /usr/ports/distfiles/*
# ln -f ~ftp/dist /usr/ports/distfiles

Now all you have to do is add this line:


to your /etc/make.conf on each machine.  Since I only have two machines, this system works exceptionally well. You may need to do something like this:

MASTER_SITE_OVERRIDE="ftp://localnethostname1/dist/ \
    ftp://localnethostname2/dist/ \ ftp://localnethostname3/dist/" 

or something similar.  Note that this is just an example, I don’t even know if it works or not.

Well, that should do it. Good luck!