From 7edc224dd044f1ed49990b185da602c23e23b712 Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Sat, 8 Oct 2022 08:08:06 +0000 Subject: dh: Hoist nocheck and nodoc into DEB_BUILD_OPTIONS from _PROFILES This makes `dh` builds "just work(tm)" for users out of the box even if they forget to be WET ("Write Everything Twice") about their environment variables. The hoisting does trigger a warning to aid the user understand why it magically works with `dh` based packages but fails horribly in fire and flames for non-`dh` packages. Personally, I still think we should permanently move `nocheck` and `nodoc` into `DEB_BUILD_PROFILES`. However, for now let us settle with making 90% of all source packages in testing work out of the box if you try to be DRY ("Don't Repeat Yourself") with environment variables. Closes: https://bugs.debian.org/979401 Signed-off-by: Niels Thykier --- debian/changelog | 6 ++++++ dh | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/debian/changelog b/debian/changelog index c79d773a..70393e99 100644 --- a/debian/changelog +++ b/debian/changelog @@ -38,6 +38,12 @@ debhelper (13.10) UNRELEASED; urgency=medium * dh_assistant: Provide a new `detect-hook-targets` command. * dh: Recommend using `dh_assistant detect-hook-targets` for checking whether hook targets are correct. + * dh: Hoist `nodoc` and `nocheck` from `DEB_BUILD_PROFILES` + into `DEB_BUILD_OPTIONS` when they are present in the former + and absent in the latter. Emit a warning when doing so to + aid the user, so they know why this does not work when they + are later building a package that does not use dh. + (Closes: #979401) [ Translations ] * Update Portuguese translation (Américo Monteiro) diff --git a/dh b/dh index 8e233821..a42ce9d1 100755 --- a/dh +++ b/dh @@ -750,6 +750,9 @@ if (! exists($Debian::Debhelper::DH::SequenceState::sequences{$sequence})) { parse_dh_cmd_options(@ARGV_orig); +_hoist_profile_into_dbo('nodoc'); +_hoist_profile_into_dbo('nocheck'); + # Figure out at what point in the sequence to start for each package. my (%logged, %startpoint, $completed_sequences); @@ -844,6 +847,14 @@ sub reject_obsolete_params { } } +sub _hoist_profile_into_dbo { + my ($name) = @_; + if (is_build_profile_active($name) && !get_buildoption($name)) { + $ENV{'DEB_BUILD_OPTIONS'} //= ''; + $ENV{'DEB_BUILD_OPTIONS'} .= ' ' . $name; + warning("Copying ${name} into DEB_BUILD_OPTIONS: It was in DEB_BUILD_PROFILES and but not in DEB_BUILD_OPTIONS"); + } +} =head1 SEE ALSO -- cgit v1.2.3