Package: dpkg
Version: 1.14.7
Followup-For: Bug #398625

Hi,

I have written a new implementation of the patch proposed earlier,
against the current shell script.

This patch tries to address all the concerns raised so far, however it
introduces some ugliness in doing so: behaviour depends on the system
clock.

Basically, what this patch does: if -B was used, it will attempt to use
the "build-arch" target. if that fails, and either -nc was set or it
took longer than 300 seconds to fail, the build is aborted there,
otherwise, the tree is cleaned and the build retried with the "build"
target.

Rationale: if it takes longer than 300 seconds for the package to find
out whether it has a "build-arch" target or not, the situation is FUBAR
anyway. Either the package build scripts are horribly broken, or the
machine is completely overloaded -- in neither case it makes real sense
to continue here. This does, however, solve the problem where a package
takes long to build in the build-arch target and fails later -- those
builds should not be retried -- and where a package does not have a
"build-arch" target -- these should. As (hopefully) many packages start
implementing these currently optional targets, the number of "normal"
FTBFS cases is high enough that we don't want to waste autobuilder time
on trying these packages twice.

A special string "I: optional-target-failed" followed by the name of the
target is output if the build is being retried -- this will allow
generating a database of packages that do not have the optional targets,
so interested individuals can contribute patches.

   Simon

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: powerpc (ppc)

Kernel: Linux 2.6.20-1-vserver-powerpc (SMP w/1 CPU core)
Locale: LANG=ja_JP.UTF-8, LC_CTYPE=ja_JP.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages dpkg depends on:
ii  coreutils                     5.97-5.4   The GNU core utilities
ii  libc6                         2.6.1-6    GNU C Library: Shared libraries

dpkg recommends no packages.

-- no debconf information
--- scripts/dpkg-buildpackage.pl.orig   2007-10-08 06:12:43.000000000 +0200
+++ scripts/dpkg-buildpackage.pl        2007-11-04 14:18:31.000000000 +0100
@@ -102,6 +102,7 @@
 my $signsource = 1;
 my $signchanges = 1;
 my $diffignore = '';
+my $buildtarget = 'build';
 my $binarytarget = 'binary';
 my $targetarch = my $targetgnusystem = '';
 
@@ -160,6 +161,7 @@
     } elsif (/^-b$/) {
        $binaryonly = '-b';
        @checkbuilddep_args = ();
+       $buildtarget = 'build-arch';
        $binarytarget = 'binary';
        if ($sourceonly) {
            usageerr(sprintf(_g("cannot combine %s and %s"), '-b', '-S'));
@@ -167,6 +169,7 @@
     } elsif (/^-B$/) {
        $binaryonly = '-B';
        @checkbuilddep_args = ('-B');
+       $buildtarget = 'build-arch';
        $binarytarget = 'binary-arch';
        if ($sourceonly) {
            usageerr(sprintf(_g("cannot combine %s and %s"), '-B', '-S'));
@@ -365,7 +368,30 @@
     chdir($dir) or failure("chdir $dir");
 }
 unless ($sourceonly) {
-    withecho('debian/rules', 'build');
+    # This handles the (currently) optional build targets. In case they ever
+    # become mandatory, replace this entire "if" block with the "else" branch.
+    # The timeout is ugly -- but it will stop packages that have the optional
+    # target but fail to build from wasting more than five minutes of
+    # autobuilder time -- and honestly, if a package takes five minutes to
+    # find out that it actually does not have an optional target, failing to
+    # build once is the least of its problems.
+    if($buildtarget ne 'build') {
+        my $starttime = time;
+        eval { withecho('debian/rules', $buildtarget); };
+       my $stoptime = time;
+        if($@) {
+           if($noclean || (($stoptime - $starttime) > 300))
+            {
+                die "$@";
+            }
+            print "[EMAIL PROTECTED]";
+            print "I: optional-target-failed $buildtarget\n";
+            withecho($rootcommand, 'debian/rules', 'clean');
+            withecho('debian/rules', 'build');
+        }
+    } else {
+        withecho('debian/rules', $buildtarget);
+    }
     withecho($rootcommand, 'debian/rules', $binarytarget);
 }
 if ($usepause &&

Reply via email to