Understanding apt-cacher

As I mentioned previously, my open source technologies class has a laboratory component, running two to three hours every Monday. The class has 36 students, all of whom already have Ubuntu 8.10 running on their workstations.

Now this presents its special problem: how to keep all of them up-to-date. Updates are never easy, especially with new kernel images. And with Ateneo's fluctuating bandwidth (too many lab assistants watching Youtube), it's a problem that's much compounded.

After some research, I found my solution: apt-cacher.

There are several tutorials around apt-cacher (here and here, for example), but I initially had some trouble following them. I think it might have been caused by the naming conventions around the path_name in the configuration file.

A more reflective reread of the aforementioned documents will help, but for brevity's sake, this is what I did:

On the server:
1. Installed apt-cacher on the designated server (it312server, in this case; I updated the /etc/hosts file of the clients to reflect that.)

2. Changed the AUTOSTART=0 line of /etc/default/apt-cacher to AUTOSTART=1.

3. Restarted apt-cacher with /etc/init.d/apt-cacher restart.

On the clients:
1. Updated the /etc/hosts file of the clients to reflect it312server's IP address.

2. Changed every instance of http://ph.archive.ubuntu.com (my nearest repository) to http://it312server:3142/ph.archive.ubuntu.com

And that's it.

A more fundamental problem was in my understanding of the way apt-cacher worked. I thought that apt-cacher would take the existing repositories from the designated server and make that available to the clients. Apparently that's not the case. Instead, apt-cacher will only cache the packages requested by the clients.

There's supposed to be a command, sudo /usr/share/apt-cacher/apt-cacher-import.pl /var/cache/apt/archives, which will copy the existing APT cache of the server to apt-cacher's own cache (which is actually separate, apparently), but I ran into symlink problems with that.

So anyway, lesson learned: initiate one update and upgrade cycle first from one machine. Then the rest follow.