Hi,
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.
Ironically, looking around to check if anyone else reported this already
I found the recent MR https://salsa.debian.org/debian/sbuild/-/merge_requests/253
which sounds like it could actually be the perfect place for my
extraction, but I am fine with what exists now.
Best regards
David Kalnischkies
Hi David, thanks for the bug report! * David Kalnischkies <david@kalnischkies.de> [2026-09-10 20:05]: 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
Am Tue, Sep 15, 2026 at 06:17:33AM +0200, schrieb Jochen Sprickerhof: As I tried to explain already, in a default configuration archives/ will be empty with or without `distclean` being called as apt will have removed the *.deb files after it installed them, so I fail to see which diff is reduced here. Can you provide an example? This removal can be disabled with $apt_keep_downloaded_packages, a clear indication that they shouldn't be removed, but by calling distclean afterwards the archives/ directory is cleared completely anyhow making the option alone useless. Worse, if you have a setup like the config option suggested with mounting archives/ from your host, this directory is now completely cleared ~ which seems like the complete opposite of what a user who had this setup until now wanted (But as said, I am not sure how this mounting would work in unshare given the wrong permissions, but in the other "older" modes that is surely a thing). I could of course, but that exposes me again to the lists/ problem you wanted to fix with the distclean call. For the same reason I don't want it automatically disabled. My opinion remains that the archives/ clearing part should be disabled by default as it does nothing in the default config and setups, but breaks documented setups (= mounting archives/ from host) and has (currently undocumented) implications for an existing config option. It also ensures that at least lists/ is cleared for both of us. I will have to live with archives/ containing *.deb files (maybe as explained last mail) in my setup, but "it sounds [indeed] unlikely that package builds would use it", so I hope I can manage that risk. Best regards David Kalnischkies