diff options
author | Joey Hess <joey@kitenet.net> | 2014-02-12 13:13:02 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-02-12 13:13:02 -0400 |
commit | f16d0915b10ff9ef0b0826ae896aaccd6f3ad84f (patch) | |
tree | 4ecaaf1a12ecb5e02f834ae601a6b06590b0e868 /Debian | |
parent | 3ae6a7452800e1c5be0351f45d9911a23ab103f1 (diff) | |
download | debhelper-f16d0915b10ff9ef0b0826ae896aaccd6f3ad84f.tar.gz |
Initial implementation of support for Build-Profiles fields. Thanks, Daniel Schepler.
Diffstat (limited to 'Debian')
-rw-r--r-- | Debian/Debhelper/Dh_Lib.pm | 52 |
1 files changed, 49 insertions, 3 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=""; |