Debian – How to pre-fetch Debian packages on local network

debianpackage-management

Let's say I have at home 3 computers running Debian testing. They mostly have the same configuration and most of the packages installed are identical.

Every time I update/upgrade the Debian packages, they are downloaded from the Internet.

Is there a way to pre-fetch the Debian packages from the Internet and have a local, up-to-date Debian repository containing only the packages I have installed that have an available update?

So, typically, if I have vim installed and an update is released, my server will go and fetch the .deb locally and I could upgrade all my machines from the LAN. If I want to install emacs, then the local repository will not have it and it will be downloaded from the Internet.

One could call it a local apt caching system, like Squid does http caching.

Thanks!

Best Answer

It seems that you are look for apt-cacher. To install it, just type:

$ sudo apt-get install apt-cacher

You can then configure apt-get to use it as proxy by creating a file /etc/apt/apt.conf.d/01proxy with content:

Acquire::http::Proxy "http://cacher_ip:3142/";

To be honest, I am using this configuration on ubuntu, but it should be similar on debian. This way all package downloads will be requested from apt-cacher on server "cacher_ip". If it exists, it will be fetched locally. Otherwise, it will be downloaded via the cacher.