What I'm not talking about
This is not the way to set up a real Debian mirror. That is covered here. I repeat, the theory covered herein will not get you a real Debian mirror.
So what exactly are we setting up?
We're going to actually use the Debian cache that you already have. Basically, if you run Debian on multiple machines on your in-house network and you only want to pull any given upgrade from the outside world once (as opposed to once for each machine), this site may help you.
The idea here stemmed from a time a couple years ago when I lived in an apartment with a friend of mine. Our only connection to the outside world was the amazingly slow dialup pool offered by SIUC. However, we were smart (stupid?) enough to set up a gateway machine that lived in the closet so we could share the connection. (Yes, we actually set up a 4 machine, bridged wired/wireless network all trickling down to a single 28.8 connection.)
The easy way
The easiest way to accomplish something along these lines is to keep the package database on your gateway machine up to date and then feed the rest of your network off of it.
I'm going to assume that you already know how to keep your package database up to date otherwise you wouldn't even be attempting to use your cache. To make your cache usable by the other machines on your network:
- Create your Packages.gz
To do this, the following command scans your packages, dumps the warnings (it warns on multiple versions of the same packages, but uses only the newest), and zips up the output for shipment. For best results, you'll want to add this to you crontab at some regular interval that makes sense to you.dpkg-scanpackages /var/cache/apt/archives/ /dev/null 2> /dev/null \ | gzip > /var/cache/apt/archives/Packages.gz
- Provide some means of connection in
Personally, I'm a fan of SSH. The man page for ssh-keygen explains how to do passwordless logins, but basically, it boils down to:user@host:~$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/user/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/user/.ssh/id_rsa. Your public key has been saved in /home/user/.ssh/id_rsa.pub. The key fingerprint is: bc:b3:46:45:7a:e5:ff:8f:16:dc:42:55:3e:0a:32:4d user@host user@host:~$ scp .ssh/id_rsa.pub remotehost: Password: foo.pub 100% 218 0.2KB/s 00:00 user@host:~$ ssh remotehost Password: user@remotehost:~$ cat id_rsa.pub >> ~/.ssh/authorized_keys2 user@remotehost:~$ rm id_rsa.pub user@remotehost:~$ exit user@host:~$
From now on, you should be able to ssh into the remote host without having to provide a password. Of course, this is inherently insecure, so if you don't like it, find a better way.
Setting up the client side
All you have to do on the client side is add your gateway cache to your /etc/apt/sources.list. Mine looks like the following: (tranq.wolfteck.com is the gateway whose cache I use)deb ssh://tranq.wolfteck.com: /var/cache/apt/archives/ deb http://security.debian.org/ sarge/updates main contrib non-free deb http://ftp.us.debian.org/debian/ sarge main contrib non-free # deb ftp://ftp.nerim.net/debian-marillat/ testing main
That's it. In general it should pull from the gateway cache. In the event that the gateway is out of date or doesn't have a package, the normal debian mirrors will be used instead.Some other ways of doing things
If you're looking for a more robust solution, consider running an apt proxy. This type of setup will cache packages that come through it as they are downloaded in the normal way by anything on the network. This is beyond the scope of the quick and easy solutions that I like to stick to here, but this is an excellent resource.
Last updated: Sunday, 20-Sep-2009 16:55:49 CDT
Contact me at randall dot will at gmail dot com
Hobbies
Vintage MotorcyclesNetworking
FacebookPresence
UbuntuDiscount ASP.NET
CPAN
p2p Wrox
Roundcube
Freshmeat
Blogger
uShip
Psychology Software Tools
Virtual Corvair Club
Chopper Charles
Live Journal
Thoughts
Borrowed PhilosophyHistorical Histrionics
Current Histrionics
Old Projects
Motorola V400 / LinuxHP ZE4200 / Linux
VPR Matrix 220a5 / Linux
FreeRadius Accounting / Linux
LDAP / FreeRadius Auth / Linux
Remote MySQL / OSX
Stewie Radio Automation
Wireless Wandering Done Right
DynDNS: TinyDNS / OpenSSH
Xilinx WebPACK 6.3 / Wine
Xilinx WebPACK 7.1 / Debian
Apache 301 Redirection
Using Your Debian Cache
Google AdSense
Gnome AdSense Monitor
Pixlatch Gallery Generator
C#.NET Tips & Tricks
Ubuntu Breezy Clockmod Bug
