summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-14 12:17:55 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-16 17:35:01 +0100
commitf2fd1c9d75e774c8a5271cdc1ec6f65c4492f941 (patch)
tree5ba16022ad6aed0c4098533eb211185df03689eb /meta/classes
parent80afddd3ae862b125f674702aff6330e87d55338 (diff)
downloadopenembedded-core-f2fd1c9d75e774c8a5271cdc1ec6f65c4492f941.tar.gz
reproducible: Move class function code into library
To try and avoid parse/memory overhead of functions within bitbake, move the bulk of the reproducibility functions to the function library. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/base.bbclass2
-rw-r--r--meta/classes/reproducible_build.bbclass37
2 files changed, 3 insertions, 36 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 59fd46e5d4..bca3944ae7 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -12,7 +12,7 @@ inherit logging
OE_EXTRA_IMPORTS ?= ""
-OE_IMPORTS += "os sys time oe.path oe.utils oe.types oe.package oe.packagegroup oe.sstatesig oe.lsb oe.cachedpath oe.license oe.qa ${OE_EXTRA_IMPORTS}"
+OE_IMPORTS += "os sys time oe.path oe.utils oe.types oe.package oe.packagegroup oe.sstatesig oe.lsb oe.cachedpath oe.license oe.qa oe.reproducible ${OE_EXTRA_IMPORTS}"
OE_IMPORTS[type] = "list"
PACKAGECONFIG_CONFARGS ??= ""
diff --git a/meta/classes/reproducible_build.bbclass b/meta/classes/reproducible_build.bbclass
index 3f661794c6..0f45b782e5 100644
--- a/meta/classes/reproducible_build.bbclass
+++ b/meta/classes/reproducible_build.bbclass
@@ -91,19 +91,8 @@ addtask do_deploy_source_date_epoch_setscene
addtask do_deploy_source_date_epoch before do_configure after do_patch
python create_source_date_epoch_stamp() {
- import oe.reproducible
-
- epochfile = d.getVar('SDE_FILE')
- tmp_file = "%s.new" % epochfile
-
source_date_epoch = oe.reproducible.get_source_date_epoch(d, d.getVar('S'))
-
- bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch)
- bb.utils.mkdirhier(d.getVar('SDE_DIR'))
- with open(tmp_file, 'w') as f:
- f.write(str(source_date_epoch))
-
- os.rename(tmp_file, epochfile)
+ oe.reproducible.epochfile_write(source_date_epoch, d.getVar('SDE_FILE'), d)
}
EPOCHTASK = "do_deploy_source_date_epoch"
@@ -112,29 +101,7 @@ EPOCHTASK = "do_deploy_source_date_epoch"
do_unpack[postfuncs] += "create_source_date_epoch_stamp"
def get_source_date_epoch_value(d):
- epochfile = d.getVar('SDE_FILE')
- cached, efile = d.getVar('__CACHED_SOURCE_DATE_EPOCH') or (None, None)
- if cached and efile == epochfile:
- return cached
-
- if cached and epochfile != efile:
- bb.debug(1, "Epoch file changed from %s to %s" % (efile, epochfile))
-
- source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK'))
- try:
- with open(epochfile, 'r') as f:
- s = f.read()
- try:
- source_date_epoch = int(s)
- except ValueError:
- 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)
- except FileNotFoundError:
- bb.debug(1, "Cannot find %s. SOURCE_DATE_EPOCH will default to %d" % (epochfile, source_date_epoch))
-
- d.setVar('__CACHED_SOURCE_DATE_EPOCH', (str(source_date_epoch), epochfile))
- return str(source_date_epoch)
+ return oe.reproducible.epochfile_read(d.getVar('SDE_FILE'), d)
export SOURCE_DATE_EPOCH ?= "${@get_source_date_epoch_value(d)}"
BB_HASHBASE_WHITELIST += "SOURCE_DATE_EPOCH"