X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=dh_builddeb;h=77da898fc02d1c2114723247e57cb6560e1d1206;hb=e2a6d4cec4a7ee952cf6a7f250d80f1d75a38f95;hp=b15c943669c82c4f030969d71fdb765c9b1ae15d;hpb=7bc99d44cfc0275e1b44b390bed1362c457da9ab;p=debhelper.git diff --git a/dh_builddeb b/dh_builddeb index b15c943..77da898 100755 --- a/dh_builddeb +++ b/dh_builddeb @@ -63,7 +63,32 @@ else { $dh{FILENAME}="/$dh{FILENAME}"; } +my $max_procs=get_buildoption("parallel") || 1; + +my $processes=1; +my $exit=0; +sub reap { + if (wait == -1) { + $processes=0; + } + else { + $processes--; + $exit=1 if $? != 0; + } +} + foreach my $package (@{$dh{DOPACKAGES}}) { + my $pid=fork(); + if (! defined $pid) { + error("fork failed! $!"); + } + if ($pid) { # parent + $processes++; + reap while $processes > $max_procs; + next; + } + + # child my $tmp=tmpdir($package); if (exists $ENV{DH_ALWAYS_EXCLUDE} && length $ENV{DH_ALWAYS_EXCLUDE}) { if (! compat(5)) { @@ -86,8 +111,12 @@ foreach my $package (@{$dh{DOPACKAGES}}) { } doit("dpkg-deb", @{$dh{U_PARAMS}}, "--build", $tmp, $dh{DESTDIR}.$filename); } + exit 0; } +reap while $processes; +exit $exit; + =head1 SEE ALSO L