From e974a079d91f1dcb0eb2b61fe3c825d714f299d6 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 27 Apr 2015 15:11:21 +0200 Subject: Dpkg::Dist::Files: Always sort the files list on output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- scripts/Dpkg/Dist/Files.pm | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'scripts/Dpkg') diff --git a/scripts/Dpkg/Dist/Files.pm b/scripts/Dpkg/Dist/Files.pm index c28c4eb0c..bb44172ce 100644 --- a/scripts/Dpkg/Dist/Files.pm +++ b/scripts/Dpkg/Dist/Files.pm @@ -1,4 +1,4 @@ -# Copyright © 2014 Guillem Jover +# Copyright © 2014-2015 Guillem Jover # # 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"; -- cgit v1.2.3