#1090358 sbuild: please pre-set config variables with their defaults

Package:
sbuild
Source:
sbuild
Submitter:
Chris Hofstaedtler
Date:
2025-01-16 07:09:04 UTC
Severity:
normal
Tags:
#1090358#5
Date:
2024-12-17 13:20:16 UTC
From:
To:
I wish sbuild would allow me to extend its config settings in
.sbuildrc or .config/sbuild/config.pl, without having to re-state
the previous defaults.

As an example, I want to extend $unshare_mmdebstrap_extra_args with
some option. But I want to keep the existing defaults too!

This bug report is mostly here to escape the salsa comment mess;
the traces are https://salsa.debian.org/debian/sbuild/-/merge_requests/104#note_559900
and some previous bug report that figured out one can use $conf in
the config file.

In https://salsa.debian.org/debian/sbuild/-/merge_requests/104#note_559973
josch@ provided a draft patch to sbuild:
--- a/lib/Sbuild/ConfBase.pm
+++ b/lib/Sbuild/ConfBase.pm
@@ -502,7 +502,12 @@ sub read ($$$$) {
        next if $conf->_get_group($key) =~ m/^__/;

        my $varname = $conf->_get_varname($key);
-       $script .= "my \$$varname = undef;\n";
+        my $vardefault = $conf->_get_default($key);
+        if (defined $vardefault) {
+           $script .= "my " . Data::Dumper->Dump([$vardefault], [$varname]);
+        } else {
+            $script .= "my \$$varname = undef;\n";
+        }
     }

     # For compatibility only.  Non-scalars are deprecated.

But also stated:

Chris

#1090358#10
Date:
2024-12-17 14:03:44 UTC
From:
To:
I have to say that results in some "interesting" breakage.

For one, autopkgtest is unhappy. Running
   sbuild -s --no-clean-source -d unstable hello
gives:

| autopkgtest
| -----------
|
| autopkgtest [14:56:35]: starting date and time: 2024-12-17 14:56:35+0100
| autopkgtest [14:56:35]: version 5.42
| autopkgtest [14:56:35]: host tiksta; command line: /usr/bin/autopkgtest /home/ch/Debian/tryout/hello_2.10-3_arm64.changes --apt-upgrade -- unshare --release unstable --arch arm64
| autopkgtest [14:56:36]: testbed dpkg architecture: arm64
| autopkgtest [14:56:36]: testbed apt version: 2.9.17
| autopkgtest [14:56:36]: @@@@@@@@@@@@@@@@@@@@ test bed setup
| autopkgtest [14:56:36]: testbed release detected to be: None
| autopkgtest [14:56:36]: updating testbed package index (apt update)
| Get:1 http://deb.debian.org/debian unstable InRelease [202 kB]
| Get:2 http://deb.debian.org/debian unstable/main arm64 Packages [9977 kB]
| Get:3 http://deb.debian.org/debian unstable/main Translation-en [7349 kB]
| Fetched 17.5 MB in 2s (11.6 MB/s)
| Reading package lists...
| autopkgtest [14:56:38]: upgrading testbed (apt dist-upgrade and autopurge)
| Reading package lists...
| Building dependency tree...
| Reading state information...
| Calculating upgrade...Starting pkgProblemResolver with broken count: 0
| Starting 2 pkgProblemResolver with broken count: 0
| Done
| Entering ResolveByKeep
|
| 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
| Reading package lists...
| Building dependency tree...
| Reading state information...
| Starting pkgProblemResolver with broken count: 0
| Starting 2 pkgProblemResolver with broken count: 0
| Done
| 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
| autopkgtest [14:56:39]: testbed running kernel: Linux 6.11.10-arm64 #1 SMP Debian 6.11.10-1 (2024-11-23)
| autopkgtest [14:56:39]: @@@@@@@@@@@@@@@@@@@@ source /home/ch/Debian/tryout/hello_2.10-3.dsc
| Unexpected error:
| Traceback (most recent call last):
|   File "/usr/share/autopkgtest/lib/VirtSubproc.py", line 833, in mainloop
|     command()
|   File "/usr/share/autopkgtest/lib/VirtSubproc.py", line 762, in command
|     r = f(c, ce)
|         ^^^^^^^^
|   File "/usr/share/autopkgtest/lib/VirtSubproc.py", line 696, in cmd_copydown
|     copyupdown(c, ce, False)
|   File "/usr/share/autopkgtest/lib/VirtSubproc.py", line 584, in copyupdown
|     copyupdown_internal(ce[0], c[1:], upp)
|   File "/usr/share/autopkgtest/lib/VirtSubproc.py", line 611, in copyupdown_internal
|     copydown_shareddir(sd[0], sd[1], dirsp, downtmp_host)
|   File "/usr/share/autopkgtest/lib/VirtSubproc.py", line 566, in copydown_shareddir
|     shutil.copy(host, host_tmp)
|   File "/usr/lib/python3.12/shutil.py", line 435, in copy
|     copyfile(src, dst, follow_symlinks=follow_symlinks)
|   File "/usr/lib/python3.12/shutil.py", line 260, in copyfile
|     with open(src, 'rb') as fsrc:
|          ^^^^^^^^^^^^^^^
| FileNotFoundError: [Errno 2] No such file or directory: '/home/ch/Debian/tryout/hello_2.10.orig.tar.gz'
| autopkgtest [14:56:39]: ERROR: testbed failure: unexpected eof from the testbed
|
| E: Autopkgtest run failed.

Which is certainly weird. I think this might be some interaction
between -s and $source_only_changes=1. I don't have any more details
yet, need to dig into testing/diffing logs more.

Chris

#1090358#15
Date:
2024-12-17 14:17:25 UTC
From:
To:
[..]
unstable. The bad news is: this happens ;-)

Chris

#1090358#18
Date:
2024-12-17 14:18:41 UTC
From:
To:
Hi,

Quoting Chris Hofstaedtler (2024-12-17 14:20:16)

me too.

Thank you! I also prefer the BTS for this. :)

The question is how to proceed. I fear that things will break. But I tested
this and nothing broke. But I know that people are *very* creative when it
comes to their ~/.sbuildrc... I fear that the only way to find out what breaks
is to upload and break things... :/

Thanks!

cheers, josch

#1090358#23
Date:
2024-12-17 14:48:03 UTC
From:
To:
I fear that is indeed the only way to find that out. :/

Chris

#1090358#28
Date:
2024-12-17 21:09:58 UTC
From:
To:
Hi,

* Johannes Schauer Marin Rodrigues <josch@debian.org> [241217 15:18]:

Please test this scenario, and see if that works for you / what
happens:

cd /var/tmp
apt source hello
cd hello-2.10
sbuild --chroot-mode=unshare --no-run-lintian
test -e hello_*changes && echo "whoops, wrote to wrong dir"

Chris

#1090358#31
Date:
2024-12-17 22:59:46 UTC
From:
To:
Hi,

Quoting Chris Hofstaedtler (2024-12-17 22:09:58)

thank you. This is because of the convenience feature that sbuild gained in
2011 with commit 601af3d6f3a7028b88e1b88e7e3afeeeef4877bb. If you run sbuild
inside an unpacked source directory, then sbuild will automatically run
"dpkg-source -b ." for you and place the build artifacts in the parent.  It
does so by changing the working directory of the process to the parent and
setting the *default* of BUILD_DIR to that directory. But at that point,
the ~/.sbuildrc has long since been evaluated. And at the point where it
got evaluated, the working directory was still the unpacked source
directory and not its parent. The patch in this bug report sets the value
of BUILD_DIR to the unpacked source dir and thus, changing the default of
BUILD_DIR later on has no effect anymore because the value was already
set to the default from back then...

The fix is not trivial considering that we don't want the fix to this to break
more things...

Thanks!

cheers, josch

#1090358#36
Date:
2024-12-18 07:48:54 UTC
From:
To:
* Johannes Schauer Marin Rodrigues <josch@debian.org> [241217 23:59]:

I haven't yet looked at what code touches BUILD_DIR exactly, but an
interim thing that one could ponder:

#1090358#41
Date:
2024-12-18 08:12:08 UTC
From:
To:
* Chris Hofstaedtler <zeha@debian.org> [241218 08:48]:

It is. Not sure why my config still evaluates at all.

It it was just about BUILD_DIR, maybe we can get away with ignoring
vars that have IGNORE_DEFAULT => 1?

Chris

#1090358#44
Date:
2024-12-18 16:07:57 UTC
From:
To:
Hi,

Quoting Chris Hofstaedtler (2024-12-18 09:12:08)

that would overload the meaning of a setting that is intended for a completely
different purpose. How about this instead:
--- a/lib/Sbuild/Conf.pm +++ b/lib/Sbuild/Conf.pm @@ -904,7 +904,16 @@ $unshare_mmdebstrap_extra_args = [ TYPE => 'STRING', VARNAME => 'build_dir', GROUP => 'Core options', - DEFAULT => cwd(), + DEFAULT => undef, + GET => sub { + my $conf = shift; + my $entry = shift; + my $retval = $conf->_get($entry->{'NAME'}); + if (!defined($retval)) { + $retval = cwd(); + } + return $retval; + }, IGNORE_DEFAULT => 1, # Don't dump class to config EXAMPLE => '$build_dir = \'/home/pete/build\';', CHECK => $validate_directory, Thanks! cheers, josch
#1090358#47
Date:
2025-01-15 13:33:11 UTC
From:
To:
Hello,

Bug #1090358 in sbuild reported by you has been fixed in the
Git repository and is awaiting an upload. You can see the commit
message below and you can check the diff of the fix at:

https://salsa.debian.org/debian/sbuild/-/commit/7e4c1404cc9c3fbbd788b18ed334eaa6be935fd6
------------------------------------------------------------------------
lib/Sbuild/ConfBase.pm: Set variables to their default values in ~/.config/sbuild/sbuild.conf

Closes: #1090358
------------------------------------------------------------------------

(this message was generated automatically)
-- 
Greetings

https://bugs.debian.org/1090358

#1090358#54
Date:
2025-01-16 07:05:14 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
sbuild, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1090358@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Johannes Schauer Marin Rodrigues <josch@debian.org> (supplier of updated sbuild package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Thu, 16 Jan 2025 07:46:28 +0100
Source: sbuild
Architecture: source
Version: 0.88.2
Distribution: unstable
Urgency: medium
Maintainer: sbuild maintainers <sbuild@packages.debian.org>
Changed-By: Johannes Schauer Marin Rodrigues <josch@debian.org>
Closes: 1089035 1089105 1090336 1090358 1091169 1091170 1091370 1092091 1092557
Changes:
 sbuild (0.88.2) unstable; urgency=medium
 .
   [ Johannes Schauer Marin Rodrigues ]
   * lib/Sbuild/Conf.pm:
      - fix examples for ENVIRONMENT_FILTER (Closes: #1090336)
      - do not ignore an empty DEB_BUILD_PROFILES environment variable
      - Add CHROOT_ALIASES configuration option, allowing one to look up chroots
        under a different name (Closes: #1089035)
   * lib/Sbuild/ConfBase.pm:
      - run check after setting all values
      - preserve order of configuration options
      - Set variables to their default values in ~/.config/sbuild/config.pl
        (Closes: #1090358)
   * lib/Sbuild/ChrootUnshare.pm:
      - check if mmdebstrap is installed only when needed
      - instead of passing the tarball path to the decompressor, let sbuild open
        it and feed it to the decompressor program via standard input (Closes:
        #1091169)
   * debian/tests/unshare:
      - install ca-certificates for https debci hosts. Thanks to Paul Gevers
      - run dpkg-deb with --root-owner-group (Closes: #1092091)
   * lib/Sbuild/Build.pm: fail if dpkg --print-foreign-architectures failed
   * lib/Sbuild/ResolverBase.pm: build metapackage with dpkg-deb
     --root-owner-group (Closes: #1092557)
   * Use dpkg-buildtree to figure out if fakeroot is required
   * die if exec fails because it cannot find the program
 .
   [ Simon McVittie ]
   * man: Cross-reference the --build-dir option in BUILD ARTIFACTS
   * man: Document how and where log files are saved
 .
   [ Guillem Jover ]
   * lib/Sbuild/Conf.pm: Do not use deprecated Dpkg::Build::Info module
 .
   [ Chris Hofstaedtler ]
   * Remove deborphan from Suggests:, package was removed
   * sbuild-update: abort if chroot-mode=unshare (Closes: #1089105, #1091370)
 .
   [ Santiago Ruano Rincón ]
   * Add Recommends on iproute2
   * Fix mmdebstrap+unshare setup-hook when handling *-security suites
 .
   [ Jakub Wilk ]
   * man: Remove stray quotation mark
 .
   [ Richard Lewis ]
   * man/sbuild.1.in: remove stray quotation mark
   * Document the need to retain package lists in the chroot if $apt_update is 0
     (Closes: #1091170)
 .
   [ Jochen Sprickerhof ]
   * unshare: Use $BUILD_USER as the default user
   * unshare: Use 'sbuild' as the default user
   * Use BUILD_USER for architecture and disk space check
Checksums-Sha1:
 0f0099edcbf367fae51ea461298ed81e97f28812 2643 sbuild_0.88.2.dsc
 7c8afb029abcb8524160a037aee55cf1ff601080 255988 sbuild_0.88.2.tar.xz
Checksums-Sha256:
 43147313e02531d784b5fed0b81ad45481bc89e0b17f13c89cdc268d91a3af47 2643 sbuild_0.88.2.dsc
 569736857d4e906faf50ce25baa3e10d45d4be983237b70ce4e1e00871557116 255988 sbuild_0.88.2.tar.xz
Files:
 47556984b7a862d35ab78354c7c3a68c 2643 devel optional sbuild_0.88.2.dsc
 1b63edbc9459af6f09986dfc82e34a74 255988 devel optional sbuild_0.88.2.tar.xz
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEElFhU6KL81LF4wVq58sulx4+9g+EFAmeIq2YACgkQ8sulx4+9
g+ESFQ//Y/wgtNcLRqfw/sIWtUd1OC1a/o2U26BHY9KZjW5Rqp01B4FepDwoH3c/
r+brucA3j2/0nvx6BpcF2EupcMlgPpY4J4EYmisyZrHgYBPlHyc8LyKVm2gDEnPV
LapflaCbdTWprYQoijxdjQ9lGJiz1XQCS+xhwI8EcIK+KXxx18pbB3i3DSLhEkX/
Ud5qHb0Y/tnj+xtdKVZED+Z6AmlGiT0+GEjWw1N7bC+uLy2J8IbdUB37ANopvVtE
l3u54HIh8M/+hDW7B4X/QeB+houFPXzRNZx+QlccWJvf19MiPPKpbOa213ieG5IH
raijuMEwNzH2PevH8nBKA1REcIAyYXlcdk4OaLm3rsiXLk2rPtXaVbFazxMiqP8m
3UyOMPmBfZSjOMjkbVtYHiw6YuA7uYCejyW5h//jW1v4NNBVQZKbHAddLjp4m6+A
oBSbuGLVamTvqcUJG+n94V+U1pRHCtvvvtYHi4h991k4Cph/klzYF3zHmZsxcET6
WBaOv4erPMP1BJkD7B2O5oxGr8tJ/jprEKtbJa1LsNakjDu7pBYumL+mmj4OKlhO
oIjw3ujGfVkXE+9Glmtj5WRTZTzRJ+cYz6zTQfwJRZ3WJxLtmJCUazK+uXi/VL01
M3bNHlwwCAyLDZ9yGm45YwneY7EiMfZytL6S8czYs+FTwXRC8og=
=H3Yw
-----END PGP SIGNATURE-----