[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: draft ballot: please rule on how to implement debian/rules build-arch

On Fri, 27 Jan 2012, Guillem Jover wrote:
> >     This fallback is a temporary measure until all packages have been
> >     converted to properly support the build-arch and build-indep targets.
> Actually thinking about this, making this temporary will imply that
> once this would get removed old/external packages would stop building
> which is not acceptable. So I think we might need to carry this for
> quite some time (if not indefinitely).

IIRC you said before that a solution involving a flag day was ok for you.
And now you care about compatibility of old/external packages? :-)

In any case, I really care about this being temporary because, as we
saw, the make -qn call can have undesired side effects and I don't want
to keep this source of problem indefinitely.

I have no problem to keep it for very long, but I would like to document
it as temporary (or, what I considered initially, not document the
existence of this kludge at all).

> In any case, looks good, thanks! So, besides those comments:

Thanks for the review. I fixed everything except the documentation 
about the temporary nature of this work-around.

Updated patch attached.

Raphaël Hertzog ◈ Debian Developer

Pre-order a copy of the Debian Administrator's Handbook and help
liberate it: http://debian-handbook.info/liberation/
commit e9290bdc4a488c685f253e63073f27f2bf2f7a34
Author: Raphaël Hertzog <hertzog@debian.org>
Date:   Tue Jan 24 11:59:44 2012 +0100

    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>

diff --git a/man/dpkg-buildpackage.1 b/man/dpkg-buildpackage.1
index 5410a20..a28826e 100644
--- a/man/dpkg-buildpackage.1
+++ b/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
 .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
-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
 It calls \fBgpg\fP to sign the \fB.dsc\fP file (if any, unless
 \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
 by \fBdpkg\-buildflags\fP. This is no longer the case.
+\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.
 It should be possible to specify spaces and shell metacharacters in
 and initial arguments for
@@ -261,7 +269,7 @@ Copyright \(co 2000 Wichert Akkerman
 Copyright \(co 2007 Frank Lichtenheld
-Copyright \(co 2008-2010 Rapha\[:e]l Hertzog
+Copyright \(co 2008-2012 Rapha\[:e]l Hertzog
 This is free software; see the GNU General Public Licence version 2 or later
 for copying conditions. There is NO WARRANTY.
diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl
index 50e6170..2a36308 100755
--- a/scripts/dpkg-buildpackage.pl
+++ b/scripts/dpkg-buildpackage.pl
@@ -30,6 +30,7 @@ use Dpkg::Compression;
 use Dpkg::Version;
 use Dpkg::Changelog::Parse;
 use Dpkg::Path qw(find_command);
+use Dpkg::IPC;
@@ -117,6 +118,7 @@ my ($admindir, $signkey, $forcesigninterface, $usepause, $noclean,
 my $checkbuilddep = 1;
 my $signsource = 1;
 my $signchanges = 1;
+my $buildtarget = 'build';
 my $binarytarget = 'binary';
 my $targetarch = my $targetgnusystem = '';
 my $call_target = '';
@@ -201,18 +203,21 @@ while (@ARGV) {
 	$include = BUILD_BINARY;
 	push @changes_opts, '-b';
 	@checkbuilddep_opts = ();
+	$buildtarget = 'build';
 	$binarytarget = 'binary';
     } elsif (/^-B$/) {
 	build_sourceonly && usageerr(_g("cannot combine %s and %s"), $_, "-S");
 	$include = BUILD_ARCH_DEP;
 	push @changes_opts, '-B';
 	@checkbuilddep_opts = ('-B');
+	$buildtarget = 'build-arch';
 	$binarytarget = 'binary-arch';
     } elsif (/^-A$/) {
 	build_sourceonly && usageerr(_g("cannot combine %s and %s"), $_, "-S");
 	$include = BUILD_ARCH_INDEP;
 	push @changes_opts, '-A';
 	@checkbuilddep_opts = ();
+	$buildtarget = 'build-indep';
 	$binarytarget = 'binary-indep';
     } elsif (/^-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);
     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) {
-    withecho(@debian_rules, 'build');
+    withecho(@debian_rules, $buildtarget);
     withecho(@rootcommand, @debian_rules, $binarytarget);
 if ($usepause &&

Reply to: