summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Watt <jpewhacker@gmail.com>2020-01-31 13:04:16 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-02-11 23:05:12 +0000
commit632bbf4bd78690d787a188ca1185f46c5dca1d98 (patch)
tree7373b865e52684e2080800129e87a1a3d7bba193
parente8c813141d2aaf74361cf95060eaf428a4bc2c33 (diff)
downloadpoky-632bbf4bd78690d787a188ca1185f46c5dca1d98.tar.gz
classes/reproducible_build: Read SDE file later
Defers the resolution of the SOURCE_DATE_EPOCH until the variable needs to be actually realized with a value. The previous method of loading the value in anonymous python had issues because it could occur before other anonymous python functions that affect the location of the epoch file, such as when a recipe uses AUTOINC/AUTOREV or allarch.bbclass. Also adds more logging to help diagnose issues in the future. [YOCTO #13763] (From OE-Core rev: b3313a10a3eb93f0a3710a35de0404fb49cd6202) (From OE-Core rev: 10515e5f7e38edbc4430e2599062a9ce6fdb42a8) (From OE-Core rev: 81d3832728aeae0e02e775bab9fc13e159fb61d3) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/reproducible_build.bbclass40
1 files changed, 31 insertions, 9 deletions
diff --git a/meta/classes/reproducible_build.bbclass b/meta/classes/reproducible_build.bbclass
index 39b6e40cac..750eb950f2 100644
--- a/meta/classes/reproducible_build.bbclass
+++ b/meta/classes/reproducible_build.bbclass
@@ -44,10 +44,12 @@ SDE_DEPLOYDIR = "${WORKDIR}/deploy-source-date-epoch"
44SSTATETASKS += "do_deploy_source_date_epoch" 44SSTATETASKS += "do_deploy_source_date_epoch"
45 45
46do_deploy_source_date_epoch () { 46do_deploy_source_date_epoch () {
47 echo "Deploying SDE to ${SDE_DIR}."
48 mkdir -p ${SDE_DEPLOYDIR} 47 mkdir -p ${SDE_DEPLOYDIR}
49 if [ -e ${SDE_FILE} ]; then 48 if [ -e ${SDE_FILE} ]; then
49 echo "Deploying SDE from ${SDE_FILE} -> ${SDE_DEPLOYDIR}."
50 cp -p ${SDE_FILE} ${SDE_DEPLOYDIR}/__source_date_epoch.txt 50 cp -p ${SDE_FILE} ${SDE_DEPLOYDIR}/__source_date_epoch.txt
51 else
52 echo "${SDE_FILE} not found!"
51 fi 53 fi
52} 54}
53 55
@@ -56,7 +58,11 @@ python do_deploy_source_date_epoch_setscene () {
56 bb.utils.mkdirhier(d.getVar('SDE_DIR')) 58 bb.utils.mkdirhier(d.getVar('SDE_DIR'))
57 sde_file = os.path.join(d.getVar('SDE_DEPLOYDIR'), '__source_date_epoch.txt') 59 sde_file = os.path.join(d.getVar('SDE_DEPLOYDIR'), '__source_date_epoch.txt')
58 if os.path.exists(sde_file): 60 if os.path.exists(sde_file):
59 os.rename(sde_file, d.getVar('SDE_FILE')) 61 target = d.getVar('SDE_FILE')
62 bb.debug(1, "Moving setscene SDE file %s -> %s" % (sde_file, target))
63 os.rename(sde_file, target)
64 else:
65 bb.debug(1, "%s not found!" % sde_file)
60} 66}
61 67
62do_deploy_source_date_epoch[dirs] = "${SDE_DEPLOYDIR}" 68do_deploy_source_date_epoch[dirs] = "${SDE_DEPLOYDIR}"
@@ -164,16 +170,32 @@ python do_create_source_date_epoch_stamp() {
164 f.write(str(source_date_epoch)) 170 f.write(str(source_date_epoch))
165} 171}
166 172
173def get_source_date_epoch_value(d):
174 cached = d.getVar('__CACHED_SOURCE_DATE_EPOCH')
175 if cached:
176 return cached
177
178 epochfile = d.getVar('SDE_FILE')
179 source_date_epoch = 0
180 if os.path.isfile(epochfile):
181 with open(epochfile, 'r') as f:
182 s = f.read()
183 try:
184 source_date_epoch = int(s)
185 except ValueError:
186 bb.warn("SOURCE_DATE_EPOCH value '%s' is invalid. Reverting to 0" % s)
187 source_date_epoch = 0
188 bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch)
189 else:
190 bb.debug(1, "Cannot find %s. SOURCE_DATE_EPOCH will default to %d" % (epochfile, source_date_epoch))
191
192 d.setVar('__CACHED_SOURCE_DATE_EPOCH', str(source_date_epoch))
193 return str(source_date_epoch)
194
195export SOURCE_DATE_EPOCH ?= "${@get_source_date_epoch_value(d)}"
167BB_HASHBASE_WHITELIST += "SOURCE_DATE_EPOCH" 196BB_HASHBASE_WHITELIST += "SOURCE_DATE_EPOCH"
168 197
169python () { 198python () {
170 if d.getVar('BUILD_REPRODUCIBLE_BINARIES') == '1': 199 if d.getVar('BUILD_REPRODUCIBLE_BINARIES') == '1':
171 d.appendVarFlag("do_unpack", "postfuncs", " do_create_source_date_epoch_stamp") 200 d.appendVarFlag("do_unpack", "postfuncs", " do_create_source_date_epoch_stamp")
172 epochfile = d.getVar('SDE_FILE')
173 source_date_epoch = "0"
174 if os.path.isfile(epochfile):
175 with open(epochfile, 'r') as f:
176 source_date_epoch = f.read()
177 bb.debug(1, "SOURCE_DATE_EPOCH: %s" % source_date_epoch)
178 d.setVar('SOURCE_DATE_EPOCH', source_date_epoch)
179} 201}