From: Joey Hess Date: Fri, 9 Sep 2011 15:17:27 +0000 (-0400) Subject: Tighten parsing of DEB_BUILD_OPTIONS. X-Git-Tag: 8.9.7~7 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=e845fcc47b244db30a8d19eaaf927de1d8c0a073;p=debhelper.git 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. --- diff --git a/Debian/Debhelper/Dh_Buildsystems.pm b/Debian/Debhelper/Dh_Buildsystems.pm index 405b79c..0a51a4d 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 40c33e8..e28cb32 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 13a755d..f0ea5e7 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 Mon, 29 Aug 2011 20:18:01 -0400 diff --git a/dh_auto_test b/dh_auto_test index ab361cc..85eaf48 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 d187668..77da898 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 5cc6883..a38a66b 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; }