Source: libdebian-copyright-perl
Version: 0.2-2
Severity: wishlist
Tags: patch
User: reproducible-bui...@lists.alioth.debian.org
Usertags: randomness toolchain
X-Debbugs-Cc: reproducible-bui...@lists.alioth.debian.org

Hi!

While working on the "reproducible builds" effort [1], we have noticed
that libdebian-copyright-perl doesn't produce reproducible copyright files [2].
The Files and License sections can appear in an unsorted order.

The attached patch fixes this by sorting Files sections by path, License
sections by name, and "x or y" listings.

Regards,
 Reiner

[1]: https://wiki.debian.org/ReproducibleBuilds
[2]: 
https://reproducible.debian.net/dbd/unstable/amd64/libcgi-application-plugin-devpopup-perl_1.08-1.debbindiff.html

diff --git a/debian/patches/reproducible-copyright.patch b/debian/patches/reproducible-copyright.patch
new file mode 100644
index 0000000..789cac2
--- /dev/null
+++ b/debian/patches/reproducible-copyright.patch
@@ -0,0 +1,47 @@
+Index: libdebian-copyright-perl-0.2/lib/Debian/Copyright.pm
+===================================================================
+--- libdebian-copyright-perl-0.2.orig/lib/Debian/Copyright.pm
++++ libdebian-copyright-perl-0.2/lib/Debian/Copyright.pm
+@@ -161,6 +161,9 @@ reference.
+ sub write {
+     my ( $self, $file ) = @_;
+ 
++    $self->files->SortByKey;
++    $self->licenses->SortByKey;
++
+     my @stanzas = (
+         $self->header,
+         $self->files->Values,
+Index: libdebian-copyright-perl-0.2/lib/Debian/Copyright/Stanza/OrSeparated.pm
+===================================================================
+--- libdebian-copyright-perl-0.2.orig/lib/Debian/Copyright/Stanza/OrSeparated.pm
++++ libdebian-copyright-perl-0.2/lib/Debian/Copyright/Stanza/OrSeparated.pm
+@@ -82,7 +82,7 @@ sub as_string
+ {
+     my $self = shift;
+     my $body = exists $self->{body} ? "\n$self->{body}" : "";
+-    return join( ' or ', @{ $self->{list} } ).$body;
++    return join( ' or ', sort @{ $self->{list} } ).$body;
+ }
+ 
+ =head2 equals
+Index: libdebian-copyright-perl-0.2/t/01.basic.t
+===================================================================
+--- libdebian-copyright-perl-0.2.orig/t/01.basic.t
++++ libdebian-copyright-perl-0.2/t/01.basic.t
+@@ -1,4 +1,4 @@
+-use Test::More tests => 36;
++use Test::More tests => 37;
+ 
+ use Debian::Copyright;
+ 
+@@ -61,7 +61,8 @@ is($copyright->licenses->Keys(0), 'Artis
+ like($copyright->licenses->Values(0)->License, qr/\AArtistic\s+This\sprogram/xms, 'licenses(0)->Files');
+ is($copyright->files->Keys(2), 'test/*', 'key files(2)');
+ is($copyright->files->Values(2)->Files, 'test/*', 'files(2)->Files');
+-is($copyright->licenses->Keys(2), 'BSD', 'key licenses(2)');
++is($copyright->licenses->Keys(1), 'BSD', 'key licenses(1)');
++is($copyright->licenses->Keys(2), 'GPL-2+', 'key licenses(2)');
+ 
+ my $copyright3 = Debian::Copyright->new;
+ isa_ok($copyright3, 'Debian::Copyright');
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..d855597
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+reproducible-copyright.patch

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to