]> git.donarmstrong.com Git - debhelper.git/blobdiff - dh_builddeb
Typo. Closes: #653339
[debhelper.git] / dh_builddeb
index b15c943669c82c4f030969d71fdb765c9b1ae15d..77da898fc02d1c2114723247e57cb6560e1d1206 100755 (executable)
@@ -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<debhelper(7)>