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

guillem pushed a commit to branch master
in repository dpkg.

commit e974a079d91f1dcb0eb2b61fe3c825d714f299d6
Author: Guillem Jover <[email protected]>
Date:   Mon Apr 27 15:11:21 2015 +0200

    Dpkg::Dist::Files: Always sort the files list on output
    
    This guarantees the debian/files and anything parsing it via this module
    get reproducible results regardless of things such as parallel builds.
    
    Reported-by: Jérémy Bobbio <[email protected]>
---
 debian/changelog            |  3 +++
 scripts/Dpkg/Dist/Files.pm  | 14 +++-----------
 scripts/t/Dpkg_Dist_Files.t | 18 ++++++++++--------
 3 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 14dd1eb..173a876 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -90,6 +90,9 @@ dpkg (1.18.0) UNRELEASED; urgency=low
       Closes: #782019
     - Do not print on undef filehandle in Dpkg::Control::Info output().
       Thanks to Roderich Schupp <[email protected]>. Closes: #781887
+    - Always sort the Dpkg::Dist::Files files list on output, instead of
+      preserving the insertion order, which is not reproducible with parallel
+      builds. Reported by Jérémy Bobbio <[email protected]>.
   * Test suite:
     - Check perl code compilation, warnings and strictness.
     - Fix dpkg-divert unit test to work on BSD «rm -rf» that cannot traverse
diff --git a/scripts/Dpkg/Dist/Files.pm b/scripts/Dpkg/Dist/Files.pm
index c28c4eb..bb44172 100644
--- a/scripts/Dpkg/Dist/Files.pm
+++ b/scripts/Dpkg/Dist/Files.pm
@@ -1,4 +1,4 @@
-# Copyright © 2014 Guillem Jover <[email protected]>
+# Copyright © 2014-2015 Guillem Jover <[email protected]>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -32,7 +32,6 @@ sub new {
     my $self = {
         options => [],
         files => {},
-        order => [],
     };
     foreach my $opt (keys %opts) {
         $self->{$opt} = $opts{$opt};
@@ -76,7 +75,6 @@ sub parse {
         } else {
             $count++;
             $self->{files}->{$file{filename}} = \%file;
-            push @{$self->{order}}, $file{filename};
         }
     }
 
@@ -86,7 +84,7 @@ sub parse {
 sub get_files {
     my $self = shift;
 
-    return map { $self->{files}->{$_} } @{$self->{order}};
+    return map { $self->{files}->{$_} } sort keys %{$self->{files}};
 }
 
 sub get_file {
@@ -102,10 +100,6 @@ sub add_file {
     # on parse(), and initialize the other attributes, although no code is
     # in need of this for now, at least in dpkg-dev.
 
-    if (not defined $self->{files}->{$filename}) {
-        push @{$self->{order}}, $filename;
-    }
-
     $self->{files}->{$filename} = {
         filename => $filename,
         section => $section,
@@ -117,8 +111,6 @@ sub del_file {
     my ($self, $filename) = @_;
 
     delete $self->{files}->{$filename};
-
-    @{$self->{order}} = grep { $_ ne $filename } @{$self->{order}};
 }
 
 sub output {
@@ -127,7 +119,7 @@ sub output {
 
     binmode $fh if defined $fh;
 
-    foreach my $filename (@{$self->{order}}) {
+    foreach my $filename (sort keys %{$self->{files}}) {
         my $file = $self->{files}->{$filename};
         my $entry = "$filename $file->{section} $file->{priority}\n";
 
diff --git a/scripts/t/Dpkg_Dist_Files.t b/scripts/t/Dpkg_Dist_Files.t
index d01ad68..019bbe7 100644
--- a/scripts/t/Dpkg_Dist_Files.t
+++ b/scripts/t/Dpkg_Dist_Files.t
@@ -67,12 +67,13 @@ my %expected = (
 my $dist = Dpkg::Dist::Files->new();
 $dist->load("$datadir/files-byhand") or error('cannot parse file');
 
-$expected = 'pkg-templ_1.2.3_arch.type section priority
+$expected = <<'FILES';
+BY-HAND-file webdocs optional
+other_0.txt text optional
 pkg-arch_2.0.0_amd64.deb admin required
 pkg-indep_0.0.1-2_all.deb net standard
-other_0.txt text optional
-BY-HAND-file webdocs optional
-';
+pkg-templ_1.2.3_arch.type section priority
+FILES
 
 is($dist->output(), $expected, 'Parsed dist file');
 foreach my $f ($dist->get_files()) {
@@ -86,12 +87,13 @@ foreach my $f ($dist->get_files()) {
               "Detail for individual dist file $filename, via get_file()");
 }
 
-$expected = 'pkg-templ_1.2.3_arch.type section priority
-pkg-arch_2.0.0_amd64.deb void imperative
-other_0.txt text optional
+$expected = <<'FILES';
 BY-HAND-file webdocs optional
 added-on-the-fly void wish
-';
+other_0.txt text optional
+pkg-arch_2.0.0_amd64.deb void imperative
+pkg-templ_1.2.3_arch.type section priority
+FILES
 
 $dist->add_file('added-on-the-fly', 'void', 'wish');
 $dist->add_file('pkg-arch_2.0.0_amd64.deb', 'void', 'imperative');

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


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to