Author: adam-guest
Date: 2008-03-10 21:27:12 +0000 (Mon, 10 Mar 2008)
New Revision: 1119
Modified:
trunk/debian/changelog
trunk/scripts/debuild.pl
Log:
debuild: Add working -j / DEB_BUILD_OPTS=parallel support
(Finally closes: #457235)
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2008-03-09 01:59:01 UTC (rev 1118)
+++ trunk/debian/changelog 2008-03-10 21:27:12 UTC (rev 1119)
@@ -53,6 +53,8 @@
+ Print a warning about unrecognised keys passed to select()
+ Add on_fault handlers to SOAP calls so we can return useful error
messages
+ * debuild: Add working -j / DEB_BUILD_OPTS=parallel support
+ (Finally closes: #457235)
-- Adam D. Barratt <[EMAIL PROTECTED]> Sat, 01 Mar 2008 11:42:02 +0000
Modified: trunk/scripts/debuild.pl
===================================================================
--- trunk/scripts/debuild.pl 2008-03-09 01:59:01 UTC (rev 1118)
+++ trunk/scripts/debuild.pl 2008-03-10 21:27:12 UTC (rev 1119)
@@ -752,6 +752,7 @@
my $since='';
my $maint='';
my $desc='';
+ my $parallel='';
my $noclean=0;
my $usepause=0;
my $warnable_error=0; # OK, dpkg-buildpackage defines this but doesn't
@@ -808,7 +809,7 @@
/^-e(.*)/ and $changedby=$1, push(@debsign_opts, $_),
push(@dpkg_opts, $_), next;
/^-C(.*)/ and $desc=$1, push(@dpkg_opts, $_), next;
- /^-j(.*)/ and push(@dpkg_opts, $_), next;
+ /^-j(\d*)$/ and $parallel=($1 || '-1'), push(@dpkg_opts, $_), next;
$_ eq '-W' and $warnable_error=1, push(@passopts, $_),
push(@dpkg_opts, $_), next;
$_ eq '-E' and $warnable_error=0, push(@passopts, $_),
@@ -850,7 +851,7 @@
/^-e(.*)/ and $changedby=$1, push(@debsign_opts, $_),
push(@dpkg_opts, $_), next;
/^-C(.*)/ and $desc=$1, push(@dpkg_opts, $_), next;
- /^-j(.*)/ and push(@dpkg_opts, $_), next;
+ /^-j(\d*)$/ and $parallel=($1 || '-1'), push(@dpkg_opts, $_), next;
$_ eq '-W' and $warnable_error=1, push(@passopts, $_),
push(@dpkg_opts, $_), next;
$_ eq '-E' and $warnable_error=0, push(@passopts, $_),
@@ -997,7 +998,7 @@
} else {
# Not using dpkg-cross, so we emulate dpkg-buildpackage ourselves
# We emulate the version found in dpkg-buildpackage-snapshot in
- # the source package
+ # the source package with the addition of -j support
# First dpkg-buildpackage action: run dpkg-checkbuilddeps
if ($checkbuilddep) {
@@ -1047,6 +1048,24 @@
run_hook('build', ! $sourceonly);
+ # From dpkg-buildpackage 1.14.15
+ if ($parallel) {
+ my $build_opts = parsebuildopts();
+
+ $parallel = $build_opts->{parallel}
+ if (defined $build_opts->{parallel});
+ $ENV{MAKEFLAGS} ||= '';
+
+ if ($parallel eq '-1') {
+ $ENV{MAKEFLAGS} .= " -j";
+ } else {
+ $ENV{MAKEFLAGS} .= " -j$parallel";
+ }
+
+ $build_opts->{parallel} = $parallel;
+ setbuildopts($build_opts);
+ }
+
# Next dpkg-buildpackage action: build and binary targets
if (! $sourceonly) {
system_withecho('debian/rules', 'build');
@@ -1294,3 +1313,53 @@
}
die $msg;
}
+
+# Dpkg::BuildOptions::parse and ::set
+sub parsebuildopts {
+ my ($env) = @_;
+
+ $env ||= $ENV{DEB_BUILD_OPTIONS};
+
+ unless ($env) { return {}; }
+
+ my %opts;
+
+ foreach (split(/[\s,]+/, $env)) {
+ # FIXME: This is pending resolution of Debian bug #430649
+ /^([a-z][a-z0-9_-]*)(=(\w*))?$/;
+
+ my ($k, $v) = ($1, $3 || '');
+
+ # Sanity checks
+ if (!$k) {
+ next;
+ } elsif ($k =~ /^(noopt|nostrip|nocheck)$/ && length($v)) {
+ $v = '';
+ } elsif ($k eq 'parallel' && $v !~ /^-?\d+$/) {
+ next;
+ }
+
+ $opts{$k} = $v;
+ }
+
+ return \%opts;
+}
+
+sub setbuildopts {
+ my ($opts, $overwrite) = @_;
+ $overwrite = 1 if not defined($overwrite);
+
+ my $env = $overwrite ? '' : $ENV{DEB_BUILD_OPTIONS}||'';
+ if ($env) { $env .= ',' }
+
+ while (my ($k, $v) = each %$opts) {
+ if ($v) {
+ $env .= "$k=$v,";
+ } else {
+ $env .= "$k,";
+ }
+ }
+
+ $ENV{DEB_BUILD_OPTIONS} = $env if $env;
+ return $env;
+}
--
To unsubscribe, send mail to [EMAIL PROTECTED]