Browse Source

dpkg-buildflags: Honor feature area settings from DEB_BUILD_OPTIONS

This allows users to specify build flags from specific area features.
These settings will be overridden by any subsequent settings from
DEB_BUILD_MAINT_OPTIONS, in the same way other build flags are affected,
so that the maintainer can disable specific things that might be broken.
Guillem Jover 11 years ago
parent
commit
60652d3854
2 changed files with 24 additions and 12 deletions
  1. 9 5
      man/dpkg-buildflags.1
  2. 15 7
      scripts/Dpkg/Vendor/Debian.pm

+ 9 - 5
man/dpkg-buildflags.1

@@ -198,8 +198,8 @@ to support other languages).
 .
 .SH FEATURE AREAS
 .P
-Each area feature can be enabled and disabled in the
-\fBDEB_BUILD_MAINT_OPTIONS\fP environment variable's area value with the
+Each area feature can be enabled and disabled in the \fBDEB_BUILD_OPTIONS\fP
+and \fBDEB_BUILD_MAINT_OPTIONS\fP environment variable's area value with the
 "+" and "\-" modifier.
 For example, to enable the \fBhardening\fP "pie" feature and disable the
 "fortify" feature you can do this in \fBdebian/rules\fP:
@@ -372,10 +372,14 @@ returned for the given \fIflag\fP.
 This variable can be used to prepend supplementary options to the value
 returned for the given \fIflag\fP.
 .TP
+.B DEB_BUILD_OPTIONS
+.TQ
 .B DEB_BUILD_MAINT_OPTIONS
-This variable can be used to disable/enable various hardening build
-flags through the \fBhardening\fP option. See the \fBFEATURE AREAS\fP section
-for details.
+These variables can be used by a user or maintainer to disable/enable
+various area features that affect build flags.
+The \fBDEB_BUILD_MAINT_OPTIONS\fP variable overrides any setting in the
+\fBDEB_BUILD_OPTIONS\fP feature areas.
+See the \fBFEATURE AREAS\fP section for details.
 .
 .SH FILES
 .SS Configuration files

+ 15 - 7
scripts/Dpkg/Vendor/Debian.pm

@@ -74,11 +74,11 @@ sub run_hook {
     }
 }
 
-sub _parse_feature_area {
-    my ($self, $area, $use_feature) = @_;
+sub _parse_build_options {
+    my ($self, $variable, $area, $use_feature) = @_;
 
-    # Adjust features based on Maintainer's desires.
-    my $opts = Dpkg::BuildOptions->new(envvar => 'DEB_BUILD_MAINT_OPTIONS');
+    # Adjust features based on user or maintainer's desires.
+    my $opts = Dpkg::BuildOptions->new(envvar => $variable);
     foreach my $feature (split(/,/, $opts->get($area) // '')) {
 	$feature = lc($feature);
 	if ($feature =~ s/^([+-])//) {
@@ -89,16 +89,24 @@ sub _parse_feature_area {
 		if (exists $use_feature->{$feature}) {
 		    $use_feature->{$feature} = $value;
 		} else {
-		    warning(_g('unknown %s feature: %s'), $area, $feature);
+		    warning(_g('unknown %s feature in %s variable: %s'),
+		            $area, $variable, $feature);
 		}
 	    }
 	} else {
-	    warning(_g('incorrect value in %s option of ' .
-	               'DEB_BUILD_MAINT_OPTIONS: %s'), $area, $feature);
+	    warning(_g('incorrect value in %s option of %s variable: %s'),
+	            $area, $variable, $feature);
 	}
     }
 }
 
+sub _parse_feature_area {
+    my ($self, $area, $use_feature) = @_;
+
+    $self->_parse_build_options('DEB_BUILD_OPTIONS', $area, $use_feature);
+    $self->_parse_build_options('DEB_BUILD_MAINT_OPTIONS', $area, $use_feature);
+}
+
 sub _add_qa_flags {
     my ($self, $flags) = @_;