[dpkg] 133/200: dpkg-genchanges: Invert the binary distribution loop inside-out

Ximin Luo infinity0 at debian.org
Wed Apr 5 15:17:28 UTC 2017


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

infinity0 pushed a commit to branch master
in repository dpkg.

commit c253c35957ecb2964774a28b0daa7e54275a7de9
Author: Guillem Jover <guillem at debian.org>
Date:   Fri Jan 27 03:51:57 2017 +0100

    dpkg-genchanges: Invert the binary distribution loop inside-out
    
    Move the if conditional from outside to inside the loop, this way
    removing one nesting level.
---
 scripts/dpkg-genchanges.pl | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl
index 2c3316d..6de26c8 100755
--- a/scripts/dpkg-genchanges.pl
+++ b/scripts/dpkg-genchanges.pl
@@ -301,22 +301,23 @@ if (build_has_any(BUILD_SOURCE)) {
     $origsrcmsg = g_('binary-only upload (no source code included)');
 }
 
-if (build_has_any(BUILD_BINARY)) {
-    my $dist_count = 0;
+my $dist_count = 0;
 
-    $dist_count = $dist->load($fileslistfile) if -e $fileslistfile;
+$dist_count = $dist->load($fileslistfile) if -e $fileslistfile;
 
-    error(g_('binary build with no binary artifacts found; cannot distribute'))
-        if $dist_count == 0;
+error(g_('binary build with no binary artifacts found; cannot distribute'))
+    if build_has_any(BUILD_BINARY) && $dist_count == 0;
 
-    foreach my $file ($dist->get_files()) {
-        if (defined $file->{package} && $file->{package_type} =~ m/^u?deb$/) {
-            $p2f{$file->{package}} //= [];
-            push @{$p2f{$file->{package}}}, $file->{filename};
+foreach my $file ($dist->get_files()) {
+    # If this is a source-only upload, ignore any other artifacts.
+    next if build_has_none(BUILD_BINARY);
 
-            push @archvalues, $file->{arch}
-                if defined $file->{arch} and not $archadded{$file->{arch}}++;
-        }
+    if (defined $file->{package} && $file->{package_type} =~ m/^u?deb$/) {
+        $p2f{$file->{package}} //= [];
+        push @{$p2f{$file->{package}}}, $file->{filename};
+
+        push @archvalues, $file->{arch}
+            if defined $file->{arch} and not $archadded{$file->{arch}}++;
     }
 }
 

-- 
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