xref: /OK3568_Linux_fs/yocto/poky/meta/recipes-bsp/grub/files/determinism.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From b6f9b3f6fa782807c4a7ec16ee8ef868cdfbf468 Mon Sep 17 00:00:00 2001
2From: Naveen Saini <naveen.kumar.saini@intel.com>
3Date: Mon, 15 Mar 2021 14:56:18 +0800
4Subject: [PATCH] The output in moddep.lst generated from syminfo.lst using
5 genmoddep.awk is not deterministic since the order of the dependencies on
6 each line can vary depending on how awk sorts the values in the array.
7
8Be deterministic in the output by sorting the dependencies on each line.
9
10Also, the output of the SOURCES lines in grub-core/Makefile.core.am, generated
11from grub-core/Makefile.core.def with gentpl.py is not deterministic due to
12missing sorting of the list used to generate it. Add such a sort.
13
14Also ensure the generated unidata.c file is deterministic by sorting the
15keys of the dict.
16
17Upstream-Status: Pending
18Richard Purdie <richard.purdie@linuxfoundation.org>
19Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
20---
21 gentpl.py               | 1 +
22 grub-core/genmoddep.awk | 4 +++-
23 util/import_unicode.py  | 2 +-
24 3 files changed, 5 insertions(+), 2 deletions(-)
25
26diff --git a/gentpl.py b/gentpl.py
27index c86550d4f..589285192 100644
28--- a/gentpl.py
29+++ b/gentpl.py
30@@ -568,6 +568,7 @@ def foreach_platform_value(defn, platform, suffix, closure):
31     for group in RMAP[platform]:
32         for value in defn.find_all(group + suffix):
33             r.append(closure(value))
34+    r.sort()
35     return ''.join(r)
36
37 def platform_conditional(platform, closure):
38diff --git a/grub-core/genmoddep.awk b/grub-core/genmoddep.awk
39index 04c2863e5..247436392 100644
40--- a/grub-core/genmoddep.awk
41+++ b/grub-core/genmoddep.awk
42@@ -59,7 +59,9 @@ END {
43     }
44     modlist = ""
45     depcount[mod] = 0
46-    for (depmod in uniqmods) {
47+    n = asorti(uniqmods, w)
48+    for (i = 1; i <= n; i++) {
49+      depmod = w[i]
50       modlist = modlist " " depmod;
51       inverse_dependencies[depmod] = inverse_dependencies[depmod] " " mod
52       depcount[mod]++
53diff --git a/util/import_unicode.py b/util/import_unicode.py
54index 08f80591e..1f434a069 100644
55--- a/util/import_unicode.py
56+++ b/util/import_unicode.py
57@@ -174,7 +174,7 @@ infile.close ()
58
59 outfile.write ("struct grub_unicode_arabic_shape grub_unicode_arabic_shapes[] = {\n ")
60
61-for x in arabicsubst:
62+for x in sorted(arabicsubst):
63     try:
64         if arabicsubst[x]['join'] == "DUAL":
65             outfile.write ("{0x%x, 0x%x, 0x%x, 0x%x, 0x%x},\n " % (arabicsubst[x][0], arabicsubst[x][1], arabicsubst[x][2], arabicsubst[x][3], arabicsubst[x][4]))
66--
672.17.1
68
69