Howto replace APT-Proxy with APT-cacher-ng

Goal change to APT cacher-ng from APT-Proxy without changes on the client side.
Tested with apt-cacher-ng 0.4

Installation and configuration

  1. Install
    apt-get install apt-cacher-ng
    
  2. Do the following changes to /etc/apt-cacher-ng/acng.conf
    @@ -9,7 +9,7 @@
     
     # TCP (http) port
     # Set to 9999 to emulate apt-proxy
    -Port:3142
    +Port:9999
     
     # Addresses to bind/listen on. Multiple addresses must be separated by spaces.
     # DNS resolution is performed. If multiple protocols are available for a
    @@ -27,6 +27,11 @@
     Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian
     Remap-uburep: file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu
     Remap-debvol: file:debvol_mirror*.gz /debian-volatile ; file:backends_debvol
    +Remap-debsec: file:deb_sec_mirrors /debian-security ; file:backends_debian_sec
    +Remap-ubusec: file:ubuntu_sec_mirrors /ubuntu-security ; file:backends_ubuntu_sec
    +# Ubuntu nx ppa
    +Remap-ubunx: file:ubuntu_nx_mirrors /ubuntu-nx ; file:backends_ubuntu_nx
    +
     
     # Virtual page accessible in a web browser to see statistics and status
     # information, i.e. under http://localhost:3142/acng-report.html
    @@ -57,7 +62,7 @@
     # offlinemode:0
     
     # Forbid all downloads that don't run through preconfigured backends (.where)
    -#ForceManaged: 0
    +ForceManaged: 1
     
     # Days before considering an unreferenced file expired (to be deleted).
     # Warning: if the value is set too low and particular index files are not
    
  3. Create backend config files (replace with you local mirrors) in /etc/apt-cacher-ng

backends_debian

http://ftp.se.debian.org/debian

backends_debian_sec

http://security.debian.org/

backends_debvol

http://volatile.debian.org/debian-volatile

backends_ubuntu

http://se.archive.ubuntu.com/ubuntu/

backends_ubuntu_nx

http://ppa.launchpad.net/freenx-team/ppa/ubuntu

backends_ubuntu_sec

http://security.ubuntu.com/ubuntu
  1. Create (extra) needed mirror files in /etc/apt-cacher-ng
    cp backends_debian_sec deb_sec_mirrors 
    cp backends_ubuntu_sec ubuntu_sec_mirrors
    cp backends_ubuntu_nx ubuntu_nx_mirrors
    
  2. Configure a AdminAuth in /etc/apt-cacher-ng/security.conf
  1. Done, now you can (re-)start apt-cacher-ng

Data migration (optional)

When you are sure that you different clients can update via apt-cacher-ng instead of apt-proxy you are also set for data migration.

Note: You will at least have to test updates from all different versions of dists that you are running (e.g. etch + lenny & dapper + hardy) otherwise you will not have index files available for a successful migration.

  1. Create (hard)links for debs and tar.gz from apt-proxy to a temporary import directory (you can not use apt-proxy after this step, due to the permissions change)
    mkdir /var/cache/apt-cacher-ng/_import
    find /var/cache/apt-proxy/ -name "*.deb" -o -name "*.tar.gz" | xargs -I '{}' ln '{}' /var/cache/apt-cacher-ng/_import
    chown -R apt-cacher-ng:apt-cacher-ng /var/cache/apt-cacher-ng/_import
    
  2. Point your web browser to your apt-proxy e.g.  http://aptproxy:9999 and select the report page
  3. Click "Start import"
  4. De-install and purge apt-proxy
    apt-get remove apt-proxy --purge
    
  5. Remove the apt-proxy cache (rm -r /var/cache/apt-proxy/) and /var/cache/apt-cacher-ng/_import