瀏覽代碼

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.
     type description.
   * Unify build options description in --help output for dpkg-buildpackage
   * Unify build options description in --help output for dpkg-buildpackage
     and dpkg-genchanges.
     and dpkg-genchanges.
+  * Only allow one build type option in dpkg-genchanges and dpkg-buildpackage.
 
 
   [ Updated programs translations ]
   [ Updated programs translations ]
   * Danish (Joe Dalton). Closes: #754127
   * 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;
 use constant BUILD_ALL        => BUILD_BINARY | BUILD_SOURCE;
 my $include = BUILD_ALL | BUILD_DEFAULT;
 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_sourceonly() { return $include == BUILD_SOURCE; }
 sub build_binaryonly() { return !($include & BUILD_SOURCE); }
 sub build_binaryonly() { return !($include & BUILD_SOURCE); }
 sub build_binaryindep() { return ($include == BUILD_ARCH_INDEP); }
 sub build_binaryindep() { return ($include == BUILD_ARCH_INDEP); }
@@ -264,27 +264,27 @@ while (@ARGV) {
 	$noclean = 1;
 	$noclean = 1;
     } elsif (/^-b$/) {
     } elsif (/^-b$/) {
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
-	    if build_sourceonly;
+	    if not build_is_default;
 	$include = BUILD_BINARY;
 	$include = BUILD_BINARY;
 	push @changes_opts, '-b';
 	push @changes_opts, '-b';
     } elsif (/^-B$/) {
     } elsif (/^-B$/) {
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
-	    if build_sourceonly;
+	    if not build_is_default;
 	$include = BUILD_ARCH_DEP;
 	$include = BUILD_ARCH_DEP;
 	push @changes_opts, '-B';
 	push @changes_opts, '-B';
     } elsif (/^-A$/) {
     } elsif (/^-A$/) {
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
-	    if build_sourceonly;
+	    if not build_is_default;
 	$include = BUILD_ARCH_INDEP;
 	$include = BUILD_ARCH_INDEP;
 	push @changes_opts, '-A';
 	push @changes_opts, '-A';
     } elsif (/^-S$/) {
     } elsif (/^-S$/) {
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
-	    if build_binaryonly;
+	    if not build_is_default;
 	$include = BUILD_SOURCE;
 	$include = BUILD_SOURCE;
 	push @changes_opts, '-S';
 	push @changes_opts, '-S';
     } elsif (/^-F$/) {
     } elsif (/^-F$/) {
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
-	    if not build_normal;
+	    if not build_is_default;
 	$include = BUILD_ALL;
 	$include = BUILD_ALL;
     } elsif (/^-v(.*)$/) {
     } elsif (/^-v(.*)$/) {
 	$since = $1;
 	$since = $1;
@@ -318,7 +318,7 @@ if (($include & BUILD_BINARY) == BUILD_BINARY) {
 
 
 if ($noclean) {
 if ($noclean) {
     # -nc without -b/-B/-A/-S/-F implies -b
     # -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) {
 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;
 use constant BUILD_ALL        => BUILD_BINARY | BUILD_SOURCE;
 my $include = BUILD_ALL;
 my $include = BUILD_ALL;
 
 
+sub build_is_default() { return ($include & BUILD_ALL) == BUILD_ALL; }
 sub is_sourceonly() { return $include == BUILD_SOURCE; }
 sub is_sourceonly() { return $include == BUILD_SOURCE; }
 sub is_binaryonly() { return !($include & BUILD_SOURCE); }
 sub is_binaryonly() { return !($include & BUILD_SOURCE); }
 sub build_opt {
 sub build_opt {
@@ -147,19 +148,19 @@ while (@ARGV) {
     $_=shift(@ARGV);
     $_=shift(@ARGV);
     if (m/^-b$/) {
     if (m/^-b$/) {
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
-	    if is_sourceonly;
+	    if not build_is_default;
 	$include = BUILD_BINARY;
 	$include = BUILD_BINARY;
     } elsif (m/^-B$/) {
     } elsif (m/^-B$/) {
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
-	    if is_sourceonly;
+	    if not build_is_default;
 	$include = BUILD_ARCH_DEP;
 	$include = BUILD_ARCH_DEP;
     } elsif (m/^-A$/) {
     } elsif (m/^-A$/) {
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
-	    if is_sourceonly;
+	    if not build_is_default;
 	$include = BUILD_ARCH_INDEP;
 	$include = BUILD_ARCH_INDEP;
     } elsif (m/^-S$/) {
     } elsif (m/^-S$/) {
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
 	usageerr(_g('cannot combine %s and %s'), build_opt(), $_)
-	    if is_binaryonly;
+	    if not build_is_default;
 	$include = BUILD_SOURCE;
 	$include = BUILD_SOURCE;
     } elsif (m/^-s([iad])$/) {
     } elsif (m/^-s([iad])$/) {
         $sourcestyle= $1;
         $sourcestyle= $1;