|
0 |
Make texino indices reproducible by genrating deterministic order
|
|
1 |
From Debian #790065
|
|
2 |
While working on the "reproducible builds" effort [1], we have noticed
|
|
3 |
that texinfo generates indices in a non-deterministic order.
|
|
4 |
|
|
5 |
This appears to happen because the index sort is not stable with respect
|
|
6 |
to the line number, resulting in output non-determinstically changing
|
|
7 |
from:
|
|
8 |
|
|
9 |
* Entry (line 1)
|
|
10 |
* Entry (line 2)
|
|
11 |
|
|
12 |
and
|
|
13 |
|
|
14 |
* Entry (line 2)
|
|
15 |
* Entry (line 1)
|
|
16 |
|
|
17 |
.. when the entry is the same string.
|
|
18 |
|
|
19 |
The attached patch adds the line number to the sort comparator. Once
|
|
20 |
applied, (some) packages using texinfo can be built reproducibly in
|
|
21 |
our reproducible toolchain.
|
|
22 |
|
|
23 |
Patch by Chris Lamb
|
|
24 |
---
|
|
25 |
tp/Texinfo/Structuring.pm | 4 ++++
|
|
26 |
1 file changed, 4 insertions(+)
|
|
27 |
|
|
28 |
--- texinfo.orig/tp/Texinfo/Structuring.pm
|
|
29 |
+++ texinfo/tp/Texinfo/Structuring.pm
|
|
30 |
@@ -1984,6 +1984,9 @@
|
|
31 |
if ($res == 0) {
|
|
32 |
$res = ($key1->{'number'} <=> $key2->{'number'});
|
|
33 |
}
|
|
34 |
+ if ($res == 0) {
|
|
35 |
+ $res = ($key1->{'line_nr'} <=> $key2->{'line_nr'});
|
|
36 |
+ }
|
|
37 |
return $res;
|
|
38 |
}
|
|
39 |
|
|
40 |
@@ -2016,6 +2019,7 @@
|
|
41 |
foreach my $index_name (keys(%$index_entries)) {
|
|
42 |
foreach my $entry (@{$index_entries->{$index_name}}) {
|
|
43 |
$entry->{'in_code'} = $index_names->{$entry->{'index_name'}}->{'in_code'};
|
|
44 |
+ $entry->{'line_nr'} = $entry->{'command'}->{'line_nr'}->{'line_nr'};
|
|
45 |
$options->{'code'} = $entry->{'in_code'};
|
|
46 |
$entry->{'key'} = Texinfo::Convert::Text::convert(
|
|
47 |
{'contents' => $entry->{'content'}}, $options);
|