瀏覽代碼

Dpkg::Build::Type: Always map the build type to the shortest string form

We should try to map to the shortest string to make life easier.
Guillem Jover 10 年之前
父節點
當前提交
bc4ceb7af5
共有 4 個文件被更改,包括 13 次插入 和 9 次删除
  1. 2 0
      debian/changelog
  2. 8 4
      scripts/Dpkg/Build/Types.pm
  3. 3 3
      scripts/t/Dpkg_Build_Types.t
  4. 0 2
      scripts/t/dpkg_buildpackage.t

+ 2 - 0
debian/changelog

@@ -60,6 +60,8 @@ dpkg (1.18.11) UNRELEASED; urgency=medium
     - Prefix private Dpkg::Source::Package::* functions with _.
     - Defer filehandle closures in Dpkg::IPC::spawn() to avoid double-close.
       Closes: #839905, #840293
+    - Always map the build type to the shortest string form in
+      Dpkg::Build::Type::get_build_options_from_type().
   * Packaging:
     - Add liblocale-gettext-perl to libdpkg-perl Recommends.
     - Wrap and document dependency relationships.

+ 8 - 4
scripts/Dpkg/Build/Types.pm

@@ -100,13 +100,13 @@ use constant BUILD_FULL   => BUILD_BINARY | BUILD_SOURCE;
 my $current_type = BUILD_FULL | BUILD_DEFAULT;
 my $current_option = undef;
 
-my @build_types = qw(source any all);
+my @build_types = qw(full source binary any all);
 my %build_types = (
     full => BUILD_FULL,
     source => BUILD_SOURCE,
+    binary => BUILD_BINARY,
     any => BUILD_ARCH_DEP,
     all => BUILD_ARCH_INDEP,
-    binary => BUILD_BINARY,
 );
 
 =back
@@ -224,11 +224,15 @@ Get the current build type as a set of comma-separated string options.
 
 sub get_build_options_from_type
 {
-    return 'full' if build_has_all(BUILD_FULL);
+    my $local_type = $current_type;
 
     my @parts;
     foreach my $type (@build_types) {
-        push @parts, $type if build_has_all($build_types{$type});
+        my $part_bits = $build_types{$type};
+        if (($local_type & $part_bits) == $part_bits) {
+            push @parts, $type;
+            $local_type &= ~$part_bits;
+        }
     }
 
     return join ',', @parts;

+ 3 - 3
scripts/t/Dpkg_Build_Types.t

@@ -26,18 +26,18 @@ ok(build_is(BUILD_DEFAULT | BUILD_FULL), 'build is default full');
 is(get_build_options_from_type(), 'full', 'build is full');
 
 set_build_type(BUILD_DEFAULT | BUILD_BINARY, '--default-binary');
-is(get_build_options_from_type(), 'any,all', 'build is any,all');
+is(get_build_options_from_type(), 'binary', 'build is binary');
 ok(build_is(BUILD_DEFAULT | BUILD_BINARY), 'build is default binary');
 
 set_build_type(BUILD_SOURCE | BUILD_ARCH_INDEP, '--build=source,all');
 is(get_build_options_from_type(), 'source,all', 'build is source,all');
 
 set_build_type_from_options('any,all', '--build=any,all', nocheck => 1);
-is(get_build_options_from_type(), 'any,all', 'build is any,all');
+is(get_build_options_from_type(), 'binary', 'build is binary from any,all');
 ok(build_is(BUILD_BINARY), 'build is any,all');
 
 set_build_type_from_options('binary', '--build=binary', nocheck => 1);
-is(get_build_options_from_type(), 'any,all', 'build is binary');
+is(get_build_options_from_type(), 'binary', 'build is binary');
 ok(build_is(BUILD_BINARY), 'build is binary');
 
 set_build_type_from_options('source,all', '--build=source,all', nocheck => 1);

+ 0 - 2
scripts/t/dpkg_buildpackage.t

@@ -176,8 +176,6 @@ sub test_build
 
     set_build_type($type, 'buildtype', nocheck => 1);
     my $typename = get_build_options_from_type();
-    $typename = 'full' if $typename eq 'source,any,all';
-    $typename = 'binary' if $typename eq 'any,all';
 
     chdir $dirname;
     spawn(exec => [ "$srcdir/dpkg-buildpackage.pl", '--host-arch=amd64',