Hi David,

thanks for the bug report!

* David Kalnischkies <[email protected]> [2026-09-10 20:05]:
my `.sbuildrc` includes (very simplified):

```
$apt_keep_downloaded_packages = 1;
my $donkult_chroot_exec = '%SBUILD_CHROOT_EXEC tar --directory 
/var/cache/apt/archives --create --file - . | tar --directory 
/tmp/cache/archives --extract --file -';
$external_commands = {
        "post-build-commands" => [
                $donkult_chroot_exec,
        ],
        "post-failed-build-commands" => [
                $donkult_chroot_exec,
        ],
};
```

The idea behind this is that I want to extract the *.deb files
sbuild has downloaded from the chroot to integrate them into my
file:///-mirror (my chroots are configured to use APTs mirror method
with file:/// location(s) first and an online source as fallback, so
if the deb is found locally it will just be reused from where ever it
is rather than be downloaded, but if it isn't there it transparently
falls back to the online source -- poor men apt cacher proxy if you
will).

This is broken with the introduction of calling `apt distclean` by
default as that (also) clears the archives/ directory, which I suppose
was not intended, but as its usually empty anyhow it went unnoticed.

Beside breaking my, I suppose, "crazy" setup, it is practically breaking
`$apt_keep_downloaded_packages` as I don't see how you could use that
option successfully now and also the usecase this options doc alludes
to: mounting /var/cache/apt/archives into the chroot directly
(that said, not sure how that would work in a unshare setup through).

It would therefore be nice if `archives/` could be excluded from the
cleanup by default (it will be clean by default anyhow) by e.g. calling
`apt distclean -o Dir::Cache::archives=/nonexistent` instead. I have
tested that this solves my use case, but not if it breaks anything else
(even if I find that unlikely), so this is not a patch.

I added the `apt distclean` because packages used the extra apt information during the build, making them not reproducible with debrebuild. Given that this is the default on the Debian buildds I would like to keep it the default for sbuild as well to make sure users have the same experience. For me this includes cleaning up `archives/`, even though it sounds unlikely that package builds would use it but it reduces any non reproducible diff in the chroot.

You could simply add

$clean_apt_cache = 0;

to your sbuild.conf to disable the feature.

We could consider disabling it automatically in case apt_keep_downloaded_packages is enabled but it sounds a bit like too much magic.

What do you think?

Cheers Jochen

Attachment: signature.asc
Description: PGP signature

Reply via email to