Просмотр исходного кода

dpkg-genchanges: Handle omitted packages due to build profiles

Properly handle the absence of packages in DEBIAN/control depending
on build profiles, so that we do not emit bogus warnings anymore.

Closes: #758191

Based-on-patch-by: Johannes Schauer <j.schauer@email.de>
Signed-off-by: Guillem Jover <guillem@debian.org>
Guillem Jover лет назад: 12
Родитель
Сommit
61e228eb7b
4 измененных файлов с 55 добавлено и 32 удалено
  1. 2 0
      debian/changelog
  2. 41 1
      scripts/Dpkg/BuildProfiles.pm
  3. 2 29
      scripts/Dpkg/Deps.pm
  4. 10 2
      scripts/dpkg-genchanges.pl

+ 2 - 0
debian/changelog

@@ -70,6 +70,8 @@ dpkg (1.17.14) UNRELEASED; urgency=low
     - On systems using libkvm, do not fail when kvm_getprocs() cannot find
       any process.
   * Map i786 to i386 also for the multiarch pathname in dpkg-architecture.
+  * Handle omitted binary packages due to build profiles in dpkg-genchanges.
+    Based on a patch by Johannes Schauer <j.schauer@email.de>. Closes: #758191
 
   [ Raphaël Hertzog ]
   * Explain better in deb-triggers(5) why interest/activate-noawait should be

+ 41 - 1
scripts/Dpkg/BuildProfiles.pm

@@ -19,7 +19,8 @@ use strict;
 use warnings;
 
 our $VERSION = '0.01';
-our @EXPORT_OK = qw(get_build_profiles set_build_profiles parse_build_profiles);
+our @EXPORT_OK = qw(get_build_profiles set_build_profiles parse_build_profiles
+                    evaluate_restriction_formula);
 
 use Exporter qw(import);
 
@@ -87,6 +88,45 @@ sub parse_build_profiles {
     return map { lc } split /\s+/, $string;
 }
 
+=item evaluate_restriction_formula(\@formula, \@profiles)
+
+Evaluate whether a restriction list, is true or false, given the array of
+enabled build profiles.
+
+=cut
+
+sub evaluate_restriction_formula {
+    my ($restrictions, $build_profiles) = @_;
+
+    my $seen_profile = 0;
+    foreach my $restriction (@{$restrictions}) {
+        # Determine if this restriction is negated, and within the "profile"
+        # namespace, otherwise it does not concern this check.
+        next if $restriction !~ m/^(!)?profile\.(.*)/;
+
+        my $negated = defined $1 && $1 eq '!';
+        my $profile = $2;
+
+        # Determine if the restriction matches any of the specified profiles.
+        my $found = any { $_ eq $profile } @{$build_profiles};
+
+        if ($negated) {
+            if ($found) {
+                $seen_profile = 0;
+                last;
+            } else {
+                # "!profile.this" includes by default all other profiles
+                # unless they also appear in a "!profile.other".
+                $seen_profile = 1;
+            }
+        } elsif ($found) {
+            $seen_profile = 1;
+            last;
+        }
+    }
+    return $seen_profile;
+}
+
 =back
 
 =cut

+ 2 - 29
scripts/Dpkg/Deps.pm

@@ -541,7 +541,7 @@ use warnings;
 use Carp;
 
 use Dpkg::Arch qw(debarch_is);
-use Dpkg::BuildProfiles qw(parse_build_profiles);
+use Dpkg::BuildProfiles qw(parse_build_profiles evaluate_restriction_formula);
 use Dpkg::Version;
 use Dpkg::ErrorHandling;
 use Dpkg::Gettext;
@@ -857,34 +857,7 @@ sub profile_is_concerned {
 
     return 0 if not defined $self->{package}; # Empty dep
     return 1 if not defined $self->{restrictions}; # Dep without restrictions
-
-    my $seen_profile = 0;
-    foreach my $restriction (@{$self->{restrictions}}) {
-        # Determine if this restriction is negated, and within the "profile"
-        # namespace, otherwise it does not concern this check.
-        next if $restriction !~ m/^(!)?profile\.(.*)/;
-
-        my $negated = defined $1 && $1 eq '!';
-        my $profile = $2;
-
-        # Determine if the restriction matches any of the specified profiles.
-        my $found = any { $_ eq $profile } @{$build_profiles};
-
-        if ($negated) {
-            if ($found) {
-                $seen_profile = 0;
-                last;
-            } else {
-                # "!profile.this" includes by default all other profiles
-                # unless they also appear in a "!profile.other".
-                $seen_profile = 1;
-            }
-        } elsif ($found) {
-            $seen_profile = 1;
-            last;
-        }
-    }
-    return $seen_profile;
+    return evaluate_restriction_formula($self->{restrictions}, $build_profiles);
 }
 
 sub reduce_profiles {

+ 10 - 2
scripts/dpkg-genchanges.pl

@@ -53,6 +53,7 @@ my $uploadfilesdir = '..';
 my $sourcestyle = 'i';
 my $quiet = 0;
 my $host_arch = get_host_arch();
+my @profiles = get_build_profiles();
 my $changes_format = '1.8';
 
 my %p2f;           # - package to file map, has entries for "packagename"
@@ -346,6 +347,7 @@ if ($include & BUILD_BINARY) {
 foreach my $pkg ($control->get_packages()) {
     my $p = $pkg->{'Package'};
     my $a = $pkg->{'Architecture'} // '';
+    my $bp = $pkg->{'Build-Profiles'};
     my $d = $pkg->{'Description'} || 'no description available';
     $d = $1 if $d =~ /^(.*)\n/;
     my $pkg_type = $pkg->{'Package-Type'} ||
@@ -359,11 +361,17 @@ foreach my $pkg ($control->get_packages()) {
     $desc .= ' (udeb)' if $pkg_type eq 'udeb';
     push @descriptions, $desc;
 
+    my @restrictions;
+    @restrictions = parse_build_profiles($bp) if defined $bp;
+
     if (not defined($p2f{$p})) {
 	# No files for this package... warn if it's unexpected
-	if ((debarch_eq('all', $a) and ($include & BUILD_ARCH_INDEP)) ||
+	if (((debarch_eq('all', $a) and ($include & BUILD_ARCH_INDEP)) ||
 	    ((any { debarch_is($host_arch, $_) } split /\s+/, $a)
-		  and ($include & BUILD_ARCH_DEP))) {
+		  and ($include & BUILD_ARCH_DEP))) and
+	    (@restrictions == 0 or
+	     evaluate_restriction_formula(\@restrictions, \@profiles)))
+	{
 	    warning(_g('package %s in control file but not in files list'),
 		    $p);
 	}