2

I run debootstrap like this:

sudo debootstrap --verbose --arch=amd64 zesty chroot

I have already installed apt-cacher-ng.

How do I make them work together so that when I run debootstrap multiple times I use the cache instead of repeatedly downloading the same packages?

I have tried using the MIRROR option and setting the http_proxy variable but it errors when I run offline:

$ sudo http_proxy="http://localhost:3142" debootstrap --verbose --arch=amd64 zesty chroot http://localhost:3142/uburep
I: Retrieving InRelease 
I: Failed to retrieve InRelease
I: Retrieving Release 
E: Failed getting release file http://localhost:3142/uburep/dists/zesty/Release

I used http://localhost:3142/uburep because that is what I found in the cache:

$ find /var/cache/apt-cacher-ng -name Release
/var/cache/apt-cacher-ng/security.ubuntu.com/ubuntu/dists/zesty-security/Release
/var/cache/apt-cacher-ng/uburep/dists/zesty-updates/Release
/var/cache/apt-cacher-ng/uburep/dists/zesty-backports/Release
/var/cache/apt-cacher-ng/uburep/dists/zesty/Release

I tried adding Defaults env_keep += "http_proxy https_proxy ftp_proxy" to /etc/sudoers (via sudo visudo) but it didn't help either.

If I remove the MIRROR option and run debootstrap offline it then doesn't seem to use apt-cacher-ng at all (note how it is not looking for localhost any more).

E: Failed getting release file http://archive.ubuntu.com/ubuntu/dists/zesty/Release
  • What Ubuntu version is this? – George Udosen Sep 23 '17 at 22:15
  • zesty. I am creating a zesty iso distribution from within zesty. – opticyclic Sep 23 '17 at 22:30
  • You shouldn't use the apt-cacher-ng URL as a mirror. It should be used a proxy only. – muru Oct 12 '17 at 5:17
  • I updated the question to demonstrate that removing the MIRROR option doesn't help. – opticyclic Oct 12 '17 at 6:29
  • Does apt-cacher's logs indicate any attempt to access it when used only as a proxy? – muru Oct 12 '17 at 6:47
4

There is a trick to get this to work without explicit proxy settings. You can in fact use your configured apt-cacher-ng as a mirror URL like so:

http://localhost:3142/us.archive.ubuntu.com/ubuntu/

So as you can see after specifying the base URL to your apt-cacher-ng instance you can then give a server and a path as per this Wiki article. I've used this method in my own bootstrap scripts and it works like a charm.

Note: you may want to verify that your apt-cacher-ng instance is running by checking with lsof -i :3142 (requires the lsof package).

  • I mention in the question that I am using the mirror option and it doesn't work when I am offline. What are you doing differently here? – opticyclic Dec 1 '17 at 21:45
  • 0xC… is using the same option as you. – Ken Sharp Jun 22 '18 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.