浏览代码

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 ]
   [ Guillem Jover ]
   * Fix plural form translations for single plural languages. Closes: #790025
   * 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:
   * Perl modules:
     - Remove non-functional timezone name support from
     - Remove non-functional timezone name support from
       Dpkg::Changelog::Entry::Debian.
       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
 child process. If the number of online processors cannot be inferred then
 the code will fallback to using an unlimited number.
 the code will fallback to using an unlimited number.
 .TP
 .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
 .B \-D
 Check build dependencies and conflicts; abort if unsatisfied. This is the
 Check build dependencies and conflicts; abort if unsatisfied. This is the
 default behavior.
 default behavior.

+ 12 - 4
scripts/dpkg-buildpackage.pl

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