#1117678 sbuild: --autopkgtest-opts broken with $chroot_mode = "unshare"

#1117678#5
Date:
2025-10-09 15:36:40 UTC
From:
To:
Dear Maintainer,

While trying to add an extra repo needed by my autopkgtest run, and after
understanding that --extra-repository only applies to the build step, I started
trying to use --autopkgtest-opts.

$ --autopkgtest-opts=--add-apt-source='deb http://deb.example.net/ experimental main'
[...]
autopkgtest
-----------

autopkgtest [16:59:30]: starting date and time: 2025-10-09 16:59:30+0200
autopkgtest [16:59:30]: version 5.51
autopkgtest [16:59:30]: host skade; command line: /usr/bin/autopkgtest /tmp/lazygal_0.11-2_amd64.changes -- unshare --release unstable --arch amd64 --add-apt-source=deb http://deb.example.net/ experimental main
usage: autopkgtest-virt-unshare [-h] [-a ARCH] [-b OUTSIDE INSIDE] [-d]
                                [--bootstrapcmd BOOTSTRAPCMD] [-p PREFIX]
                                [-r RELEASE] [-t TARBALL] [-u UNPACK_DIR]
autopkgtest-virt-unshare: error: unrecognized arguments: --add-apt-source=deb http://deb.example.net/ experimental main

It seems that unshare makes AUTOPKGTEST_OPTIONS initialized with "-- unshare..."
and that --autopkgtest-opts gets appended after which make the command line fail.

The badly generated command line is:

    /usr/bin/autopkgtest /tmp/lazygal_0.11-2_amd64.changes -- unshare --release unstable --arch amd64 --add-apt-source='deb http://deb.example.net/ experimental main'

instead of:

    /usr/bin/autopkgtest --add-apt-source='deb http://deb.example.net/ experimental main' /tmp/lazygal_0.11-2_amd64.changes -- unshare --release unstable --arch amd64

Thanks,

Alex

#1117678#10
Date:
2025-10-09 17:31:09 UTC
From:
To:
Hi Alexandre,

* Alexandre Rossi <niol@zincube.net> [2025-10-09 17:36]:

You can work around this by setting $autopkgtest_opts in your
sbuild.conf. Or setting it to an empty value.

Long term I see different ways to fix this and I am not sure which one
would be best:

a) https://salsa.debian.org/ci-team/autopkgtest/-/merge_requests/515
proposes an automatic mode so we could eventually drop the `-- unshare`
injection.

b) We could make --autopkgtest-opt[s] drop the `-- unshare` injection so
one could freely add autopkgtest options on the command line. Not sure
though if it should happen always or only when the user does not have a
$autopkgtest_opts set.

c) We could add --autopkgtest-opt[s] at the beginning of the final
AUTOPKGTEST_OPTIONS or before the --.

d) We could split --autopkgtest-opt[s] into a multiple options to inject
before and after the --.

e) Document the $autopkgtest_opts = [];  workaround.

Cheers Jochen

#1117678#15
Date:
2026-04-26 09:31:13 UTC
From:
To:
i also ran into this, trying to pass
--override-control=./debian/tests/alternative-control-file for
debugging

(i didnt try this, as i already have other things added to
$autopkgtest_opts in sbuild.conf)

this is good, but users will still want to choose the mode themselves
sometimes - a fast unshare can test most things but also a slow
container is needed to test eg systemd units

this makes most sense to me: it sounds overkill, but eg
"--shell-fail" has to go before the "--" and
"--prefix=/opt/dir/with/more/space" has to go after, and users might
want all four combinations