summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorJan-Simon Möller <jsmoeller@linuxfoundation.org>2021-02-20 18:29:33 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-02-24 00:19:38 +0000
commit7e9c2f33d4ea9f6449dd56d19ff4522a9ddc2df1 (patch)
treebe233f9a5727c4766205ba352dab7996b3aa3b5c /meta
parente9e23ec77e0fb8fcbcb6684059fe0cadd99e2c04 (diff)
downloadpoky-7e9c2f33d4ea9f6449dd56d19ff4522a9ddc2df1.tar.gz
reproducible_builds: SOURCE_DATE_EPOCH should not be 0
A SOURCE_DATE_EPOCH of 0 might be misinterpreted by namely rpm as no SDE. e.g.: char *srcdate = getenv(SOURCE_DATE_EPOCH); if (srcdate && rpmExpandNumeric(%{?clamp_mtime_to_source_date_epoch})) Solve this by: - providing a SOURCE_DATE_EPOCH_FALLBACK variable != 0 - changing defaults to use it - using SOURCE_DATE_EPOCH_FALLBACK also when reading 0 out of sstate-cache (From OE-Core rev: 9a1dde74e794362399193dc3f81c9685a83d0776) Signed-off-by: Jan-Simon Möller <jsmoeller@linuxfoundation.org> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/reproducible_build.bbclass19
1 files changed, 15 insertions, 4 deletions
diff --git a/meta/classes/reproducible_build.bbclass b/meta/classes/reproducible_build.bbclass
index 2f3bd90b07..9e806c0b75 100644
--- a/meta/classes/reproducible_build.bbclass
+++ b/meta/classes/reproducible_build.bbclass
@@ -37,10 +37,13 @@
37BUILD_REPRODUCIBLE_BINARIES ??= '1' 37BUILD_REPRODUCIBLE_BINARIES ??= '1'
38inherit ${@oe.utils.ifelse(d.getVar('BUILD_REPRODUCIBLE_BINARIES') == '1', 'reproducible_build_simple', '')} 38inherit ${@oe.utils.ifelse(d.getVar('BUILD_REPRODUCIBLE_BINARIES') == '1', 'reproducible_build_simple', '')}
39 39
40SDE_DIR ="${WORKDIR}/source-date-epoch" 40SDE_DIR = "${WORKDIR}/source-date-epoch"
41SDE_FILE = "${SDE_DIR}/__source_date_epoch.txt" 41SDE_FILE = "${SDE_DIR}/__source_date_epoch.txt"
42SDE_DEPLOYDIR = "${WORKDIR}/deploy-source-date-epoch" 42SDE_DEPLOYDIR = "${WORKDIR}/deploy-source-date-epoch"
43 43
44# A SOURCE_DATE_EPOCH of '0' might be misinterpreted as no SDE
45export SOURCE_DATE_EPOCH_FALLBACK ??= "1302044400"
46
44SSTATETASKS += "do_deploy_source_date_epoch" 47SSTATETASKS += "do_deploy_source_date_epoch"
45 48
46do_deploy_source_date_epoch () { 49do_deploy_source_date_epoch () {
@@ -81,6 +84,10 @@ python create_source_date_epoch_stamp() {
81 84
82 source_date_epoch = oe.reproducible.get_source_date_epoch(d, d.getVar('S')) 85 source_date_epoch = oe.reproducible.get_source_date_epoch(d, d.getVar('S'))
83 86
87 if source_date_epoch == 0 :
88 bb.debug(1, "source_date_epoch is 0, using SOURCE_DATE_EPOCH_FALLBACK instead.")
89 source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK'))
90
84 bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch) 91 bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch)
85 bb.utils.mkdirhier(d.getVar('SDE_DIR')) 92 bb.utils.mkdirhier(d.getVar('SDE_DIR'))
86 with open(epochfile, 'w') as f: 93 with open(epochfile, 'w') as f:
@@ -93,15 +100,19 @@ def get_source_date_epoch_value(d):
93 return cached 100 return cached
94 101
95 epochfile = d.getVar('SDE_FILE') 102 epochfile = d.getVar('SDE_FILE')
96 source_date_epoch = 0 103 source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK'))
97 if os.path.isfile(epochfile): 104 if os.path.isfile(epochfile):
98 with open(epochfile, 'r') as f: 105 with open(epochfile, 'r') as f:
99 s = f.read() 106 s = f.read()
100 try: 107 try:
101 source_date_epoch = int(s) 108 source_date_epoch = int(s)
109 # workaround for old sstate with SDE_FILE content being 0 - use SOURCE_DATE_EPOCH_FALLBACK
110 if source_date_epoch == 0 :
111 source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK'))
112 bb.warn("SOURCE_DATE_EPOCH value from sstate '%s' is deprecated/invalid. Reverting to SOURCE_DATE_EPOCH_FALLBACK '%s'" % (s, source_date_epoch))
102 except ValueError: 113 except ValueError:
103 bb.warn("SOURCE_DATE_EPOCH value '%s' is invalid. Reverting to 0" % s) 114 bb.warn("SOURCE_DATE_EPOCH value '%s' is invalid. Reverting to SOURCE_DATE_EPOCH_FALLBACK" % s)
104 source_date_epoch = 0 115 source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK'))
105 bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch) 116 bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch)
106 else: 117 else:
107 bb.debug(1, "Cannot find %s. SOURCE_DATE_EPOCH will default to %d" % (epochfile, source_date_epoch)) 118 bb.debug(1, "Cannot find %s. SOURCE_DATE_EPOCH will default to %d" % (epochfile, source_date_epoch))