diff options
author | Jan-Simon Möller <jsmoeller@linuxfoundation.org> | 2021-02-20 18:29:33 +0100 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2021-03-05 04:40:01 -1000 |
commit | 72daea3a413ff0a8ded76a494d673c5264535426 (patch) | |
tree | f756a5dccc5932f5c9b1794ddf5e6dac0e510350 /meta/classes | |
parent | b6d941126e92e26ae26cc4550c6849829eb88af9 (diff) | |
download | openembedded-core-contrib-72daea3a413ff0a8ded76a494d673c5264535426.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
Signed-off-by: Jan-Simon Möller <jsmoeller@linuxfoundation.org>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 9a1dde74e794362399193dc3f81c9685a83d0776)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/reproducible_build.bbclass | 19 |
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 @@ BUILD_REPRODUCIBLE_BINARIES ??= '1' inherit ${@oe.utils.ifelse(d.getVar('BUILD_REPRODUCIBLE_BINARIES') == '1', 'reproducible_build_simple', '')} -SDE_DIR ="${WORKDIR}/source-date-epoch" +SDE_DIR = "${WORKDIR}/source-date-epoch" SDE_FILE = "${SDE_DIR}/__source_date_epoch.txt" SDE_DEPLOYDIR = "${WORKDIR}/deploy-source-date-epoch" +# A SOURCE_DATE_EPOCH of '0' might be misinterpreted as no SDE +export SOURCE_DATE_EPOCH_FALLBACK ??= "1302044400" + SSTATETASKS += "do_deploy_source_date_epoch" do_deploy_source_date_epoch () { @@ -81,6 +84,10 @@ python create_source_date_epoch_stamp() { source_date_epoch = oe.reproducible.get_source_date_epoch(d, d.getVar('S')) + if source_date_epoch == 0 : + bb.debug(1, "source_date_epoch is 0, using SOURCE_DATE_EPOCH_FALLBACK instead.") + source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK')) + bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch) bb.utils.mkdirhier(d.getVar('SDE_DIR')) with open(epochfile, 'w') as f: @@ -93,15 +100,19 @@ def get_source_date_epoch_value(d): return cached epochfile = d.getVar('SDE_FILE') - source_date_epoch = 0 + source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK')) if os.path.isfile(epochfile): with open(epochfile, 'r') as f: s = f.read() try: source_date_epoch = int(s) + # workaround for old sstate with SDE_FILE content being 0 - use SOURCE_DATE_EPOCH_FALLBACK + if source_date_epoch == 0 : + source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK')) + bb.warn("SOURCE_DATE_EPOCH value from sstate '%s' is deprecated/invalid. Reverting to SOURCE_DATE_EPOCH_FALLBACK '%s'" % (s, source_date_epoch)) except ValueError: - bb.warn("SOURCE_DATE_EPOCH value '%s' is invalid. Reverting to 0" % s) - source_date_epoch = 0 + bb.warn("SOURCE_DATE_EPOCH value '%s' is invalid. Reverting to SOURCE_DATE_EPOCH_FALLBACK" % s) + source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK')) bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch) else: bb.debug(1, "Cannot find %s. SOURCE_DATE_EPOCH will default to %d" % (epochfile, source_date_epoch)) |