Adventures As Me


The Virtues of Apt-Move

Written 30 Mar 2004

If you want to create a partial Debian mirror, apt-move is a tool you want to learn. The tool's premise is quite simple: move a collection of Debian package files into a proper archive hierarchy as is used in the official Debian archive. In accomplishing that it does in a very easy way. The following are the bare steps needed to put apt-move to work for you.

First, if you do not have it installed, apt-get -uf install apt-move. A configuration file is placed in /etc, as is proper. Before editing the file, decide where you want the hierarchy created. According to the FHS, the likely candidates are /var/cache or /var/lib. Within one of those directories, create a new directory tree mirrors/debian:

# mkdir -p /var/cache/mirrors/debian

Second, we need to edit /etc/apt-move.conf. The default setup will generate a mirror based on all the apt sources listed in /etc/apt/sources.list. You only need to change LOCALDIR=/mirrors/debian to LOCALDIR=/var/cache/mirrors/debian. Of course, be certain LOCALDIR points to the actual directory created earlier. Save the file and exit your editor.

Third, your local mirror needs primed. Do this by executing:

# apt-move get

According to apt-move(8) This generates the master files using Packages and Sources files from the apt(8) cache. The master files are used to keep track of what packages are available, and where packages should be installed.. For some reason the first time apt-move is used, it must be called with only the get argument, in order to prime your local mirror. Once it runs, execute:

# apt-move update

This combines the arguments get, move, delete and packages. Upon compeletion, your mirror is ready and populated with all the most recent debs on your system. But then what? Well, obviously you want to make this mirror available for other machines to use. The easiest, but perhaps not the most secure, method is to add a simple alias to your Apache configuration file. That is if you are running Apache on this system. You could also share via ftp, NFS or Samba.

Here is what I do for Apache. Edit /etc/apache/httpd.conf and add the following line at the bottom:

Alias /debs /var/cache/mirrors/debian

Save the file, exit your editor and execute:

# /etc/init.d/apache restart

On a machine on the same network as this new mirror you created, add the following to /etc/apt/sources.list: deb http://hostname/debs unstable main contrib. You will need to change the release and sections to match what exists in your local mirror. If you are uncertain, perform a directory listing of /var/cache/mirrors/debian/dists to find the releases available. Pick a release, and list its directory contents to find what sections are available.

Once you have the client machine setup properly, do the following:

# apt-get update

You should see your local mirror make its appears in the sites apt queries. And that is that! Simple.

Related Posts