summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-03 20:12:26 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-04 15:03:54 +0100
commit80f2b56ad8c270269d9f7f65cc114d8f13f9dfbb (patch)
treec0f44f29532defdf6d7f3fb7b9a5b94de715df5e
parenta26db5c9447679eba709aec1cacf6766feb1f312 (diff)
downloadpoky-80f2b56ad8c270269d9f7f65cc114d8f13f9dfbb.tar.gz
reproducible_build: Work around caching issues
SOURCE_DATE_EPOCH can be expanded early in the parsing process before the class extensions are applied. This can mean the directory pointed to for the SDE can be incorrect until later in parsing. Cache the file name in the cached value and allow it to dynamically update. This isn't ideal but avoding expansion of the variable likely isn't possible and I'm not sure how else to handle this. This works around the issue until a better solution can be found. (From OE-Core rev: 44dc97cd1223e4d2b635669627ec5f796838d42d) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/reproducible_build.bbclass11
1 files changed, 7 insertions, 4 deletions
diff --git a/meta/classes/reproducible_build.bbclass b/meta/classes/reproducible_build.bbclass
index 89f645b858..7571c116c8 100644
--- a/meta/classes/reproducible_build.bbclass
+++ b/meta/classes/reproducible_build.bbclass
@@ -115,11 +115,14 @@ EPOCHTASK = "do_deploy_source_date_epoch"
115do_unpack[postfuncs] += "create_source_date_epoch_stamp" 115do_unpack[postfuncs] += "create_source_date_epoch_stamp"
116 116
117def get_source_date_epoch_value(d): 117def get_source_date_epoch_value(d):
118 cached = d.getVar('__CACHED_SOURCE_DATE_EPOCH') 118 epochfile = d.getVar('SDE_FILE')
119 if cached: 119 cached, efile = d.getVar('__CACHED_SOURCE_DATE_EPOCH') or (None, None)
120 if cached and efile == epochfile:
120 return cached 121 return cached
121 122
122 epochfile = d.getVar('SDE_FILE') 123 if cached and epochfile != efile:
124 bb.debug(1, "Epoch file changed from %s to %s" % (efile, epochfile))
125
123 source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK')) 126 source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK'))
124 try: 127 try:
125 with open(epochfile, 'r') as f: 128 with open(epochfile, 'r') as f:
@@ -137,7 +140,7 @@ def get_source_date_epoch_value(d):
137 except FileNotFoundError: 140 except FileNotFoundError:
138 bb.debug(1, "Cannot find %s. SOURCE_DATE_EPOCH will default to %d" % (epochfile, source_date_epoch)) 141 bb.debug(1, "Cannot find %s. SOURCE_DATE_EPOCH will default to %d" % (epochfile, source_date_epoch))
139 142
140 d.setVar('__CACHED_SOURCE_DATE_EPOCH', str(source_date_epoch)) 143 d.setVar('__CACHED_SOURCE_DATE_EPOCH', (str(source_date_epoch), epochfile))
141 return str(source_date_epoch) 144 return str(source_date_epoch)
142 145
143export SOURCE_DATE_EPOCH ?= "${@get_source_date_epoch_value(d)}" 146export SOURCE_DATE_EPOCH ?= "${@get_source_date_epoch_value(d)}"