[debhelper-devel] [debhelper] 01/01: Make -p<pkg> a no-op when <pkg> is disabled due to Build-Profiles

Niels Thykier nthykier at moszumanska.debian.org
Sun Oct 1 08:14:15 UTC 2017


This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository debhelper.

commit 93d8fdfc5dfc994af53fc6fed7f36f271b3abee5
Author: Niels Thykier <niels at thykier.net>
Date:   Sun Oct 1 07:56:27 2017 +0000

    Make -p<pkg> a no-op when <pkg> is disabled due to Build-Profiles
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 debhelper.pod                     | 32 ++++++++++++++++++++++++++++++++
 debian/changelog                  |  5 +++++
 lib/Debian/Debhelper/Dh_Getopt.pm | 21 ++++++++++++++++++---
 3 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/debhelper.pod b/debhelper.pod
index b03a8bb..e39bafd 100644
--- a/debhelper.pod
+++ b/debhelper.pod
@@ -822,6 +822,38 @@ B<DEB_BUILD_PROFILES> environment variable and B<Build-Profiles> fields in
 binary package stanzas in B<debian/control>, according to the draft policy at
 L<https://wiki.debian.org/BuildProfileSpec>.
 
+=head3 Interaction between package selections and Build-Profiles
+
+Build-Profiles affect which packages are included in the package
+selections mechanisms in debhelper.  Generally, the package selections
+are described from the assumption that all packages are enabled.  This
+section describes how the selections react when a package is disabled
+due to the active Build-Profiles (or lack of active Build-Profiles).
+
+=over 4
+
+=item -a/--arch, -i/--indep OR no selection options (a raw "dh_X" call)
+
+The package disabled by Build-Profiles is silently excluded from the
+selection.
+
+Note you will receive a warning if I<all> packages related to these
+selections are disabled.  In that case, it generally does not make
+sense to do the build in the first place.
+
+=item -N I<package> / --no-package I<package>
+
+The option is accepted and effectively does nothing.
+
+=item -p I<package> / --package I<package>
+
+The option is accepted, but debhelper will not act on the package.
+
+=back
+
+Note that it does not matter whether a package is enabled or disabled
+by default.
+
 =head2 Automatic generation of Debian install scripts
 
 Some debhelper commands will automatically generate parts of Debian
diff --git a/debian/changelog b/debian/changelog
index 593325b..81a8189 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,11 @@ debhelper (10.9.1) UNRELEASED; urgency=medium
     messages during parsing when -O options were passed via
     DH_OPTIONS (among other).  Thanks to Adrian Bunk and
     Andrew Shadura for reporting the issue.  (Closes: #876689)
+  * Dh_Getopt.pm: Gracefully reduce the tool to a no-op when given
+    a -p<pkg> and <pkg> is disabled by a Build-Profile.
+  * debhelper.7: Document how package selections interact with
+    Build-Profiles.  Thanks to Helmut Grohne for the report.
+    (Closes: #872745)
 
  -- Niels Thykier <niels at thykier.net>  Thu, 21 Sep 2017 19:13:19 +0000
 
diff --git a/lib/Debian/Debhelper/Dh_Getopt.pm b/lib/Debian/Debhelper/Dh_Getopt.pm
index dce0bca..1f39dfe 100644
--- a/lib/Debian/Debhelper/Dh_Getopt.pm
+++ b/lib/Debian/Debhelper/Dh_Getopt.pm
@@ -11,7 +11,7 @@ use warnings;
 use Debian::Debhelper::Dh_Lib;
 use Getopt::Long;
 
-my (%exclude_package, %known_packages);
+my (%exclude_package, %known_packages, %profile_enabled_packages, $profile_excluded_pkg);
 
 sub showhelp {
 	my $prog=basename($0);
@@ -45,7 +45,14 @@ sub AddPackage { my($option,$value)=@_;
 		if (not exists($known_packages{$value})) {
 			error("Requested unknown package ${value} via -p/--package, expected one of: " . join(' ', getpackages()));
 		}
-		push @{$dh{DOPACKAGES}}, $value;
+		%profile_enabled_packages = map { $_ => 1 } getpackages('both') if not %profile_enabled_packages;
+		# Silently ignore packages that are not enabled by the
+		# profile.
+		if (exists($profile_enabled_packages{$value})) {
+			push @{$dh{DOPACKAGES}}, $value;
+		} else {
+			$profile_excluded_pkg = 1;
+		}
 	}
 	else {
 		error("bad option $option - should never happen!\n");
@@ -253,14 +260,22 @@ sub parseopts {
 	# want us to act on them all. Note we have to do this before excluding
 	# packages out, below.
 	if (! defined $dh{DOPACKAGES} || ! @{$dh{DOPACKAGES}}) {
+		my $do_exit = 0;
+		if ($profile_excluded_pkg) {
+			if (! $dh{BLOCK_NOOP_WARNINGS}) {
+				warning("All requested packages have been excluded (e.g. via a Build-Profile).");
+			}
+			$do_exit = 1;
+		}
 		if ($dh{DOINDEP} || $dh{DOARCH}) {
 			# User specified that all arch (in)dep package be
 			# built, and there are none of that type.
 			if (! $dh{BLOCK_NOOP_WARNINGS}) {
 				warning("You asked that all arch in(dep) packages be built, but there are none of that type.");
 			}
-			exit(0);
+			$do_exit = 1;
 		}
+		exit(0) if $do_exit;
 		push @{$dh{DOPACKAGES}},getpackages("both");
 	}
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git




More information about the debhelper-devel mailing list