Package: dpkg
Version: 1.16.0.3
Severity: normal
Tags: patch

dpkg currently supports

  Build-Depends (arch all and any)
  Build-Depends-Indep (arch all)

and the same Build-Conflicts.

This patch adds

  Build-Depends-Arch (arch any)

and Build-Conflicts-Arch.


This makes the support for build dependencies for arch all and any
packages symmetrical and more logical.  It also permits arch-any
dependencies to be omitted for arch-any-only builds.

This change will not break any existing packages: if the arch any
deps are in Build-Depends, they may be installed unnecessarily,
but they will still be installed.  This change just allows an
additional optimisation.


This change relates to the discussion of build-arch and build-indep
currently on -policy and -ctte.  While this isn't required for
implementing build-arch and build-indep, it does tidy up a slight
omission in the original implementation of build dependencies, and
would give the buildds additional options when arch-all autobuilding
is enabled (especially now it's available as a separate independent
arch).

If this change is suitable, I'll make the corresponding changes in
sbuild and wanna-build, and then in Policy.


Regards,
Roger

-- System Information:
Debian Release: 6.0.1
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.32.27-kvm-i386-20110114 (SMP w/1 CPU core)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
>From 150ab538bb7477b5adfe29383ef816d01d1de6ed Mon Sep 17 00:00:00 2001
From: Roger Leigh <rle...@debian.org>
Date: Tue, 7 Jun 2011 00:02:03 +0100
Subject: [PATCH] Add Build-Depends-Arch and Build-Conflicts-Arch

Signed-off-by: Roger Leigh <rle...@debian.org>
---
 man/deb-src-control.5          |   24 +++++++++++++++++++-----
 man/dpkg-checkbuilddeps.1      |    4 ++++
 scripts/Dpkg/Control/Fields.pm |   10 ++++++++++
 scripts/dpkg-checkbuilddeps.pl |   19 ++++++++++++++++---
 scripts/dpkg-source.pl         |    2 +-
 5 files changed, 50 insertions(+), 9 deletions(-)

diff --git a/man/deb-src-control.5 b/man/deb-src-control.5
index 94a0aa4..d780f66 100644
--- a/man/deb-src-control.5
+++ b/man/deb-src-control.5
@@ -115,7 +115,13 @@ or \fIbuild-indep\fP targets in place of \fIbuild\fP.
 .TP
 .BR Build\-Depends: " <package list>"
 A list of packages that need to be installed and configured to be able to build
-the source package.
+the source package (both architecture dependent and independent packages).
+
+.TP
+.BR Build\-Depends\-Arch: " <package list>"
+Same as Build\-Depends, but they are only needed when building the
+architecture dependent packages. The Build\-Depends are also installed
+in this case.
 
 .TP
 .BR Build\-Depends\-Indep: " <package list>"
@@ -125,8 +131,14 @@ in this case.
 
 .TP
 .BR Build\-Conflicts: " <package list>"
-A list of packages that should not be installed when the package is build, for
-example because they interfere with the used build system.
+A list of packages that should not be installed when the package is built, for
+example because they interfere with the used build system (both
+architecture dependent and independent packages).
+
+.TP
+.BR Build\-Conflicts\-Arch: " <package list>"
+Same as Build\-Conflicts, but only when building the architecture dependent
+packages.
 
 .TP
 .BR Build\-Conflicts\-Indep: " <package list>"
@@ -134,7 +146,8 @@ Same as Build\-Conflicts, but only when building the 
architecture independent
 packages.
 
 The syntax of the
-.B Build\-Depends
+.BR Build\-Depends ,
+.B Build\-Depends\-Arch
 and
 .B Build\-Depends\-Indep
 fields is a list of groups of alternative packages. Each group is a list
@@ -145,7 +158,8 @@ optionally followed by a version number specification in 
parentheses and an
 architecture specification in square brackets.
 
 The syntax of the
-.B Build\-Conflicts
+.BR Build\-Conflicts ,
+.B Build\-Conflicts\-Arch
 and
 .B Build\-Conflicts\-Indep
 fields is a list of comma-separated package names, where the comma is read
diff --git a/man/dpkg-checkbuilddeps.1 b/man/dpkg-checkbuilddeps.1
index 1ac3bad..2afb5e6 100644
--- a/man/dpkg-checkbuilddeps.1
+++ b/man/dpkg-checkbuilddeps.1
@@ -21,6 +21,10 @@ may be specified on the command line.
 Change the location of the \fBdpkg\fR database. The default location is
 \fI/var/lib/dpkg\fP.
 .TP
+.B \-A
+Ignore \fIBuild\-Depends\-Arch\fR lines. Use when no arch-dep packages will
+be built.
+.TP
 .B \-B
 Ignore \fIBuild\-Depends\-Indep\fR lines. Use when no arch-indep packages will
 be built.
diff --git a/scripts/Dpkg/Control/Fields.pm b/scripts/Dpkg/Control/Fields.pm
index 0183281..8622684 100644
--- a/scripts/Dpkg/Control/Fields.pm
+++ b/scripts/Dpkg/Control/Fields.pm
@@ -63,6 +63,11 @@ our %FIELDS = (
         dependency => 'union',
         dep_order => 3,
     },
+    'Build-Conflicts-Arch' => {
+        allowed => ALL_SRC,
+        dependency => 'union',
+        dep_order => 4,
+    },
     'Build-Conflicts-Indep' => {
         allowed => ALL_SRC,
         dependency => 'union',
@@ -73,6 +78,11 @@ our %FIELDS = (
         dependency => 'normal',
         dep_order => 1,
     },
+    'Build-Depends-Arch' => {
+        allowed => ALL_SRC,
+        dependency => 'normal',
+        dep_order => 2,
+    },
     'Build-Depends-Indep' => {
         allowed => ALL_SRC,
         dependency => 'normal',
diff --git a/scripts/dpkg-checkbuilddeps.pl b/scripts/dpkg-checkbuilddeps.pl
index 31b7ee6..9750649 100755
--- a/scripts/dpkg-checkbuilddeps.pl
+++ b/scripts/dpkg-checkbuilddeps.pl
@@ -42,6 +42,7 @@ sub usage {
 "Usage: %s [<option>...] [<control-file>]")
        . "\n\n" . _g(
 "Options:
+  -A             all-only, ignore -Arch.
   -B             binary-only, ignore -Indep.
   -d build-deps  use given string as build dependencies instead of
                  retrieving them from control file
@@ -56,9 +57,11 @@ sub usage {
        . "\n", $progname;
 }
 
+my $all_only=0;
 my $binary_only=0;
 my ($bd_value, $bc_value);
-if (!GetOptions('B' => \$binary_only,
+if (!GetOptions('A' => \$all_only,
+               'B' => \$binary_only,
                 'help|h' => sub { usage(); exit(0); },
                 'version' => \&version,
                 'd=s' => \$bd_value,
@@ -78,10 +81,20 @@ my $facts = parse_status("$admindir/status");
 unless (defined($bd_value) or defined($bc_value)) {
     $bd_value = 'build-essential';
     $bd_value .= ", " . $fields->{"Build-Depends"} if defined 
$fields->{"Build-Depends"};
+    if (not $all_only and defined $fields->{"Build-Depends-Arch"}) {
+       $bd_value .= ", " . $fields->{"Build-Depends-Arch"};
+    }
     if (not $binary_only and defined $fields->{"Build-Depends-Indep"}) {
        $bd_value .= ", " . $fields->{"Build-Depends-Indep"};
     }
     $bc_value = $fields->{"Build-Conflicts"} if defined 
$fields->{"Build-Conflicts"};
+    if (not $all_only and defined $fields->{"Build-Conflicts-Arch"}) {
+       if ($bc_value) {
+           $bc_value .= ", " . $fields->{"Build-Conflicts-Arch"};
+       } else {
+           $bc_value = $fields->{"Build-Conflicts-Arch"};
+       }
+    }
     if (not $binary_only and defined $fields->{"Build-Conflicts-Indep"}) {
        if ($bc_value) {
            $bc_value .= ", " . $fields->{"Build-Conflicts-Indep"};
@@ -93,11 +106,11 @@ unless (defined($bd_value) or defined($bc_value)) {
 my (@unmet, @conflicts);
 
 if ($bd_value) {
-       push @unmet, build_depends('Build-Depends/Build-Depends-Indep)',
+       push @unmet, 
build_depends('Build-Depends/Build-Depends-Arch/Build-Depends-Indep)',
                deps_parse($bd_value, reduce_arch => 1), $facts);
 }
 if ($bc_value) {
-       push @conflicts, 
build_conflicts('Build-Conflicts/Build-Conflicts-Indep',
+       push @conflicts, 
build_conflicts('Build-Conflicts/Build-Conflicts-Arch/Build-Conflicts-Indep',
                deps_parse($bc_value, reduce_arch => 1, union => 1), $facts);
 }
 
diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl
index 8d23806..f37532b 100755
--- a/scripts/dpkg-source.pl
+++ b/scripts/dpkg-source.pl
@@ -232,7 +232,7 @@ if ($options{'opmode'} =~ 
/^(-b|--print-format|--(before|after)-build)$/) {
            $fields->{$_} = $v;
        } elsif (m/^Uploaders$/i) {
            ($fields->{$_} = $v) =~ s/\s*[\r\n]\s*/ /g; # Merge in a single-line
-       } elsif (m/^Build-(Depends|Conflicts)(-Indep)?$/i) {
+       } elsif (m/^Build-(Depends|Conflicts)(-Arch|-Indep)?$/i) {
            my $dep;
            my $type = field_get_dep_type($_);
            $dep = deps_parse($v, union => $type eq 'union');
-- 
1.7.5.3

Reply via email to