snapcraft cleanbuild
is supposed to let me build snaps in clean-room environments. Accordingly it starts from a minimal LXD image and installs necessary packages. However, it seems to use the base archive.ubuntu.com
mirror, which is excruciatingly slow. How do I cache the packages it download?
I could set up apt-cacher-ng
or another caching proxy, but there's still the problem of getting the snap/LXD combination to use it. It would be best if it had an internal cache like pbuilder does, but if not, then how do I convince it use a different mirror or a proxy for the mirror?
The basic principles as outlined in popey's suggestion work:
Get the host IP address (as seen by the container):
Use it to set the default profile proxy settings:
However, there are a couple of caveats.
snapcraft cleanbuild
downloads a lot of packages by some other mechanism than the usualapt-get
, which isn't affected by this configuration. This insanity is seen in this part of the output:There are quite a few of these, and the individual requests make them slow as hell anyway, and that's not counting that that the apt proxy settings set earlier don't affect them.
So, I set the
http_proxy
environment variable instead:And similarly for HTTPS, since some other downloads in the container used HTTPS. I usually prefer apt-cacher-ng, but it doesn't support HTTPS CONNECT, so I switched to squid.