]> git.donarmstrong.com Git - debhelper.git/commitdiff
Tighten parsing of DEB_BUILD_OPTIONS.
authorJoey Hess <joey@kitenet.net>
Fri, 9 Sep 2011 15:17:27 +0000 (11:17 -0400)
committerJoey Hess <joey@kitenet.net>
Fri, 9 Sep 2011 15:17:27 +0000 (11:17 -0400)
A future nostripexceptonfullmoon option seems unlikely, but sure,
let's be strict. More importantly, let's reuse good code.

Debian/Debhelper/Dh_Buildsystems.pm
Debian/Debhelper/Dh_Lib.pm
debian/changelog
dh_auto_test
dh_builddeb
dh_strip

index 405b79c610f8d0617326258f17d0783c196f28dc..0a51a4d228ea6fa81cf5df75d8640d8e82f358a1 100644 (file)
@@ -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;
        }
 }
 
index 40c33e84722606c64b8afa293f3f65e2271cbaa1..e28cb326079c741a97b81f549cd502081dcb2ff8 100644 (file)
@@ -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
index 13a755d4f7a1edefb8336edd5803ae8c24430470..f0ea5e759b3580113933347fd3f53e86a76599aa 100644 (file)
@@ -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
 
index ab361cc5cad6be9fe0c44b3be4675e6118a30bbd..85eaf48a7a7d65af21eb2809d24cde2c3d2c63a7 100755 (executable)
@@ -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;
 }
 
index d1876687282f761cd225449548c07f3a7572b198..77da898fc02d1c2114723247e57cb6560e1d1206 100755 (executable)
@@ -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;
index 5cc68834d5cf4ee307729c9f5a0af4c07c60cdc8..a38a66be30fb46494babc45bfa8490fc089b3725 100755 (executable)
--- 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;
 }