Просмотр исходного кода

Merge branch 'master' of ssh://git.debian.org/git/dpkg/dpkg

Christian Perrier лет назад: 19
Родитель
Сommit
f4d3e5971e
8 измененных файлов с 101 добавлено и 4 удалено
  1. 15 1
      ChangeLog
  2. 4 0
      debian/changelog
  3. 9 0
      man/ChangeLog
  4. 11 0
      man/dpkg-buildpackage.1
  5. 1 1
      man/po/sv.add
  6. 38 0
      scripts/Dpkg/BuildOptions.pm
  7. 1 0
      scripts/Makefile.am
  8. 22 2
      scripts/dpkg-buildpackage.pl

+ 15 - 1
ChangeLog

@@ -1,3 +1,17 @@
+2007-09-23  Frank Lichtenheld  <djpig@debian.org>
+
+	* scripts/dpkg-buildpackage.pl: Add new option
+	-j[<number>] that works like the make option of
+	the same name. It will be passed to debian/rules in
+	the MAKEFLAGS environment variable. Also the
+	parallel=<n> DEB_BUILD_OPTIONS option will be honored
+	and set correctly. The finally used value is determined by the
+	following order: -j > DEB_BUILD_OPTIONS > MAKEFLAGS.
+	Based on an idea by Robert Millan <rmh@aybabtu.com>.
+	* scripts/Dpkg/BuildOptions.pm: Added. Support code
+	for DEB_BUILD_OPTIONS handling by dpkg-buildpackage.
+	* scripts/Makefile.am: Adapt.
+
 2007-09-23  Jari Aalto  <jari.aalto@cante.net>
 
 	* scripts/dpkg-source.pl ($diff_ignore_default_regexp): Add
@@ -13,7 +27,7 @@
 
 	* scripts/Dpkg.pm: Make the regex for determining
 	$progname more robust.
-	
+
 	* scripts/dpkg-buildpackage.sh: Move to...
 	* scripts/dpkg-buildpackage.pl: Convert from
 	Shell to Perl.

+ 4 - 0
debian/changelog

@@ -19,6 +19,10 @@ dpkg (1.14.7) UNRELEASED; urgency=low
   [ Frank Lichtenheld ]
   * Add _MTN to dpkg-source -i default regex. Suggested by Jari Aalto.
   * Convert dpkg-buildpackage to a Perl script.
+  * dpkg-buildpackage accepts a -j<n> option now which will set
+    MAKEFLAGS(-j<n>) and DEB_BUILD_OPTIONS(parallel=<n>) accordingly.
+    parallel=<n> in DEB_BUILD_OPTIONS will be passed to MAKEFLAGS as
+    well. Based on an idea by Robert Millan. Closes: #440636
 
   [ Updated dpkg translations ]
   * Basque (Piarres Beobide). Closes: #440859

+ 9 - 0
man/ChangeLog

@@ -1,3 +1,12 @@
+2007-09-23  Frank Lichtenheld  <djpig@debian.org>
+
+	* dpkg-buildpackage.1: Document the new -j
+	option.
+
+2007-09-23  Peter Karlsson  <peterk@debian.org>
+
+	* po/sv.add: Fixed typo.
+
 2007-09-15  Guillem Jover  <guillem@debian.org>
 
 	* po/dpkg-man.pot: Regenerated.

+ 11 - 0
man/dpkg-buildpackage.1

@@ -47,6 +47,17 @@ Specify the Debian architecture we build for. The architecture of the
 machine we build on is determined automatically, and is also the default
 for the host machine.
 .TP
+.BI \-j jobs
+Number of jobs allowed to be run simultaneously, equivalent to the
+.BR make (1)
+option of the same name. Will add itself to the MAKEFLAGS
+environment variable, which should cause all subsequent make
+invocations to inherit the option. Also adds \fBparallel=\fP\fIjobs\fP
+to the DEB_BUILD_OPTIONS environment variable which allows
+debian/rules files to use this information for their own purposes.
+If no \fB-j\fP option is given, an existing value for \fBparallel\fP will be
+honoured and added to MAKEFLAGS.
+.TP
 .BI \-v version
 Use changelog information from all versions strictly later than
 .IR version .

+ 1 - 1
man/po/sv.add

@@ -1,3 +1,3 @@
 PO4A-HEADER:mode=after;position=^\.TH;beginboundary=FakePo4aBoundary
 .SH "ÖVERSÄTTNING"
-Peter Karlsson och Debian Nylander.
+Peter Karlsson och Daniel Nylander.

+ 38 - 0
scripts/Dpkg/BuildOptions.pm

@@ -0,0 +1,38 @@
+package Dpkg::BuildOptions;
+
+use strict;
+use warnings;
+
+sub parse {
+    my ($env) = @_;
+
+    $env ||= $ENV{DEB_BUILD_OPTIONS};
+
+    unless ($env) { return {}; }
+
+    my %opts;
+    if ($env =~ s/(noopt|nostrip),?//ig) {
+	$opts{lc $1} = '';
+    } elsif ($env =~ s/(parallel)=(-?\d+),?//ig) {
+	$opts{lc $1} = $2;
+    }
+
+    return \%opts;
+}
+
+sub set {
+    my ($opts, $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,";
+	}
+    }
+}
+
+1;

+ 1 - 0
scripts/Makefile.am

@@ -55,6 +55,7 @@ CLEANFILES = \
 
 perllibdir = $(PERL_LIBDIR)
 nobase_dist_perllib_DATA = \
+	Dpkg/BuildOptions.pm \
 	Dpkg/Gettext.pm \
 	Dpkg.pm
 

+ 22 - 2
scripts/dpkg-buildpackage.pl

@@ -8,6 +8,7 @@ use File::Basename;
 
 use Dpkg;
 use Dpkg::Gettext;
+use Dpkg::BuildOptions;
 
 push (@INC, $dpkglibdir);
 require 'controllib.pl';
@@ -39,6 +40,7 @@ Options:
   -p<sign-command>
   -d             do not check build dependencies and conflicts.
   -D             check build dependencies and conflicts.
+  -j[<number>]   specify jobs to run simultaniously } passed to debian/rules
   -k<keyid>      the key to use for signing.
   -sgpg          the sign-command is called like GPG.
   -spgp          the sign-command is called like PGP.
@@ -95,7 +97,7 @@ if ( ( ($ENV{GNUPGHOME} && -e $ENV{GNUPGHOME})
 my ($admindir, $signkey, $forcesigninterface, $usepause, $noclean,
     $warnable_errors, $sourcestyle, $cleansource,
     $binaryonly, $sourceonly, $since, $maint,
-    $changedby, $desc);
+    $changedby, $desc, $parallel);
 my (@checkbuilddep_args, @passopts, @tarignore);
 my $checkbuilddep = 1;
 my $signsource = 1;
@@ -115,6 +117,8 @@ while (@ARGV) {
 	exit 0;
     } elsif (/^--admindir=(.*)$/) {
 	$admindir = $1;
+    } elsif (/^-j(\d*)$/) {
+	$parallel = $1 || '-1';
     } elsif (/^-r(.*)$/) {
 	$rootcommand = $1;
     } elsif (/^-p(.*)$/) {
@@ -209,6 +213,22 @@ if ($signcommand && ($signinterface !~ /^(gpg|pgp)$/)) {
     warning(_g("unknown sign command, assuming pgp style interface"));
 }
 
+if ($parallel || $ENV{DEB_BUILD_OPTIONS}) {
+    my $build_opts = Dpkg::BuildOptions::parse();
+
+    $parallel ||= $build_opts->{parallel};
+    if (defined $parallel) {
+	$ENV{MAKEFLAGS} ||= '';
+	if ($parallel eq '-1') {
+	    $ENV{MAKEFLAGS} .= " -j";
+	} else {
+	    $ENV{MAKEFLAGS} .= " -j$parallel";
+	}
+    }
+    $build_opts->{parallel} = $parallel;
+    Dpkg::BuildOptions::set($build_opts);
+}
+
 my $cwd = cwd();
 my $dir = basename($cwd);
 
@@ -309,7 +329,7 @@ if ($checkbuilddep) {
     }
 
     if (system('dpkg-checkbuilddeps', @checkbuilddep_args)) {
-	warning(_g("Build dependencies/conflicts unsatisfied; aborting.\n"));
+	warning(_g("Build dependencies/conflicts unsatisfied; aborting."));
 	warning(_g("(Use -d flag to override.)"));
 	exit 3;
     }