How to install apt-proxy
Introduction
apt-proxy is a proxy for apt that creates a complete copy of the remote repository on your hard disk. As apt-proxy behaves as if it was a HTTP-Server with a repository, you can access the packages from every other computer in your intranet. If a package is not in the cache, apt-proxy automatically downloads it and puts it to the cache. This may significantly decrease download bandwith and installation time if you have to install packages over and over again (i.e. an upgrade or dist-upgrade of all your machines).
The current unstable version of apt-proxy is available from the hoary universe repository (See: [WWW] How To - Access the "universe" repository) and you can simply install it via
apt-get install apt-proxy/hoary
Configuration
To use apt-proxy, you have to change apt's sources.list and the configuration of apt-proxy.
apt-proxy-v2.conf
The first section in /etc/apt-proxy/apt-proxy-v2.conf contains the default settings for the proxy and its cache.
Most probably you want to change the address parameter to something appropriate for you, namely the IP of your proxy server in the internal network. The port parameter specifies the port apt-proxy listens on for requests and defaults to 9999 wich is a good value to stay at if you don't have any conflicts.
Maybe you want to change the cache directory of the repository to some other place than /var/cache/apt-proxy. This can be done by changing the cache_dir parameter.
If you are using a general proxy, you can make apt-proxy aware of it with http_proxy = proxy_server:port. If you are behind a firewall you may experience problems with active FTP connections when trying to connect to a FTP backend. passive_ftp = on should solve this problem.
The other values control the time a package remains in the cache, how old a package must be at least before apt-proxy checks for newer versions or how often the cache is checked for old packages. They can safely be left on their default values.
apt-proxy has to know where to find the remote repository, named backend. This is done via backend sections in /etc/apt-proxy/apt-proxy-v2.conf. A backend entry for ubuntu may look like this:
[ubuntu]
;; Ubuntu archive
backends =
http://archive.ubuntu.com/ubuntu
http://de.archive.ubuntu.com/ubuntu
As you can see, it is possible to specify more than one server, separated by blank space. If the first server should be down, apt-proxy tries to get the data from the second server and so on.You can also override values set in the [default-section. For instance, if you know that a special server takes very long to answer a request, you can increase the timeout value:
[ubuntu-slow]
timout = 60 ;wait 1 Minute
backends = prot://some.very.slow.server.net/ubuntu-slow
A complete apt-proxy-v2.conf (i.e. mine

[DEFAULT]
;; All times are in seconds, but you can add a suffix
;; for minutes(m), hours(h) or days(d)
address = 127.0.0.1
port = 9999
cache_dir = /var/cache/apt-proxy
;; Control files (Packages/Sources/Contents) refresh rate
min_refresh_delay = 1s
complete_clientless_downloads = 1
;; Debugging settings.
debug = all:4 db:0
timeout = 30
passive_ftp = on
;;--------------------------------------------------------------
;; Cache housekeeping
cleanup_freq = 1d
max_age = 120d
max_versions = 3
;;---------------------------------------------------------------
;; Backend servers
;;
;; Place each server in its own [section]
[ubuntu]
; Ubuntu archive
backends =
http://archive.ubuntu.com/ubuntu
http://de.archive.ubuntu.com/ubuntu
[ubuntu-security]
; Ubuntu security updates
backends = http://security.ubuntu.com/ubuntu
[marillat]
backends = ftp://ftp.nerim.net/debian-marillat
[debian]
; Backend servers, in order of preference
backends =
http://ftp.us.debian.org/debian
http://ftp.de.debian.org/debian
http://ftp2.de.debian.org/debian
ftp://ftp.uk.debian.org/debian
[debian-non-US]
; Debian debian-non-US archive
backends =
http://ftp.uk.debian.org/debian-non-US
http://ftp.de.debian.org/debian-non-US
ftp://ftp.uk.debian.org/debian
[security]
; Debian security archive
backends =
http://security.debian.org/debian-security
http://ftp2.de.debian.org/debian-security
[openoffice]
; OpenOffice.org packages
backends =
http://ftp.囗囗囗囗囗囗囗.de/pub/debian-openoffice
http://ftp.sh.cvut.cz/MIRRORS/OpenOffice.deb
http://borft.student.utwente.nl/debian
[apt-proxy]
; Apt-proxy new versions
backends = http://apt-proxy.sourceforge.net/apt-proxy
sources.list
Now, apt has to know that there is something like apt-proxy to get the packages from instead of downloading them directly. It is the best if you comment all direct servers in your sources.list out to make sure that apt-get never tries to get packages directly from a server. Then add the lines for apt-proxy. They look similar to normal apt repositories except that you always have to append the backend section (the items in square brackets in apt-proxy-v2.conf) as path:
deb http://apt-proxy:port/backend dist component
If your apt-proxy listens on localhost on port 9999, as mine does, and you specified a section ubuntu, a source line might look like this:
deb http://localhost:9999/ubuntu hoary main restricted universe multiverse
deb-src http://localhost:9999/ubuntu hoary main restricted universe multiverse
^^^^^^
This is the backend section (i.e. [ubuntu])
After you changed the apt-proxy configuration file, you must restart the proxy by sudo-ing
/etc/init.d/apt-proxy restart
The complete sources.list corresponding to the apt-proxy-v2.conf above may look like this:
# apt-proxy entries for standard modules
deb http://localhost:9999/ubuntu hoary main restricted universe multiverse
deb-src http://localhost:9999/ubuntu hoary main restricted universe multiverse
# apt-proxy entries for security patches
deb http://localhost:9999/ubuntu-security hoary-security main restricted universe multiverse
deb-src http://localhost:9999/ubuntu-security hoary-security main restricted universe multiverse
# additional repositories
deb http://localhost:9999/marillat unstable main
# debian packages
deb http://localhost:9999/debian unstable main contrib non-free
deb http://localhost:9999/debian-non-US unstable/non-us main contrib non-free
deb http://localhost:9999/security sid main contrib non-free
Initializing apt-proxy
Now run a apt-get update to initialize apt-proxy's cache and get the new lists to the cache. Now you can use apt-* as if there were no apt-proxy.
Importing apt's cache
If you already downloaded packages with apt-get, they are cached in /var/cache/apt/archives. You can import these packages to the apt-proxy cache with apt-proxy-import according to the current package list. So you should first run apt-get update to get a fresh list. Then simply run
apt-proxy-import -r -i /var/cache/apt/archives
and apt-proxy will import all the packages in apt's cache to its own cache.
Links
*
[AptGetHowTo]
*
[WWW] http://apt-proxy.sourceforge.net
https://wiki.ubuntu.com/AptProxyHowTo