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;
}
}
&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;
}
}
+# 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
* 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
=cut
use strict;
+use Debian::Debhelper::Dh_Lib;
use Debian::Debhelper::Dh_Buildsystems;
=head1 SYNOPSIS
=cut
-if (defined $ENV{DEB_BUILD_OPTIONS} && $ENV{DEB_BUILD_OPTIONS} =~ /nocheck/) {
+if (get_buildoption("nocheck")) {
exit 0;
}
$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;
});
# 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;
}