#1104517 command-not-found: avoid relying on /etc/apt/sources.list in tests

#1104517#5
Date:
2025-05-01 13:28:35 UTC
From:
To:
Hi,

in a clean environment without /etc/apt/sources.list(.d/*),
command-not-found's build-time tests fail like this:


======================================================================
FAIL: test_from_table (CommandNotFound.tests.test_command_not_found.CommandNotFoundOutputTest.test_from_table)
----------------------------------------------------------------------
Traceback (most recent call last):
   File "/build/reproducible-path/command-not-found-23.04.0/CommandNotFound/tests/test_command_not_found.py", line 149, in test_from_table
     self._test_spec(spec)
     ~~~~~~~~~~~~~~~^^^^^^
   File "/build/reproducible-path/command-not-found-23.04.0/CommandNotFound/tests/test_command_not_found.py", line 191, in _test_spec
     self.assertEqual(output, expected_output, "test '%s' broken" % test)
     ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: "Comm[87 chars]0, or (You will have to enable component calle[97 chars]')\n" != "Comm[87 chars]0, or\nsudo apt install neovim  # version 2.0\n"
   Command 'x-vi' not found, but can be installed with:
- sudo apt install vim     # version 1.0, or (You will have to enable component called 'main')
- sudo apt install neovim  # version 2.0 (You will have to enable component called 'main')
+ sudo apt install vim     # version 1.0, or
+ sudo apt install neovim  # version 2.0
  : test 'multi advise debs' broken


Please find a patch attached, avoiding this problem.

Please apply it.

Thanks,
Chris

#1104517#10
Date:
2025-05-09 16:29:00 UTC
From:
To:
I just want to note:

I do not believe that a build environment lacking apt or the
apt configuration or a working apt cache is a valid build
environment.

In particular, builds of native packages should be able to
run smoke tests against the build system state.

#1104517#15
Date:
2025-05-09 17:39:13 UTC
From:
To:
Hi,

if you feel strongly about this, you should bring this up on
debian-devel@l.d.o, I think. Because what you describe is not how we currently
build packages in Debian. To implement what you describe, we at least need to
add apt as a Depends to the build-essential package. A package that is not
explicitly (via B-D) or implicitly (via Essential:yes and build-essential) a
(direct or transitive) build dependency of a source package must not be a
requirement for that source package to be buildable. Or in other words: if you
say that you think that apt should be part of the build environment for source
packages in Debian then it must be added either to the Essential:yes set, as a
Depends of build-essential or listed as an explicit Build-Depends,
Build-Depends-Indep or Build-Depends-Arch.

Before you embark on this journey note though, that what you describe is
currently the opposite of what is done in practice. Since apt is neither part
of the explicit nor of the implicit build dependencies of source packages in
general, it is also not listed in .buildinfo files and as a result, the mass
rebuilds done by the rebuilderd machines of the reproducible builds projects
regularly rebuild all source packages in the archive without apt and file bugs
for packages which need apt without explicitly depending on it.

Note also, that I am moving sbuild in a direction which will make it possible
to build source packages in a chroot without apt hopefully during the Forky
cycle. We have package builders like sbuild to make sure that our source
packages are rebuilt in a minimal and well defined environment. Apt is neither
part of the (transative) Essential:yes package set nor of the (transitive)
build-essential set and hence it currently being part of the default chroots is
what I consider a historic artifacts of how chroots used to be built. You know
that it is not a problem to create chroots of an arbitrary package selection
without having apt installed inside that chroot by using apt from the outside
on that chroot. What stopped us in the past from making use of this feature in
sbuild is the schroot backend. Last year, buildds switched away from schroot so
my hope is that we can soon reap another benefit of that switch and get
apt-less source package building also on the buildds.

If you do not believe that "a build environment lacking apt or the apt
configuration or a working apt cache is a valid build environment." then we
need to have a bigger discussion. Because that believe is in contrast to where
me and others are currently trying to move sbuild, rebuilderd and buildds.
Thanks to the effort of the reproducible builds folks, the archive today is in
a state where apt is *not* needed inside the chroot. If you believe this is a
problem, then we should discuss this with a wider audience.

Thanks!

cheers, josch

#1104517#20
Date:
2025-11-01 06:26:11 UTC
From:
To:
Hi Julian,

* Julian Andres Klode <jak@debian.org> [2025-05-09 18:29]:

Please note that in this case the test already fails with a sources.list
containing:

deb [signed-by=/usr/share/keyrings/debian-archive-keyring.gpg] http://deb.debian.org/debian unstable main

As is produced by debrebuild. Also I think an empty/missing sources.list
is a valid apt configuration. Could you please fix this issue?

In general I agree with what josch wrote already.

Thanks!

Jochen

#1104517#25
Date:
2025-11-01 11:50:45 UTC
From:
To:
There's an MR on salsa hanging around fixing this. It also had a
commit to fix the other bug, so you'd have to cherry-pick the
relevant one out of the MR.

Chris

#1104517#30
Date:
2026-06-01 13:05:17 UTC
From:
To:
Hi Julian,

* Chris Hofstaedtler <zeha@debian.org> [2025-11-01 12:50]:

command-not-found is one of the last packages failing to build on
https://reproduce.debian.net. Could you please upload the patch?

Thanks!

Jochen