Web lists-archives.com

DEB_BUILD_OPTIONS vs DEB_BUILD_PROFILES: What is right and what is wrong?




Hi,

while trying to get the nocheck build profile working, I stumbled over
some discrepancies between

* Debian Policy §4.9.1,
* dpkg-buildflags (behaviour + man page), and
* lintian's long description of the tag
  override_dh_auto_test-does-not-check-DEB_BUILD_OPTIONS.

lintian recommends, e.g. at
https://lintian.debian.org/tags/override_dh_auto_test-does-not-check-DEB_BUILD_OPTIONS.html:

> The debian/rules file for this package has an override_dh_auto_test
> target that does not appear to check DEB_BUILD_OPTIONS against
> nocheck.
> 
> As this check is not automatically performed by debhelper(1), the
> specified testsuite is run regardless of another maintainer using the
> nocheck build profile.
> 
> Please add a check such as:
> 
>      override_dh_auto_test:
>      ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
>              ./run-upstream-testsuite
>      endif

Please note that lintian explicitly mentions the "nocheck build
_profile_". (Emphasis is mine.)

The Debian Policy says at §4.9.1 respectively at
https://www.debian.org/doc/debian-policy/ch-source.html#debian-rules-and-deb-build-options:

> 4.9.1. debian/rules and DEB_BUILD_OPTIONS
> 
> Supporting the standardized environment variable DEB_BUILD_OPTIONS is
> recommended. This variable can contain several flags to change how a
> package is compiled and built. Each flag must be in the form flag or
> flag=options. If multiple flags are given, they must be separated by
> whitespace. [14] flag must start with a lowercase letter (a-z) and
> consist only of lowercase letters, numbers (0-9), and the characters -
> and _ (hyphen and underscore). options must not contain whitespace.
> The same tag should not be given multiple times with conflicting
> values. Package maintainers may assume that DEB_BUILD_OPTIONS will not
> contain conflicting tags.
> 
> The meaning of the following tags has been standardized:
> 
> nocheck
>
> This tag says to not run any build-time test suite provided by the package.

Please note that the Debian Policy talks about "tags" and not about
"profiles".

And dpkg-buildpackage(1) says:

>     -P, --build-profiles=profile[,...]
>
>            Specify the profile(s) we build, as a comma-separated
>            list (since dpkg 1.17.2, long option since dpkg 1.18.8).
>            The default behavior is to build for no specific
>            profile. Also sets them (as a space separated list) as
>            the DEB_BUILD_PROFILES environment variable which
>            allows, for example, debian/rules files to use this
>            information for conditional builds.

DEB_BUILD_OPTIONS is primarily (if not only) mentioned for parallel
building:

>     -j, --jobs[=jobs|auto]
>
>            […] Also adds parallel=jobs or parallel to the
>            DEB_BUILD_OPTIONS environment variable which allows
>            debian/rules files to use this information for their own
>            purposes. […]

So if I now use the code recommended by lintian to check for the
nocheck build _profile_ and build with "dpkg-buildpackage -Pnocheck",
my build fails, because DEB_BUILD_OPTIONS (as used by Lintian and
documented in the Debian Policy at 4.9.1) does _not_ contain "nocheck"
but just some "parallel=<n>" as documented by dpkg-buildpackage(1).

But the build profile name can be found in DEB_BUILD_PROFILES as
documented by dpkg-buildpackage(1).

To make easier to understand where my problem lays, here's a (more or
less real-world) example:

Given this code in debian/rules:

> override_dh_auto_test:
> ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
> 	echo "$(DEB_BUILD_OPTIONS)"
> 	echo "$(DEB_BUILD_PROFILES)"
> 	exit 2
> endif

The first two lines and the last line are copy and paste from the
mentioned lintian tag's long description.

If I now build this package with "dpkg-buildpackage -Pnocheck", it
should IMHO build fine without running the tests, but it fails as
follows:

>   debian/rules override_dh_auto_test
> make[1]: Entering directory '/home/abe/<pkg>/<pkg>'
> echo "parallel=4"
> parallel=4
> echo "nocheck"
> nocheck
> exit 2
> make[1]: *** [debian/rules:50: override_dh_auto_test] Error 2
> make[1]: Leaving directory '/home/abe/<pkg>/<pkg>'
> make: *** [debian/rules:24: binary] Error 2
> dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2

Please note that nocheck and parallel=4 are not echoed by the same
echo statement, i.e. are in separate DEB_BUILD_* variables.

So my first guess was that lintian's documentation and tag name was
wrong and that DEB_BUILD_PROFILES should have been meant. That would
affect 1135 source packages:

https://codesearch.debian.net/search?q=nocheck%2C%5C%24%5C%28DEB_BUILD_OPTIONS%5C%29

Ugh. (65 are using DEB_BUILD_PROFILES instead.)

But then I found https://bugs.debian.org/889746 which exactly demanded
earlier this year the opposite of what I had in my mind to fix this:
to rename override_dh_auto_test-does-not-check-DEB_BUILD_PROFILES to
override_dh_auto_test-does-not-check-DEB_BUILD_OPTIONS. (Cc'ing Mattia
explicitly because he requested that change.)

So now I wonder: what is wrong and needs to be fixed?

A) lintian by mixing up build tags and build profiles? (Maybe this
   mentioning of build profiles was overseen when fixing #889746.)
B) dpkg-buildpackages by not setting nocheck in DEB_BUILD_OPTIONS?
C) debian-policy (and #889746 + lintian as a followup issue) by
   documenting DEB_BUILD_OPTIONS and DEB_BUILD_PROFILES both mixed
   under DEB_BUILD_OPTIONS?
D) Something completely different like dh or so?

Or am I just missing something totally essential and don't see the
forest for the trees?

And a more general question, especially in case A:

If I want to build something with the build-profile nocheck, do I
really have to set DEB_BUILD_OPTIONS myself separately to "nocheck" in
addition to "-Pnocheck"? That sounds very counterintuitive to me…

		Regards, Axel
-- 
 ,''`.  |  Axel Beckert <abe@xxxxxxxxxx>, https://people.debian.org/~abe/
: :' :  |  Debian Developer, ftp.ch.debian.org Admin
`. `'   |  4096R: 2517 B724 C5F6 CA99 5329  6E61 2FF9 CD59 6126 16B5
  `-    |  1024D: F067 EA27 26B9 C3FC 1486  202E C09E 1D89 9593 0EDE