Przeglądaj źródła

dpkg-buildpackage: use build-arch and build-indep targets of debian/rules

'build-arch' is used when building only arch-any binaries (-B)
while 'build-indep' is used when building only arch-all binaries (-A).
To avoid breaking too many packages, dpkg-buildpackages verifies that
those targets are implemented by calling “make -f debian/rules -qn
<target>” and ensuring that it doesn't fail with exit code 2. Otherwise
it falls back to using the 'build' target.

This fallback is a temporary measure until all packages have been
converted to properly support the build-arch and build-indep targets.

Acked-by: Guillem Jover <guillem@debian.org>
Raphaël Hertzog 14 lat temu
rodzic
commit
2b6e4e5f26
3 zmienionych plików z 42 dodań i 7 usunięć
  1. 3 0
      debian/changelog
  2. 14 6
      man/dpkg-buildpackage.1
  3. 25 1
      scripts/dpkg-buildpackage.pl

+ 3 - 0
debian/changelog

@@ -89,6 +89,9 @@ dpkg (1.16.2) UNRELEASED; urgency=low
   * Drop misleading spaces in deb-symbols(5) in the format description.
   * Drop misleading spaces in deb-symbols(5) in the format description.
   * Clean up dpkg-architecture(1) dropping useless information and
   * Clean up dpkg-architecture(1) dropping useless information and
     adding a reference to /usr/share/dpkg/architecture.mk.
     adding a reference to /usr/share/dpkg/architecture.mk.
+  * Update dpkg-buildpackage to use the "build-arch" (for -B) and
+    "build-indep" (for -A) targets unless "make -qn" says that they do not
+    exist. Closes: #229357
 
 
   [ Jonathan Nieder ]
   [ Jonathan Nieder ]
   * Bump po4a version in Build-Depends to 0.41, since earlier versions do
   * Bump po4a version in Build-Depends to 0.41, since earlier versions do

+ 14 - 6
man/dpkg-buildpackage.1

@@ -27,12 +27,13 @@ It calls \fBdpkg\-source \-b\fP to generate the source package (unless
 a binary\-only build has been requested with \fB\-b\fP, \fB\-B\fP or
 a binary\-only build has been requested with \fB\-b\fP, \fB\-B\fP or
 \fB\-A\fP).
 \fB\-A\fP).
 .IP \fB5.\fP 3
 .IP \fB5.\fP 3
-It calls \fBdebian/rules\fP \fBbuild\fP followed by
+It calls \fBdebian/rules\fP \fIbuild-target\fP followed by
 \fBfakeroot debian/rules\fP \fIbinary-target\fP (unless a source-only
 \fBfakeroot debian/rules\fP \fIbinary-target\fP (unless a source-only
-build has been requested with \fB\-S\fP). Note that \fIbinary-target\fR is
-either \fBbinary\fP (default case, or if \fB\-b\fP is specified)
-or \fBbinary\-arch\fP (if \fB\-B\fP is specified) or \fBbinary\-indep\fP
-(if \fB\-A\fP is specified).
+build has been requested with \fB\-S\fP). Note that \fIbuild-target\fR
+and \fIbinary-target\fP are either \fBbuild\fP and \fBbinary\fP (default
+case, or if \fB\-b\fP is specified), or \fBbuild\-arch\fP and
+\fBbinary\-arch\fP (if \fB\-B\fP is specified), or \fBbuild\-indep\fP and
+\fBbinary\-indep\fP (if \fB\-A\fP is specified).
 .IP \fB6.\fP 3
 .IP \fB6.\fP 3
 It calls \fBgpg\fP to sign the \fB.dsc\fP file (if any, unless
 It calls \fBgpg\fP to sign the \fB.dsc\fP file (if any, unless
 \fB\-us\fP is specified).
 \fB\-us\fP is specified).
@@ -241,6 +242,13 @@ exported compiler flags (\fBCFLAGS\fP, \fBCXXFLAGS\fP, \fBFFLAGS\fP,
 \fBCPPFLAGS\fP and \fBLDFLAGS\fP) with values as returned
 \fBCPPFLAGS\fP and \fBLDFLAGS\fP) with values as returned
 by \fBdpkg\-buildflags\fP. This is no longer the case.
 by \fBdpkg\-buildflags\fP. This is no longer the case.
 .
 .
+.SH BACKWARD COMPATIBILITY
+\fBdpkg\-buildpackage\fP is using the \fBbuild\-arch\fP and
+\fBbuild\-indep\fP targets since version 1.16.2. Those targets are thus
+mandatory. But to avoid breakages of existing packages, and ease
+the transition, it will fallback to using the \fBbuild\fP target
+if \fBmake \-f debian/rules \-qn\fP \fIbuild-target\fP returns 2 as
+exit code.
 .SH BUGS
 .SH BUGS
 It should be possible to specify spaces and shell metacharacters in
 It should be possible to specify spaces and shell metacharacters in
 and initial arguments for
 and initial arguments for
@@ -261,7 +269,7 @@ Copyright \(co 2000 Wichert Akkerman
 .br
 .br
 Copyright \(co 2007 Frank Lichtenheld
 Copyright \(co 2007 Frank Lichtenheld
 .br
 .br
-Copyright \(co 2008-2010 Rapha\[:e]l Hertzog
+Copyright \(co 2008-2012 Rapha\[:e]l Hertzog
 .sp
 .sp
 This is free software; see the GNU General Public Licence version 2 or later
 This is free software; see the GNU General Public Licence version 2 or later
 for copying conditions. There is NO WARRANTY.
 for copying conditions. There is NO WARRANTY.

+ 25 - 1
scripts/dpkg-buildpackage.pl

@@ -30,6 +30,7 @@ use Dpkg::Compression;
 use Dpkg::Version;
 use Dpkg::Version;
 use Dpkg::Changelog::Parse;
 use Dpkg::Changelog::Parse;
 use Dpkg::Path qw(find_command);
 use Dpkg::Path qw(find_command);
+use Dpkg::IPC;
 
 
 textdomain("dpkg-dev");
 textdomain("dpkg-dev");
 
 
@@ -117,6 +118,7 @@ my ($admindir, $signkey, $forcesigninterface, $usepause, $noclean,
 my $checkbuilddep = 1;
 my $checkbuilddep = 1;
 my $signsource = 1;
 my $signsource = 1;
 my $signchanges = 1;
 my $signchanges = 1;
+my $buildtarget = 'build';
 my $binarytarget = 'binary';
 my $binarytarget = 'binary';
 my $targetarch = my $targetgnusystem = '';
 my $targetarch = my $targetgnusystem = '';
 my $call_target = '';
 my $call_target = '';
@@ -201,18 +203,21 @@ while (@ARGV) {
 	$include = BUILD_BINARY;
 	$include = BUILD_BINARY;
 	push @changes_opts, '-b';
 	push @changes_opts, '-b';
 	@checkbuilddep_opts = ();
 	@checkbuilddep_opts = ();
+	$buildtarget = 'build';
 	$binarytarget = 'binary';
 	$binarytarget = 'binary';
     } elsif (/^-B$/) {
     } elsif (/^-B$/) {
 	build_sourceonly && usageerr(_g("cannot combine %s and %s"), $_, "-S");
 	build_sourceonly && usageerr(_g("cannot combine %s and %s"), $_, "-S");
 	$include = BUILD_ARCH_DEP;
 	$include = BUILD_ARCH_DEP;
 	push @changes_opts, '-B';
 	push @changes_opts, '-B';
 	@checkbuilddep_opts = ('-B');
 	@checkbuilddep_opts = ('-B');
+	$buildtarget = 'build-arch';
 	$binarytarget = 'binary-arch';
 	$binarytarget = 'binary-arch';
     } elsif (/^-A$/) {
     } elsif (/^-A$/) {
 	build_sourceonly && usageerr(_g("cannot combine %s and %s"), $_, "-S");
 	build_sourceonly && usageerr(_g("cannot combine %s and %s"), $_, "-S");
 	$include = BUILD_ARCH_INDEP;
 	$include = BUILD_ARCH_INDEP;
 	push @changes_opts, '-A';
 	push @changes_opts, '-A';
 	@checkbuilddep_opts = ();
 	@checkbuilddep_opts = ();
+	$buildtarget = 'build-indep';
 	$binarytarget = 'binary-indep';
 	$binarytarget = 'binary-indep';
     } elsif (/^-S$/) {
     } elsif (/^-S$/) {
 	build_binaryonly && usageerr(_g("cannot combine %s and %s"), build_opt, "-S");
 	build_binaryonly && usageerr(_g("cannot combine %s and %s"), build_opt, "-S");
@@ -393,8 +398,27 @@ unless (build_binaryonly) {
     withecho('dpkg-source', @source_opts, '-b', $dir);
     withecho('dpkg-source', @source_opts, '-b', $dir);
     chdir($dir) or syserr("chdir $dir");
     chdir($dir) or syserr("chdir $dir");
 }
 }
+
+unless ($buildtarget eq "build" or scalar(@debian_rules) > 1) {
+    # Verify that build-{arch,indep} are supported. If not, fallback to build.
+    # This is a temporary measure to not break too many packages on a flag day.
+    my $pid = spawn(exec => [ "make", "-f", @debian_rules, "-qn", $buildtarget ],
+                    from_file => "/dev/null", to_file => "/dev/null",
+                    error_to_file => "/dev/null");
+    my $cmdline = "make -f @debian_rules -qn $buildtarget";
+    wait_child($pid, nocheck => 1, cmdline => $cmdline);
+    my $exitcode = WEXITSTATUS($?);
+    subprocerr($cmdline) unless WIFEXITED($?);
+    if ($exitcode == 2) {
+        warning(_g("%s must be updated to support the 'build-arch' and " .
+                   "'build-indep' targets (at least '%s' seems to be " .
+                   "missing)"), "@debian_rules", $buildtarget);
+        $buildtarget = "build";
+    }
+}
+
 unless (build_sourceonly) {
 unless (build_sourceonly) {
-    withecho(@debian_rules, 'build');
+    withecho(@debian_rules, $buildtarget);
     withecho(@rootcommand, @debian_rules, $binarytarget);
     withecho(@rootcommand, @debian_rules, $binarytarget);
 }
 }
 if ($usepause &&
 if ($usepause &&