[Reproducible-commits] [dpkg] 83/105: Dpkg::Build::Types: Clarify build type functions

Niko Tyni ntyni at moszumanska.debian.org
Mon May 2 13:49:56 UTC 2016


This is an automated email from the git hooks/post-receive script.

ntyni pushed a commit to branch ntyni/reproducible_builds
in repository dpkg.

commit 3baee8a7d507d7d24ba9a8762399c54129efc1d7
Author: Guillem Jover <guillem at debian.org>
Date:   Wed Apr 6 17:33:26 2016 +0200

    Dpkg::Build::Types: Clarify build type functions
    
    Distinguish build_has_any from build_has_all. Rename build_has_not into
    build_has_none.
    
    Fix scripts to use the correct bits check function.
---
 scripts/Dpkg/Build/Types.pm  | 18 +++++++++---------
 scripts/dpkg-buildpackage.pl | 18 +++++++++---------
 scripts/dpkg-genchanges.pl   | 18 +++++++++---------
 scripts/t/Dpkg_Build_Types.t | 16 ++++++++--------
 4 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/scripts/Dpkg/Build/Types.pm b/scripts/Dpkg/Build/Types.pm
index 85b4424..9f19c77 100644
--- a/scripts/Dpkg/Build/Types.pm
+++ b/scripts/Dpkg/Build/Types.pm
@@ -28,8 +28,8 @@ our @EXPORT = qw(
     BUILD_BINARY
     BUILD_FULL
     build_has_any
-    build_has
-    build_has_not
+    build_has_all
+    build_has_none
     build_is
     set_build_type
 );
@@ -118,32 +118,32 @@ sub build_has_any
     return $current_type & $bits;
 }
 
-=item build_has($bits)
+=item build_has_all($bits)
 
 Return a boolean indicating whether the current build type has all the
 specified $bits.
 
 =cut
 
-sub build_has
+sub build_has_all
 {
     my ($bits) = @_;
 
     return ($current_type & $bits) == $bits;
 }
 
-=item build_has_not($bits)
+=item build_has_none($bits)
 
-Return a boolean indicating whether the current build type does not have the
+Return a boolean indicating whether the current build type has none of the
 specified $bits.
 
 =cut
 
-sub build_has_not
+sub build_has_none
 {
     my ($bits) = @_;
 
-    return ($current_type & $bits) != $bits;
+    return !($current_type & $bits);
 }
 
 =item build_is($bits)
@@ -172,7 +172,7 @@ sub set_build_type
     my ($build_type, $build_option) = @_;
 
     usageerr(g_('cannot combine %s and %s'), $current_option, $build_option)
-        if build_has_not(BUILD_DEFAULT) and $current_type != $build_type;
+        if build_has_none(BUILD_DEFAULT) and $current_type != $build_type;
 
     $current_type = $build_type;
     $current_option = $build_option;
diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl
index 8ad12c8..e922e0c 100755
--- a/scripts/dpkg-buildpackage.pl
+++ b/scripts/dpkg-buildpackage.pl
@@ -304,20 +304,20 @@ while (@ARGV) {
     }
 }
 
-if (build_has(BUILD_BINARY)) {
+if (build_has_all(BUILD_BINARY)) {
     $buildtarget = 'build';
     $binarytarget = 'binary';
-} elsif (build_has(BUILD_ARCH_DEP)) {
+} elsif (build_has_any(BUILD_ARCH_DEP)) {
     $buildtarget = 'build-arch';
     $binarytarget = 'binary-arch';
-} elsif (build_has(BUILD_ARCH_INDEP)) {
+} elsif (build_has_any(BUILD_ARCH_INDEP)) {
     $buildtarget = 'build-indep';
     $binarytarget = 'binary-indep';
 }
 
 if ($noclean) {
     # -nc without -b/-B/-A/-S/-F implies -b
-    set_build_type(BUILD_BINARY) if build_has(BUILD_DEFAULT);
+    set_build_type(BUILD_BINARY) if build_has_any(BUILD_DEFAULT);
     # -nc with -S implies no dependency checks
     $checkbuilddep = 0 if build_is(BUILD_SOURCE);
 }
@@ -438,7 +438,7 @@ if (not $signcommand) {
     $signchanges = 0;
 }
 
-if ($signsource && build_has_not(BUILD_SOURCE)) {
+if ($signsource && build_has_none(BUILD_SOURCE)) {
     $signsource = 0;
 }
 
@@ -462,8 +462,8 @@ unless ($call_target) {
 if ($checkbuilddep) {
     my @checkbuilddep_opts;
 
-    push @checkbuilddep_opts, '-A' if build_has_not(BUILD_ARCH_DEP);
-    push @checkbuilddep_opts, '-B' if build_has_not(BUILD_ARCH_INDEP);
+    push @checkbuilddep_opts, '-A' if build_has_none(BUILD_ARCH_DEP);
+    push @checkbuilddep_opts, '-B' if build_has_none(BUILD_ARCH_INDEP);
     push @checkbuilddep_opts, '-I' if not $check_builtin_builddep;
     push @checkbuilddep_opts, "--admindir=$admindir" if $admindir;
 
@@ -494,9 +494,9 @@ unless ($noclean) {
     withecho(@rootcommand, @debian_rules, 'clean');
 }
 
-run_hook('source', build_has(BUILD_SOURCE));
+run_hook('source', build_has_any(BUILD_SOURCE));
 
-if (build_has(BUILD_SOURCE)) {
+if (build_has_any(BUILD_SOURCE)) {
     warning(g_('building a source package without cleaning up as you asked; ' .
                'it might contain undesired files')) if $noclean;
     chdir('..') or syserr('chdir ..');
diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl
index 85778a5..016cc5e 100755
--- a/scripts/dpkg-genchanges.pl
+++ b/scripts/dpkg-genchanges.pl
@@ -230,7 +230,7 @@ foreach (keys %{$src_fields}) {
 my $dist = Dpkg::Dist::Files->new();
 my $origsrcmsg;
 
-if (build_has(BUILD_SOURCE)) {
+if (build_has_any(BUILD_SOURCE)) {
     my $sec = $sourcedefault{'Section'} // '-';
     my $pri = $sourcedefault{'Priority'} // '-';
     warning(g_('missing Section for source files')) if $sec eq '-';
@@ -333,8 +333,8 @@ foreach my $pkg ($control->get_packages()) {
 
     if (not defined($p2f{$p})) {
 	# No files for this package... warn if it's unexpected
-	if (((build_has(BUILD_ARCH_INDEP) and debarch_eq('all', $a)) or
-	     (build_has(BUILD_ARCH_DEP) and
+	if (((build_has_any(BUILD_ARCH_INDEP) and debarch_eq('all', $a)) or
+	     (build_has_any(BUILD_ARCH_DEP) and
 	      (any { debarch_is($host_arch, $_) } debarch_list_parse($a)))) and
 	    (@restrictions == 0 or
 	     evaluate_restriction_formula(\@restrictions, \@profiles)))
@@ -353,7 +353,7 @@ foreach my $pkg ($control->get_packages()) {
 	} elsif (m/^Priority$/) {
 	    $f2pricf{$_} = $v foreach (@f);
 	} elsif (m/^Architecture$/) {
-	    if (build_has(BUILD_ARCH_DEP) and
+	    if (build_has_any(BUILD_ARCH_DEP) and
 	        (any { debarch_is($host_arch, $_) } debarch_list_parse($v))) {
 		$v = $host_arch;
 	    } elsif (!debarch_eq('all', $v)) {
@@ -432,12 +432,12 @@ if (length($fields->{'Binary'}) > 980) {
     $fields->{'Binary'} =~ s/(.{0,980}) /$1\n/g;
 }
 
-unshift @archvalues, 'source' if build_has(BUILD_SOURCE);
+unshift @archvalues, 'source' if build_has_any(BUILD_SOURCE);
 @archvalues = ('all') if build_is(BUILD_ARCH_INDEP);
 @archvalues = grep { !debarch_eq('all', $_) } @archvalues
-    if build_has_not(BUILD_ARCH_INDEP);
+    if build_has_none(BUILD_ARCH_INDEP);
 @archvalues = grep { !debarch_eq($host_arch, $_) } @archvalues
-    if build_has_not(BUILD_ARCH_DEP);
+    if build_has_none(BUILD_ARCH_DEP);
 $fields->{'Architecture'} = join ' ', @archvalues;
 
 $fields->{'Built-For-Profiles'} = join ' ', get_build_profiles();
@@ -452,8 +452,8 @@ for my $file ($dist->get_files()) {
     if (defined $file->{package} && $file->{package_type} =~ m/^u?deb$/) {
         my $arch_all = debarch_eq('all', $file->{arch});
 
-        next if build_has_not(BUILD_ARCH_INDEP) and $arch_all;
-        next if build_has_not(BUILD_ARCH_DEP) and not $arch_all;
+        next if build_has_none(BUILD_ARCH_INDEP) and $arch_all;
+        next if build_has_none(BUILD_ARCH_DEP) and not $arch_all;
     }
     $checksums->add_from_file("$uploadfilesdir/$f", key => $f);
 }
diff --git a/scripts/t/Dpkg_Build_Types.t b/scripts/t/Dpkg_Build_Types.t
index b3229f5..0fdfbed 100644
--- a/scripts/t/Dpkg_Build_Types.t
+++ b/scripts/t/Dpkg_Build_Types.t
@@ -32,13 +32,13 @@ set_build_type(BUILD_SOURCE | BUILD_ARCH_INDEP, '--build=source,all');
 
 ok(build_is(BUILD_SOURCE | BUILD_ARCH_INDEP), 'build source,all is source,all');
 ok(!build_is(BUILD_SOURCE | BUILD_ARCH_DEP), 'build source,all is not source,any');
-ok(build_has(BUILD_SOURCE), 'build source indep has source');
-ok(build_has(BUILD_ARCH_INDEP), 'build source indep has arch indep');
-ok(build_has_not(BUILD_DEFAULT), 'build source indep has not default');
-ok(build_has_not(BUILD_ARCH_DEP), 'build source indep has not arch dep');
-ok(build_has_not(BUILD_BINARY), 'build source indep has not binary');
-ok(build_has_not(BUILD_SOURCE | BUILD_ARCH_DEP),
-   'build source,all has_not source,any');
-ok(build_has_not(BUILD_FULL), 'build source indep has not full');
+ok(build_has_any(BUILD_SOURCE), 'build source,all has_any source');
+ok(build_has_any(BUILD_ARCH_INDEP), 'build source,all has_any any');
+ok(build_has_none(BUILD_DEFAULT), 'build source,all has_none default');
+ok(build_has_none(BUILD_ARCH_DEP), 'build source,all has_none any');
+ok(!build_has_all(BUILD_BINARY), 'build source,all not has_all binary');
+ok(!build_has_all(BUILD_SOURCE | BUILD_ARCH_DEP),
+   'build source,all not has_all source,any');
+ok(!build_has_all(BUILD_FULL), 'build source,all has_all full');
 
 1;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list