approx: Package caching for Ubuntu (and Debian) lovers

If you have quite a few Debian or Ubuntu machines and you want an easy way to share and speed up package downloads — or reduce your bandwidth consumption — then approx is for you! It’s incredibly easy to set up, but there are a few tricks I’ve learned which can make it especially good for Ubuntu lovers.

I suppose the obvious starting point would be…

apt-get install approx

… and that’s almost all there is to it, but let’s fancy it up a bit.

In /etc/approx/approx.conf:

# use my ISP's ubuntu mirror for most packages
# use central mirrors for security, partner and ports
ubuntu     http://mirror.internode.on.net/pub/ubuntu/ubuntu
secure     http://security.ubuntu.com/ubuntu
partner    http://archive.canonical.com/ubuntu
ports      http://ports.ubuntu.com/ubuntu-ports
medibuntu  http://packages.medibuntu.org

# you can cache PPA packages too, see the sources.list example below
ppa        http://ppa.launchpad.net

# ISP's debian mirror, particularly handy for getting sources
debian     http://mirror.internode.on.net/pub/debian

Demonstrative examples from /etc/apt/sources.list:

# get most packages from my ISP
deb http://approx:9999/ubuntu jaunty main restricted universe

# get security packages from my ISP *or* central
deb http://approx:9999/ubuntu jaunty-security main restricted universe
deb http://approx:9999/secure jaunty-security main restricted universe

# partner and medibuntu packages for naughty stuff we need
deb http://approx:9999/partner jaunty partner
deb http://approx:9999/medibuntu jaunty free non-free

# use generic PPA repository to support arbitrary PPAs!
deb http://approx:9999/ppa/jdub/ppa/ubuntu jaunty main
deb http://approx:9999/ppa/gwibber-team/ubuntu intrepid main

Now you can configure all of your Ubuntu (or Debian) machines to grab their package lists and packages from your approx cache. No more wasted bandwidth when you’re updating, and no more wasted time when you’re stuck watching an update — this is particularly awesome for autmated installs, of course! :-)

Other handy tidbits:

  • You can use the cache to share source packages too — just change ‘deb’ to ‘deb-src’ at the beginning of the line, as usual.
  • approx comes with daily and weekly cronjobs to keep your cache tidy.
  • If you have a bunch of packages lying around in /var/cache/apt/archives which could be put to good use in your approx cache, just use approx-import. Very sweet.

Gosh I’m happy that someone has finally nailed this… I’m pretty sure I’ve tried every attempt to implement a dynamic apt proxy/cache that ever was. Interestingly, approx is yet another OCaml success story. Cool. :-)

Enjoy!

  • email
  • Print
  • Twitter
  • Identi.ca
  • del.icio.us
  • Facebook
  • Digg

10 Comments

  1. Posted April 13, 2009 at 06:02 | Permalink | Reply

    But there is one very big problem with approx (and apt-cache): It does not allow parallel requests so when two clients try to update at the same time, one has to wait.

    I’m using apt-cacher-ng instead which does pretty much the same and is easier to use: Just install it on one host and configure this as your apt proxy. You neither need to write any configuration files for it nor change the sources.list file.

  2. Olivier
    Posted April 13, 2009 at 06:20 | Permalink | Reply

    What are the avantages of approx over apt-proxy? is it worth migrating?

  3. Jerome Haltom
    Posted April 13, 2009 at 08:12 | Permalink | Reply

    Odd. I always just used Squid.

  4. Jones Lee
    Posted April 13, 2009 at 09:03 | Permalink | Reply

    Indeed it is not possible to process multi-requests with approx. Thus to upgrade or deploy softwares on a massive scale of network is not possible. Then again, apt-cacher-ng comes in to save the day.

  5. Posted April 13, 2009 at 11:07 | Permalink | Reply

    @Olivier: I’ve found approx to be extraordinarily reliable, certainly moreso than apt-proxy. It does have a special place in my heart, though, being the very first Twisted app I ever used. ;-)

    I might have to give apt-cacher-ng another try, given the positive comments above. Thanks!

  6. ken
    Posted April 13, 2009 at 18:05 | Permalink | Reply

    You can do something with the file /etc/apt/apt.conf.d/01proxy to instruct apt to use the cache rather than change your sources.list. Then if you’re out on the road, you can change 01proxy back to use the real servers rather than the proxy.

  7. James
    Posted April 13, 2009 at 20:38 | Permalink | Reply

    apt-zeroconf doesn’t need fucking around with your sources.list and works OK, although it’s a bit unmaintained and needs restarting occasionally.

  8. Duncan
    Posted May 7, 2009 at 20:56 | Permalink | Reply

    Hi,
    I’ve been using approx for a while now to feed a few debian and ubuntu installs with no problems except….

    Doing an dist upgrade on ubuntu, if you use the “suggested” tools, third party sources are automatically disabled and the upgrade uses the ubuntu repos. Is there a way to force ubuntu to use the local repo for dist upgrade?

    Or alternatively, is it safe to do a command line dist-upgrade on ubuntu (i.e. not use the upgrade tool) and just manually update the sources list as I would on debian?

  9. James
    Posted May 8, 2009 at 00:01 | Permalink | Reply

    Duncan: update-manager does some extra things beyond a plain dist-upgrade - the source is python if you want to read what it does and attempt it by hand.

  10. Gerhard Mack
    Posted August 11, 2009 at 19:50 | Permalink | Reply

    apt-proxy is buggy and unmaintained so pretty much anything else wins out.

Post a Comment

Your email is never shared. Required fields are marked *

*
*

Comments will be sent to the moderation queue.