Home

Debian/Ubuntu Tips & Tricks

Debuntu.org: .deb packages, Unix/Linux Tutorials and Articles.

User login

Get Firefox


Tips


How To Set up a repository cache with apt-cacher -- page 2

3. Setting up the Clients and Server sources.list

Now it is time to set up the client hosts apt source list files: /etc/apt/sources.list. It make sense to use the repository cache on the server too, as that way, any updates made by the server will fill up the cache.

Here is the original /etc/apt/sources.list:

#debuntu repository
deb http://repository.debuntu.org edgy multiverse
deb-src http://repository.debuntu.org edgy multiverse

#ubuntu main repository
deb http://archive.ubuntu.com/ubuntu/ edgy main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ edgy main restricted universe multiverse

#ubuntu updates repository
deb http://archive.ubuntu.com/ubuntu/ edgy-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ edgy-updates main restricted universe multiverse

#ubuntu security updates repository
deb http://security.ubuntu.com/ubuntu edgy-security main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu edgy-security main restricted universe multiverse

In order to use our cache repository, those entries need to be changed to:

#debuntu repository
deb http://repository-cache:3142/debuntu edgy multiverse
deb-src http://repository-cache:3142/debuntu edgy multiverse

#ubuntu main repository
deb http://repository-cache:3142/ubuntu edgy main restricted universe multiverse
deb-src http://repository-cache:3142/ubuntu edgy main restricted universe multiverse

#ubuntu updates repository
deb http://repository-cache:3142/ubuntu-updates edgy-updates main restricted universe multiverse
deb-src http://repository-cache:3142/ubuntu-updates edgy-updates main restricted universe multiverse

#ubuntu security updates repository
deb http://repository-cache:3142/ubuntu-security edgy-security main restricted universe multiverse
deb-src http://repository-cache:3142/ubuntu-security edgy-security main restricted universe multiverse

Cool, now, every host should be able to retrieve the .deb packages from our repository cache once:

$sudo apt-get update

has been ran on every host.

4. Importing existing package from /var/cache/apt/archives/ to apt-cacher repository

It might happen that your server already got a whole lot of packages cached in its local repository: /var/cache/apt/archives/. apt-cacher offers a tool to import those files to apt-cacher repository.

There is a whole lot of usefull script that can be found in /usr/share/apt-cacher/. The one we are interested in here is apt-cacher-import.pl. To import deb files from /var/cache/apt/archives to apt-cacher repository run:

$sudo /usr/share/apt-cacher/apt-cacher-import.pl /var/cache/apt/archives

This must be run as user root or .deb files might not be copied to the cache repository

Now, the directory /var/cache/apt-cacher/packages/ should be filled up with a whole bunch of packages.

5. Getting report usage of your repository cache

If you left the directive generate_reports set to 1, apt-cacher will generate report on the usage of the cache every day.

You will be able to access it at the address: http://repository-cache:3142/report

.

If you need to regenerate the report, run: $sudo /usr/share/apt-cacher/apt-cacher-report.pl

6. Conclusion

apt-cacher is an easy and efficient package which will save you both time and bandwidth when using multiple machines with the same distribution like it could happen in a home network or in at a company.


Thanks!

Thanks a lot. Worked like a charm!


It would be more complete if

It would be more complete if the writer addressed the use of ftp sites ... Debian mirrors are almost exclusively on ftp sites. Does apt-cacher work with ftp mirrors ?


don't seem to be supported

At the bottom of apt-cacher.conf, we can find:

FTP access method not supported yet, maybe in the future.

so I believe it is not supported :).
Concerning debian mirrors being ftp mirrors, that is not right, even though the url are usually like:
ftp.country.debian.org, you can access the mirror both using ftp://mirror.url or http://mirror.url
Debuntu


Use apt proxy setting instead of editing sources.list

Use synaptic dialog, or edit apt.conf and add

Acquire::http::Proxy "http://repository-cache:3142";

Then you don't need to edit sources.list. If the repository-cache machine is inaccessible, its easy to turn off the proxy.


Apt Proxy didn't work for me

would be really convenient if it worked, but when i tried it, i either got 500's in response from the server, or the repository requests just skipped over my apt-cacher box, and went straight to the normal external repositories.


Can multiple proxys be specified??

Can multiple proxys be specified?

If the first one fails then it would go to the next proxy in the list.

This would be useful for a laptop that would use the home proxy when on the home network and automatically fail back to another proxy or no proxy (using the DIRECT keyword - see man page) when on a remote network.

For a laptop, this beats having to go into apt.conf and manually turning the proxy on/off based on the current network connection.

Thanks!


Re: Can multiple proxys be specified??

The Acquire::http::Proxy directive in apt.conf is formatted the same as the http_proxy environment variable. In fact you need to make sure that you *don't* specify a http_proxy environment variable since that will override this directive in apt.conf.

Whilst you can't specify a proxy try list, you can specify different proxies for specific remote servers. For example:
Acquire::http::Proxy "http://repository-cache:3142/";
Acquire::http::Proxy::security.ubuntu.com "DIRECT";

That would use your repository cache for everything but Ubuntu security updates. Try "man apt.conf" for more info.