[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1107108: pre approval sbuild



Hi Ivo,

* Ivo De Decker <ivodd@debian.org> [2025-06-04 17:42]:
On Sun, Jun 01, 2025 at 10:15:29PM +0200, Aurelien Jarno wrote:
> > this is a pre approval request for an sbuild upload.
> >
> > I would like to improve the build environment for forky by cleaning the
> > apt cache before running dpkg-buildpackage. This has the advantage that
> > we have a better definition of the build environment which makes it
> > easier to reproduce it with debrebuild later. josch (for sbuild) and
> > Aurelien (for wanna build) signaled already that they would be fine with
> > this.
> >
> > Note that we only want to enable this in forky but I would still like to
> > push this to trixie for one because it makes it easier to implement this
> > on the buildds and two Debian developers using stable would get the same
> > results as on the buildds.
>
> I understood that the change was limited to forky and later. With this
> change applied and migrated to trixie this technically makes the bugs
> below RC.
>
> > Santiago Vila did a rebuild of unstable and reproduce.debian.net tested
> > trixie so we are pretty sure that there are only three packages that
> > would need patching with this feature: autodep8 (#961138), dh-r
> > (#1089197) and blends (#1104515). All of them have proposed patches
> > already. Note that I don't propose to apply them for trixie.
>
> One option is to accept this change, but with the default set to 1
> (don't clean). Then we can pass the option to sbuild on the buildds for
> forky/sid/experimental once trixie is released. And developers can also
> manually use that option to reproduce the buildds behavior.
> Alternatively the behaviour can be changed only for >= forky in the
> first point release.

After discussion with Jochen on IRC, a better option would be to let
this patch enter trixie, but then explicitly disable apt cleaning on the
buildds for trixie. We just need to synchronize the migration to testing
and the changes to the buildds.

As we are now in the hard freeze, I feel not changing the default behavior in
trixie seems like the most logical way forward. It gives the smallest risk of
regressions. It still leaves the option to change the config on the buildds.

Feel free to clarify the reason why you would want to change the default in
trixie.

I agree that not changing the default is the better solution. New diff attached.

Cheers Jochen
From be3afd7dea3cfd5dc9c29d77e60c0520ff5d13df Mon Sep 17 00:00:00 2001
From: Jochen Sprickerhof <jspricke@debian.org>
Date: Sun, 1 Jun 2025 17:53:40 +0200
Subject: [PATCH] Run apt-get distclean by default if available

This improves reproducibility as debrebuild can't recreate the apt
cache. It only works in trixie and currently makes autodep8 (#961138),
some R packages via dh-r (#1089197) and blends (#1104515) FTBFS. All
bugs have at least a proposed patch.
---
 lib/Sbuild/Build.pm | 12 ++++++++++++
 lib/Sbuild/Conf.pm  |  8 ++++++++
 2 files changed, 20 insertions(+)

diff --git a/lib/Sbuild/Build.pm b/lib/Sbuild/Build.pm
index 9798018e..82f0948c 100644
--- a/lib/Sbuild/Build.pm
+++ b/lib/Sbuild/Build.pm
@@ -2569,6 +2569,18 @@ sub build {
 		}
 	}
 
+	if (!$self->get_conf('DONT_CLEAN_APT_CACHE')) {
+		$self->log_subsubsection("clean up apt cache");
+		$session->run_command({
+			COMMAND => ["apt-get", "distclean"],
+			USER    => 'root',
+		});
+		if ($?) {
+			$self->log_error("cleaning the apt cache failed with $?\n");
+		   # Don't fail as distclean was only introduced in apt 2.7.8 (trixie).
+		}
+	}
+
 	$self->log_subsubsection("Check disk space");
 	chomp(my $current_usage
 		  = $session->read_command(
diff --git a/lib/Sbuild/Conf.pm b/lib/Sbuild/Conf.pm
index 941040e4..b4a5e517 100644
--- a/lib/Sbuild/Conf.pm
+++ b/lib/Sbuild/Conf.pm
@@ -975,6 +975,14 @@ $unshare_mmdebstrap_extra_args = [
 			DEFAULT => 0,
 			HELP    =>
 'Run in split mode?  In split mode, apt-get and dpkg are run on the host system, rather than inside the chroot.'
+		},
+		'DONT_CLEAN_APT_CACHE' => {
+			TYPE    => 'BOOL',
+			VARNAME => 'dont_clean_apt_cache',
+			GROUP   => 'Build options',
+			DEFAULT => 1,
+			HELP    =>
+'sbuild runs apt-get distclean by default to clean the apt package cache if the command is available. This makes sure that the build environment is not polluted by extra information but means that you need to run apt update before manually installing packages for debugging. You can disable this to save the extra call but remember to not use the information from the apt cache. Also note that this silently files when the command is not available to be compatible with older releases.'
 		},
 		'CHECK_SPACE' => {
 			TYPE    => 'BOOL',
-- 
2.49.0

Attachment: signature.asc
Description: PGP signature


Reply to: