Go to TogaWare.com Home Page.
GNU/Linux Desktop Survival Guide
by Graham Williams

Maintaining a Distribution Archive

Downloaded Debian packages are placed into /var/cache/apt/archive. You can have the files moved into a local hierarchy that mirrors a standard Debian distribution hierarchy. Then you can point the /etc/apt/sources.list to this local archive by using the file:// format.

To set up a local machine as a local (partial) mirror of the Debian archive, wajig will use the apt-move package.

Edit /etc/apt-move.conf to set the DIST to match your system (default is stable):


The wajig command move will then move any packages in your /var/cache/apt/archives into the Debian mirror being created (/mirrors/debian is created by default):

  $ wajig move

You can actually create a complete mirror with:

  # apt-move mirror

These commands place the packages into /mirrors/debian. To make it available on your web server simply:

  # cd /var/www
  # ln -s /mirrors pub

The file /etc/apt/sources.list can then be updated to point to the new archive as the first place to check for packages (place this lines first in the file):

  deb http://athens/pub/debian unstable main contrib non-free

All of this might happen on your server (called athens in this example) and other machines on your local network can then access the local archive by adding the above line to /etc/apt/sources.list.

If your server is not the most up to date machine (since you may not want to run the risk of your server becoming unstable), you can rsync all packages in /var/cache/apt/archives on other machines to the server and then run the move command on the server:

  # rsync -vr friend:/var/cache/apt/archives/ /var/cache/apt/archives/
  # ssh friend wajig clean         (apt-get clean)
  # wajig move                     (apt-move update)

In fact, on your server you could use the following Python script saved to file /root/apt-archive.py to automate this for each of the hosts on the network:

#!/usr/bin/env python
import os

hosts = ['friend', 'cargo']
archive = '/var/cache/apt/archives/'

for h in hosts:
    os.system('rsync -vr %s:%s %s' % (h, archive, archive))
    os.system('ssh %s wajig clean' % h)

os.system('wajig move')

Then set the script up to run:

  # chmod u+x apt-archive.py

and run it as required:

  # ./apt-archive.py

Depending on how you have ssh set up this may ask for your password for each connection. To avoid this, you can use public/private keys with no passphrase (see Section 92.5), and then the script could be run automatically using cron each morning by copying the executable script to /etc/cron.daily/apt-archive7.1.

Copyright © 1995-2006 [email protected]
Contribue and access the PDF Version