Use apt-cacher for stripped down Debian and Ubuntu repositories
I recently needed to upgrade a client's servers from Debian Sarge to Lenny. The client is not in the US, and has a low bandwidth (yet still high cost!) connection for their servers. So running the netinst upgrade isn't a viable option since it will take so long and eat up so much of their quota. On the other hand, Lenny is now up to 3 DVDs. Even if most of what is needed is on the first disc, the hassle of configuring the CD repos is a big pain, considering that these are servers with a very tightly controlled set of packages already installed. So I didn't want to download the full DVD when I only needed a small set of packages.
I thought about what kind of tool would be needed: I need to download just the new set of packages so I can make them available to each server. A custom CD would be a lot of work. Tools like apt-mirror will pull down entire repositories, which is copmlete overkill considering the set of packages I need. I saw things like apt-proxy that were kinda close but not quite, and feared I might have a lot more work ahead of me than originally budgeted.
Then after a little more searching, I came across this great little Perl tool: apt-cacher. It does exactly what I needed it to: You configure your existing /etc/apt/sources.list to route the repo URLs through the proxy script. The script will handle downloading the package (and headers and everything else) if it doesn't already have it in its local repo. It looks just like any other repo as far as apt-get is concerned. And it only downloads just the packages that are actually installed. When I first tried apt-mirror, it estimated 65GB just for the etch-i386 repo. Using apt-cacher, I have both etch and lenny repos for all the packages I need to upgrade the client's servers, and it only takes 2.2GB! Much more efficient!
For the way I plan to do the production upgrades, I need the repos on my laptop (download quickly here in the states, then run locally onsite). Unfortunately the apt-cacher code has been completely pulled into the Debian repository, so I had to do a little more work to get the latest version setup on my Mac. I installed the .deb on a Debian machine, then packaged the files up and copied to my laptop. There are lots of hardcoded references in the scripts due to it having been Debian-ized, so for expediency I just created symlinks for those references back into the folder I created.
If there's any interest, I can make the references relative and bundle up my scripts. But it wasn't hard to un-Debian-ize the package. I'm just happy that I found a solution that solved my need in the perfect manner!













