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

# you can cache PPA packages too, see the sources.list example below

# ISP's debian mirror, particularly handy for getting sources

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. 🙂


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

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

    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:


        with the contents:


  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.

  11. Vivian Wang says:

    It’s wierd that the approx doesn’t work on Debian Jessie. If anyone has suggestions?

    here is config files:
    /etc/approx/approx.conf on approx server

    /etc/apt/sources.list on client machine
    deb http://approx:80/debian jessie main contrib non-free
    deb http://approx:80/debian jessie-updates main

    When newly installed, it’s empty under /var/cached/approx, then approx never go out to remote source. it works only put archived packages under the cached folder.
    see logs as below.
    root@debian:~# apt-get update
    Ign file: packages/ InReleaseIgn http://approx:80 jessie Release.gpg
    Err http://approx:80 jessie/non-free amd64 Packages
    404 Not Found
    Err http://approx:80 jessie-updates/main amd64 Packages
    404 Not Found
    W: Failed to fetch http://approx:80/debian/dists/jessie/main/binary-amd64/Packages 404 Not Found

    W: Failed to fetch http://approx:80/debian/dists/jessie/contrib/binary-amd64/Packages 404 Not Found

    E: Some index files failed to download. They have been ignored, or old ones used instead.

    And there is no cron job on the approx server.

    Even worse, approx-import said no packages found the approx cache. It should copy local packages under /var/cache/apt/archives to /var/cache/approx, shouldn’t it?

    # approx-import /var/cache/apt/archives/*.deb
    There are no Packages files in the approx cache.
    Please run “apt-get update” first.

    # pwd
    # ls
    approx_5.5-1_amd64.deb libreoffice-calc_1%3a4.3.3-2+deb8u5_amd64.deb
    augeas-lenses_1.2.0-0.2+deb8u1_all.deb libreoffice-core_1%3a4.3.3-2+deb8u5_amd64.deb
    autoconf_2.69-8_all.deb libreoffice-draw_1%3a4.3.3-2+deb8u5_amd64.deb

Leave a Reply

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

Comments will be sent to the moderation queue.