summaryrefslogtreecommitdiffstats
path: root/meta/classes/reproducible_build.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/reproducible_build.bbclass')
-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}