ソースを参照

dpkg-buildpackage: Add new -J option

This option behaves in the same way as -j, except that it does not set
the MAKEFLAGS environment variable, and as such it is safer to use with
any package including those that are not parallel-build safe.
Guillem Jover 11 年 前
コミット
ec206658f9
共有3 個のファイルを変更した19 個の追加4 個の削除を含む
  1. 1 0
      debian/changelog
  2. 6 0
      man/dpkg-buildpackage.1
  3. 12 4
      scripts/dpkg-buildpackage.pl

+ 1 - 0
debian/changelog

@@ -2,6 +2,7 @@ dpkg (1.18.2) UNRELEASED; urgency=low
 
   [ Guillem Jover ]
   * Fix plural form translations for single plural languages. Closes: #790025
+  * Add new dpkg-buildpackage -J option, which is a safe version of -j.
   * Perl modules:
     - Remove non-functional timezone name support from
       Dpkg::Changelog::Entry::Debian.

+ 6 - 0
man/dpkg-buildpackage.1

@@ -200,6 +200,12 @@ currently active processors, and as such will not get propagated to any
 child process. If the number of online processors cannot be inferred then
 the code will fallback to using an unlimited number.
 .TP
+.BR \-J [\fIjobs\fP|\fBauto\fP]
+This option (since dpkg 1.18.2) is equivalent to the \fB\-j\fP option
+except that it does not set the \fB\%MAKEFLAGS\fP environment variable,
+and as such it is safer to use with any package including those that are
+not parallel-build safe.
+.TP
 .B \-D
 Check build dependencies and conflicts; abort if unsatisfied. This is the
 default behavior.

+ 12 - 4
scripts/dpkg-buildpackage.pl

@@ -4,7 +4,7 @@
 #
 # Copyright © 1996 Ian Jackson
 # Copyright © 2000 Wichert Akkerman
-# Copyright © 2006-2010,2012-2014 Guillem Jover <guillem@debian.org>
+# Copyright © 2006-2010, 2012-2015 Guillem Jover <guillem@debian.org>
 # Copyright © 2007 Frank Lichtenheld
 #
 # This program is free software; you can redistribute it and/or modify
@@ -74,7 +74,8 @@ sub usage {
   -R<rules>      rules file to execute (default is debian/rules).
   -T<target>     call debian/rules <target> with the proper environment.
       --as-root  ensure -T calls the target with root rights.
-  -j[<number>]   specify jobs to run simultaneously (passed to <rules>).
+  -j[<number>]   jobs to run simultaneously (passed to <rules>), forced mode.
+  -J[<number>]   jobs to run simultaneously (passed to <rules>), opt-in mode.
   -r<gain-root-command>
                  command to gain root privileges (default is fakeroot).
   --check-command=<check-command>
@@ -135,6 +136,7 @@ my $signcommand;
 my $noclean;
 my $cleansource;
 my $parallel;
+my $parallel_force;
 my $checkbuilddep = 1;
 my @source_opts;
 my $check_command = $ENV{DEB_CHECK_COMMAND};
@@ -233,6 +235,10 @@ while (@ARGV) {
 	push @changes_opts, $1;
     } elsif (/^-j(\d*|auto)$/) {
 	$parallel = $1 || '';
+	$parallel_force = 1;
+    } elsif (/^-J(\d*|auto)$/) {
+	$parallel = $1 || '';
+	$parallel_force = 0;
     } elsif (/^-r(.*)$/) {
 	my $arg = $1;
 	@rootcommand = split /\s+/, $arg;
@@ -395,8 +401,10 @@ if (defined $parallel) {
         $parallel = qx(getconf _NPROC_ONLN 2>/dev/null) if $?;
         chomp $parallel;
     }
-    $ENV{MAKEFLAGS} //= '';
-    $ENV{MAKEFLAGS} .= " -j$parallel";
+    if ($parallel_force) {
+        $ENV{MAKEFLAGS} //= '';
+        $ENV{MAKEFLAGS} .= " -j$parallel";
+    }
     $build_opts->set('parallel', $parallel);
     $build_opts->export();
 }