Преглед изворни кода

scripts: Only allow one build type option

For dpkg-genchanges and dpkg-buildpackage, specifying more than one
build type option seems rather confusing, as depending on the
combination it can either fail, or make the last option win. And it
will get even more confusing when adding the remaining options to
cover all build type combinations. Just be consistent about this
and fail hard when specifying conflicting build types.
Guillem Jover пре 12 година
родитељ
комит
c781f4c988
3 измењених фајлова са 13 додато и 11 уклоњено
  1. 1 0
      debian/changelog
  2. 7 7
      scripts/dpkg-buildpackage.pl
  3. 5 4
      scripts/dpkg-genchanges.pl

+ 1 - 0
debian/changelog

@@ -95,6 +95,7 @@ dpkg (1.17.11) UNRELEASED; urgency=low
     type description.
   * Unify build options description in --help output for dpkg-buildpackage
     and dpkg-genchanges.
+  * Only allow one build type option in dpkg-genchanges and dpkg-buildpackage.
 
   [ Updated programs translations ]
   * Danish (Joe Dalton). Closes: #754127

+ 7 - 7
scripts/dpkg-buildpackage.pl

@@ -165,7 +165,7 @@ use constant BUILD_BINARY     => BUILD_ARCH_DEP | BUILD_ARCH_INDEP;
 use constant BUILD_ALL        => BUILD_BINARY | BUILD_SOURCE;
 my $include = BUILD_ALL | BUILD_DEFAULT;
 
-sub build_normal() { return ($include & BUILD_ALL) == BUILD_ALL; }
+sub build_is_default() { return $include & BUILD_DEFAULT; }
 sub build_sourceonly() { return $include == BUILD_SOURCE; }
 sub build_binaryonly() { return !($include & BUILD_SOURCE); }
 sub build_binaryindep() { return ($include == BUILD_ARCH_INDEP); }
@@ -264,27 +264,27 @@ while (@ARGV) {
 	$noclean = 1;
     } elsif (/^-b$/) {
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
-	    if build_sourceonly;
+	    if not build_is_default;
 	$include = BUILD_BINARY;
 	push @changes_opts, '-b';
     } elsif (/^-B$/) {
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
-	    if build_sourceonly;
+	    if not build_is_default;
 	$include = BUILD_ARCH_DEP;
 	push @changes_opts, '-B';
     } elsif (/^-A$/) {
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
-	    if build_sourceonly;
+	    if not build_is_default;
 	$include = BUILD_ARCH_INDEP;
 	push @changes_opts, '-A';
     } elsif (/^-S$/) {
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
-	    if build_binaryonly;
+	    if not build_is_default;
 	$include = BUILD_SOURCE;
 	push @changes_opts, '-S';
     } elsif (/^-F$/) {
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
-	    if not build_normal;
+	    if not build_is_default;
 	$include = BUILD_ALL;
     } elsif (/^-v(.*)$/) {
 	$since = $1;
@@ -318,7 +318,7 @@ if (($include & BUILD_BINARY) == BUILD_BINARY) {
 
 if ($noclean) {
     # -nc without -b/-B/-A/-S/-F implies -b
-    $include = BUILD_BINARY if ($include & BUILD_DEFAULT);
+    $include = BUILD_BINARY if build_is_default;
 }
 
 if ($< == 0) {

+ 5 - 4
scripts/dpkg-genchanges.pl

@@ -86,6 +86,7 @@ use constant BUILD_BINARY     => BUILD_ARCH_DEP | BUILD_ARCH_INDEP;
 use constant BUILD_ALL        => BUILD_BINARY | BUILD_SOURCE;
 my $include = BUILD_ALL;
 
+sub build_is_default() { return ($include & BUILD_ALL) == BUILD_ALL; }
 sub is_sourceonly() { return $include == BUILD_SOURCE; }
 sub is_binaryonly() { return !($include & BUILD_SOURCE); }
 sub build_opt {
@@ -147,19 +148,19 @@ while (@ARGV) {
     $_=shift(@ARGV);
     if (m/^-b$/) {
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
-	    if is_sourceonly;
+	    if not build_is_default;
 	$include = BUILD_BINARY;
     } elsif (m/^-B$/) {
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
-	    if is_sourceonly;
+	    if not build_is_default;
 	$include = BUILD_ARCH_DEP;
     } elsif (m/^-A$/) {
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
-	    if is_sourceonly;
+	    if not build_is_default;
 	$include = BUILD_ARCH_INDEP;
     } elsif (m/^-S$/) {
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
-	    if is_binaryonly;
+	    if not build_is_default;
 	$include = BUILD_SOURCE;
     } elsif (m/^-s([iad])$/) {
         $sourcestyle= $1;