summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2011-09-09 11:17:27 -0400
committerJoey Hess <joey@kitenet.net>2011-09-09 11:17:27 -0400
commite845fcc47b244db30a8d19eaaf927de1d8c0a073 (patch)
tree81a08c988ca293f7ab097fe631ff9c5b88935cc6
parentf3afdd51e82972541cefebb15ec5a1d78ce67215 (diff)
Tighten parsing of DEB_BUILD_OPTIONS.
A future nostripexceptonfullmoon option seems unlikely, but sure, let's be strict. More importantly, let's reuse good code.
-rw-r--r--Debian/Debhelper/Dh_Buildsystems.pm19
-rw-r--r--Debian/Debhelper/Dh_Lib.pm19
-rw-r--r--debian/changelog1
-rwxr-xr-xdh_auto_test3
-rwxr-xr-xdh_builddeb5
-rwxr-xr-xdh_strip2
6 files changed, 29 insertions, 20 deletions
diff --git a/Debian/Debhelper/Dh_Buildsystems.pm b/Debian/Debhelper/Dh_Buildsystems.pm
index 405b79c6..0a51a4d2 100644
--- a/Debian/Debhelper/Dh_Buildsystems.pm
+++ b/Debian/Debhelper/Dh_Buildsystems.pm
@@ -167,19 +167,12 @@ sub buildsystems_init {
sub set_parallel {
my $max=shift;
- $opt_parallel=1;
-
- if (exists $ENV{DEB_BUILD_OPTIONS}) {
- # Get number of processes from parallel=n tag limiting it
- # with $max if needed
- foreach my $opt (split(/\s+/, $ENV{DEB_BUILD_OPTIONS})) {
- if ($opt =~ /^parallel=(-?\d+)$/) {
- $opt_parallel = $1;
- if ($max > 0 && $opt_parallel > $max) {
- $opt_parallel = $max;
- }
- }
- }
+ # Get number of processes from parallel=n option, limiting it
+ # with $max if needed
+ $opt_parallel=get_buildoption("parallel") || 1;
+
+ if ($max > 0 && $opt_parallel > $max) {
+ $opt_parallel = $max;
}
}
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 40c33e84..e28cb326 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -18,7 +18,7 @@ use vars qw(@ISA @EXPORT %dh);
&inhibit_log &load_log &write_log &commit_override_log
&dpkg_architecture_value &sourcepackage
&is_make_jobserver_unavailable &clean_jobserver_makeflags
- &cross_command &set_buildflags);
+ &cross_command &set_buildflags &get_buildoption);
my $max_compat=9;
@@ -926,4 +926,21 @@ sub set_buildflags {
}
}
+# Gets a DEB_BUILD_OPTIONS option, if set.
+sub get_buildoption {
+ my $wanted=shift;
+
+ return undef unless exists $ENV{DEB_BUILD_OPTIONS};
+
+ foreach my $opt (split(/\s+/, $ENV{DEB_BUILD_OPTIONS})) {
+ # currently parallel= is the only one with a parameter
+ if ($opt =~ /^parallel=(-?\d+)$/ && $wanted eq 'parallel') {
+ return $1;
+ }
+ elsif ($opt eq $wanted) {
+ return 1;
+ }
+ }
+}
+
1
diff --git a/debian/changelog b/debian/changelog
index 13a755d4..f0ea5e75 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,7 @@ debhelper (8.9.7) UNRELEASED; urgency=low
* debhelper no longer build-depends on man-db or file, to ease bootstrapping.
* Remove obsolete versioned dependency on perl-base.
* Avoid writing debhelper log files in no-act mode. Closes: #640586
+ * Tighten parsing of DEB_BUILD_OPTIONS.
-- Joey Hess <joeyh@debian.org> Mon, 29 Aug 2011 20:18:01 -0400
diff --git a/dh_auto_test b/dh_auto_test
index ab361cc5..85eaf48a 100755
--- a/dh_auto_test
+++ b/dh_auto_test
@@ -7,6 +7,7 @@ dh_auto_test - automatically runs a package's test suites
=cut
use strict;
+use Debian::Debhelper::Dh_Lib;
use Debian::Debhelper::Dh_Buildsystems;
=head1 SYNOPSIS
@@ -48,7 +49,7 @@ tests will be performed.
=cut
-if (defined $ENV{DEB_BUILD_OPTIONS} && $ENV{DEB_BUILD_OPTIONS} =~ /nocheck/) {
+if (get_buildoption("nocheck")) {
exit 0;
}
diff --git a/dh_builddeb b/dh_builddeb
index d1876687..77da898f 100755
--- a/dh_builddeb
+++ b/dh_builddeb
@@ -63,10 +63,7 @@ else {
$dh{FILENAME}="/$dh{FILENAME}";
}
-my $max_procs=1;
-if (defined $ENV{DEB_BUILD_OPTIONS} && $ENV{DEB_BUILD_OPTIONS}=~/parallel=(\d+)/) {
- $max_procs=$1;
-}
+my $max_procs=get_buildoption("parallel") || 1;
my $processes=1;
my $exit=0;
diff --git a/dh_strip b/dh_strip
index 5cc68834..a38a66be 100755
--- a/dh_strip
+++ b/dh_strip
@@ -82,7 +82,7 @@ init(options => {
});
# This variable can be used to turn off stripping (see Policy).
-if (defined $ENV{DEB_BUILD_OPTIONS} && $ENV{DEB_BUILD_OPTIONS} =~ /nostrip/) {
+if (get_buildoption('nostrip')) {
exit;
}