summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Debian/Debhelper/Dh_Lib.pm52
-rw-r--r--debhelper.pod11
-rw-r--r--debian/changelog4
3 files changed, 62 insertions, 5 deletions
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 7120a708..377454ed 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -761,6 +761,44 @@ sub buildos {
}
}
+# Passed a list of profiles to match against, returns true if
+# DEB_BUILD_PROFILES environment variable matched
+sub buildprofilesmatch {
+ my %debbuildprofiles = ();
+ if (exists $ENV{'DEB_BUILD_PROFILES'}) {
+ foreach my $profile (split(/\s+/, $ENV{'DEB_BUILD_PROFILES'})) {
+ $debbuildprofiles{$profile} = 1;
+ }
+ }
+
+ my $packageprofilesstr = shift;
+ my $package = shift;
+ my @packageprofiles = split(/\s+/, $packageprofilesstr);
+ my $err = sub { error("Build-Profiles field for package $package contains both positive and negative entries"); };
+ if ($#packageprofiles < 0 || $packageprofiles[0] =~ /^!/) {
+ # package profiles list is negative or empty
+ foreach my $packageprofile (@packageprofiles) {
+ $packageprofile =~ /^!(.*)$/ || &{$err}();
+ if ($debbuildprofiles{$1}) {
+ return 0;
+ }
+ }
+ return 1;
+ }
+ else {
+ # package profiles list is positive
+ foreach my $packageprofile (@packageprofiles) {
+ if ($packageprofile =~ /^!/) {
+ &{$err}();
+ }
+ if ($debbuildprofiles{$packageprofile}) {
+ return 1;
+ }
+ }
+ return 0;
+ }
+}
+
# Returns source package name
sub sourcepackage {
open (CONTROL, 'debian/control') ||
@@ -785,18 +823,20 @@ sub sourcepackage {
# packages.
# As a side effect, populates %package_arches and %package_types with the
# types of all packages (not only those returned).
-my (%package_types, %package_arches);
+my (%package_types, %package_arches, %package_profiles);
sub getpackages {
my $type=shift;
%package_types=();
%package_arches=();
+ %package_profiles=();
$type="" if ! defined $type;
my $package="";
my $arch="";
my $package_type;
+ my $build_profiles;
my @list=();
my %seen;
open (CONTROL, 'debian/control') ||
@@ -814,6 +854,7 @@ sub getpackages {
error("debian/control has a duplicate entry for $package");
}
$package_type="deb";
+ $build_profiles="";
}
if (/^Architecture:\s*(.*)/) {
$arch=$1;
@@ -821,11 +862,15 @@ sub getpackages {
if (/^(?:X[BC]*-)?Package-Type:\s*(.*)/) {
$package_type=$1;
}
-
+ if (/^Build-Profiles:\s*(.*)/) {
+ $build_profiles=$1;
+ }
+
if (!$_ or eof) { # end of stanza.
if ($package) {
$package_types{$package}=$package_type;
$package_arches{$package}=$arch;
+ $package_profiles{$package}=$build_profiles;
}
if ($package &&
@@ -833,7 +878,8 @@ sub getpackages {
(($type eq 'arch' || $type eq 'both') && ($arch eq 'any' ||
($arch ne 'all' &&
samearch(buildarch(), $arch)))) ||
- ! $type)) {
+ ! $type) &&
+ buildprofilesmatch($build_profiles, $package)) {
push @list, $package;
$package="";
$arch="";
diff --git a/debhelper.pod b/debhelper.pod
index 216360b2..ca22cc41 100644
--- a/debhelper.pod
+++ b/debhelper.pod
@@ -566,7 +566,16 @@ To facilitate this, as well as give you more control over which packages
are acted on by debhelper programs, all debhelper programs accept the
B<-a>, B<-i>, B<-p>, and B<-s> parameters. These parameters are cumulative.
If none are given, debhelper programs default to acting on all packages listed
-in the control file.
+in the control file, with the exceptions below.
+
+First, any package whose B<Architecture> field in B<debian/control> does not
+match the build architecture will be excluded
+(L<Debian Policy, section 5.6.8>).
+
+Also, some additional packages may be excluded based on the contents of the
+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>.
=head2 Automatic generation of Debian install scripts
diff --git a/debian/changelog b/debian/changelog
index 7e3d3ec0..673b2a28 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-debhelper (9.20131228) UNRELEASED; urgency=medium
+debhelper (9.20140210) UNRELEASED; urgency=medium
* dh_compress: Avoid compressing .map files, which may be html
usemaps. Closes: #704443
@@ -10,6 +10,8 @@ debhelper (9.20131228) UNRELEASED; urgency=medium
parameters intended to be passed on to debhelper commands.
Closes: #737635
* perl_build: Use realclean instead of distclean. Closes: #737662
+ * Initial implementation of support for Build-Profiles fields.
+ Thanks, Daniel Schepler.
-- Joey Hess <joeyh@debian.org> Sat, 25 Jan 2014 15:49:45 -0400