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!

This entry was posted in General and tagged , , , , , , , , , . Bookmark the permalink.

12 Responses to approx: Package caching for Ubuntu (and Debian) lovers

  1. Julian says:

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

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

  3. Jerome Haltom says:

    Odd. I always just used Squid.

  4. Jones Lee says:

    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. Jeff Waugh says:

    @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 says:

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

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

    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?

    • bjoern says:

      I remember that I did successfully a dist uograde via approx some time ago, but now I have the same problem: the Ubuntu update manager disables all proxy entries in my sources.list. This is a pain in the … until now now answer found out there, any suggestion from here would be appreciated very much. Thanks in advance, Bjoern

      • Max Bowsher says:

        You can configure Ubuntu update-manager to not disable APT sources which do not appear to be official.

        To do this, you create a file at:

        /etc/update-manager/release-upgrades.d/allow-third-party.cfg

        with the contents:

        [Sources]
        AllowThirdParty=1

  9. James says:

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

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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Comments will be sent to the moderation queue.