[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



Hi,

On Fri, 20 Jan 2012, Guillem Jover wrote:
> I think I've stated my take on this at least in #604397. In any case
> I'm fine with mostly any solution ranging (in no particular order)
> from a global activation of the targets on a flag day to incremental
> activation depending on the Build-Depends(-Indep) fields, to
> autodetection heuristics, or combinations of those, as long as any
> such temporary hack is confined to dpkg itself. But certainly I'm not
> fine with a Build-Options/Build-Features kind of field solution that
> percolates into packages, when they should just be fixed to support
> build-arch/build-indep.
[...]
> In any case I don't think I've ever opposed «make -qn», all the
> contrary!

Ok, then I suggest to go ahead with the attached patch. If I don't hear
any objections, I'll push it later this week.

This one uses build-arch/build-indep by default but falls back to build
if "make -qn" says the target is not supported.

The number of packages broken by this change is relatively small according
to the rebuilds of Roger (~100 out of all the arch-any packages, probably
twice that big if we include arch-all packages). And this number might
have decreased since the tests given that lintian has been advising
maintainers to add the build-arch/build-indep targets. 

This means that build-arch/build-indep ought to be mandatory for all
packages from now on.

(We could have argued to use build-arch/build-indep only for packages
which build both arch any&all binaries but that would create an assymetry
with the way the binary target is handled and IMO it's best avoided)

> > least allow some progress to be made.  It would only need to be
> > there until the release of wheezy.

I think you're rather optimistic, this transition will not be completed
before the release of wheezy.

Cheers,
-- 
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 557b5809eef183da2e4907e994dabaa9273e7e0b
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 fallsback 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.

diff --git a/man/dpkg-buildpackage.1 b/man/dpkg-buildpackage.1
index 5410a20..f7d1cf1 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
 \fB\-A\fP).
 .IP \fB5.\fP 3
-It calls \fBdebian/rules\fP \fBbuild\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).
+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 \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.
 .
+.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
 It should be possible to specify spaces and shell metacharacters in
 and initial arguments for
@@ -261,7 +269,7 @@ Copyright \(co 2000 Wichert Akkerman
 .br
 Copyright \(co 2007 Frank Lichtenheld
 .br
-Copyright \(co 2008-2010 Rapha\[:e]l Hertzog
+Copyright \(co 2008-2012 Rapha\[:e]l Hertzog
 .sp
 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..e1dd538 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;
 
 textdomain("dpkg-dev");
 
@@ -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");
@@ -385,6 +390,7 @@ if ($call_target) {
 unless ($noclean) {
     withecho(@rootcommand, @debian_rules, 'clean');
 }
+
 unless (build_binaryonly) {
     warning(_g("it is a bad idea to generate a source package " .
                "without cleaning up first, it might contain undesired " .
@@ -393,10 +399,30 @@ 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 avoid breaking 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 &&
     ($signchanges || (!build_binaryonly && $signsource))) {
     print _g("Press the return key to start signing process\n");

Reply to: