#1002952 build-rdeps: Inconsistent defaults on Ubuntu (or other non-Debian systems)

Package:
devscripts
Source:
devscripts
Description:
scripts to make the life of a Debian Package maintainer easier
Submitter:
Matthijs Kooijman
Date:
2022-01-01 17:27:04 UTC
Severity:
normal
#1002952#5
Date:
2022-01-01 17:25:31 UTC
From:
To:
Hi,

I was trying to use build-rdeps on Ubuntu today, and the default settings seem
unusable there. I tried both the Ubuntu version from impish and the Sid
version, both with the same result:

  $ sudo build-rdeps -d dh-cmake
  DEBUG: Package => dh-cmake
  DEBUG: running with dose-ceve resolver
  DEBUG: buildarch=amd64 hostarch=amd64
  DEBUG: Running 'apt-get' 'indextargets' 'DefaultEnabled: yes' 'Origin:
  Debian'
  build-rdeps: unable to find sources files.
  Did you forget to run apt-get update (or add --update to this command)?
  at /usr/bin/build-rdeps line 520.

Looking at the source code, I see that there does seem to be some code
in place to handle non-Debian vendors as well, but I think this does not
work well currently.

By default, the script only looks at sources that have 'Origin: Debian',
regardless of what the current system is:

https://salsa.debian.org/debian/devscripts/-/blob/master/scripts/build-rdeps.pl#L157
  my $opt_origin = 'Debian';

However, it then further limits sources to "development" releases only:

https://salsa.debian.org/debian/devscripts/-/blob/master/scripts/build-rdeps.pl#L227
  sub is_devel_release {
      my $ctrl = shift;
      if (get_current_vendor() eq 'Debian') {
	  return $ctrl->{Suite} eq 'unstable' || $ctrl->{Codename} eq 'sid';
      } else {
	  return $ctrl->{Suite} eq 'devel';
      }
  }

In this case, it *does* use the current vendor to determine the default
release to check for, meaning running build-rdeps without additional
options on non-Debian systems will never work (not even if you have
Debian deb-src lines in your sources.list as I have).

It seems like adding an explicit --origin Ubuntu would help here,
except:
 - Using a "devel" release of Ubuntu is apparently not a common practice
   (anymore):
https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1728616/comments/2
 - If you *do* use e.g. `deb-src http://archive.ubuntu.com/ubuntu/ devel main`,
   this produces "Release: devel", not "Suite: devel", so the current
   code still does not match.

More generally, I wonder if build-rdeps should really limit itself to a
devel release only. This poses an additional requirement on your
sources.list (you need to have deb-src for sid or devel), which is not
documented in the manpage and not hinted at by the error message.

I can imagine it would *favor* unstable/devel if available (or maybe
testing if unstable is not found) , but fall back to the most recent
release (based on the Version field), or failing that, *any* available
src release instead?


As for the conflicting defaults, I can imagine:
 - Adding a --vendor option, defaulting to Dpkg::Vendor::get_current_vendor()
 - Pick the Origin based on the vendor (and maybe apply no origin limit
   for unknown vendors)
 - Pick the default distribution based on the vendor, like now (but
   checking against Release: devel instead of Suite:devel

Alternatively, if the "priority"-based scheme suggested above is
implemented, maybe there is no need at all to switch the distribution
based on the vendor at all. If you just apply a priority to each release
(sid/unstable/devel get max priority, testing nearly max priority,
others based on Version) this works regardless of the current vendor,
and you can switch between vendors based on the Origin (which should
probably still switch its default based on the vendor).


Note that there is also the matter of the list of components being
hardcoded currently, but that is already the subject of #913551.

As for making the current version work, what I can now do is:
 - Add a Ubuntu "devel" release to sources.list, patch build-rdeps to
   check Release: devel instead of Suite: devel, and run with `--origin
   Ubuntu".
 - Run with "--origin Ubuntu --distribution impish" (or whatever distro
   you're using).
 - Add "sid" sources to sources.list, and run with `--distribution sid`.

Gr.

Matthijs
--- /etc/devscripts.conf ---
Empty.
--- ~/.devscripts --- Not present