Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

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):

  DIST=unstable

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 https://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 91.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]

 
 
  Published under the terms fo the GNU General Public License Design by Interspire