#1109132 sbuild: document how to use an apt proxy

#1109132#5
Date:
2025-07-12 07:08:28 UTC
From:
To:
Hi,

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']
];

Best,

Lucas

#1109132#10
Date:
2025-07-12 10:12:13 UTC
From:
To:
Hi Lucas,

I think there is agreement that these common usecases should be
documented in the manual pages, but it has not happened yet.

For "APT proxy by URL", the config.pl fragment that currently gets advertised
is:

  push @{$unshare_mmdebstrap_extra_args}, "*",
    ['--aptopt=Acquire::http { Proxy "http://127.0.0.1:3142"; }'];


Hope this helps,
Chris

#1109132#13
Date:
2025-07-12 10:20:40 UTC
From:
To:
Quoting Chris Hofstaedtler (2025-07-12 12:12:13)

That is correct. I'm working on it. Sorry for the delay. I'm not at DebConf
because these weeks it's exam season so I'm very busy... :(

Thanks!

cheers, josch

#1109132#18
Date:
2026-09-14 07:59:32 UTC
From:
To:
Hi,

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