Hi,

On Sat, Jul 12, 2025 at 09:08:28AM +0200, Lucas Nussbaum wrote:
> While refreshing my sbuild setup, I failed to find documentation on how
> to use an APT proxy together with unshare+mmdebstrap.
> 
> Ideally there would be doc about:
> - specifying an APT proxy by URL
> - using auto-apt-proxy to auto-detect the proxy
> 
> And it should be documented how to do that using command-line options,
> and in .config/sbuild/config.pl
> 
> Regarding config.pl, maybe it can be solved by improving the example
> config.pl
> 
> It looks like the following does what I need:
> $piuparts_opts = ['--bootstrapcmd=mmdebstrap --skip=check/empty 
> --variant=minbase --include=auto-apt-proxy', '--no-eatmydata', 
> '--distribution=%r', '--fake-essential-packages=systemd-sysv'];
> $unshare_mmdebstrap_extra_args = [
>   "*" => ['--include=auto-apt-proxy']
> ];

Let me share my approach here. There are different trade-offs involved.
I am externally managing my build environments and do not include the
auto-apt-proxy package in the build environment in the interest of
producing minimal environments. Therefore, I need to run auto-apt-proxy
outside the chroot. The following sbuild config.pl snippet can do:

| my $apt_proxy;
| if (defined $ENV{'http_proxy'}) {
|       $apt_proxy = $ENV{'http_proxy'};
| } else {
|       $apt_proxy = `auto-apt-proxy`;
|       chomp $apt_proxy;
| }
| if ($apt_proxy) {
|       push @{%$external_commands{'chroot-setup-commands'}}, "printf 
'Acquire::http { Proxy \"%%s\"; }\\n' '$apt_proxy' 
>/etc/apt/apt.conf.d/99proxy";
| }

I wouldn't quite recommend this as a general solution to include it into
documentation. Clearly, we don't want end users to have to put code like
this into their sbuild configuration. Still, it can serve as an
inspiration for a better solution to be integrated into sbuild.

Also keep in mind that Jochen is working on apt-less build environments
every now and then and has made quite some advancements at least in
making packages not use the apt cache. Clearly, including auto-apt-proxy
in build environments is not going to work in such environments.

Helmut

Reply via email to