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:41:59 +0100
commita28891c779fa85818a1572abfa8450e5930c01ca (patch)
tree607afa1b7df4f4e4607a52c8cb9414d8a8027a4e /meta/classes
parent4f8eec834a8f8686f37f418e43110f746df6f552 (diff)
downloadpoky-a28891c779fa85818a1572abfa8450e5930c01ca.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. (From OE-Core rev: f2fd1c9d75e774c8a5271cdc1ec6f65c4492f941) 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
12 12
13OE_EXTRA_IMPORTS ?= "" 13OE_EXTRA_IMPORTS ?= ""
14 14
15OE_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}" 15OE_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}"
16OE_IMPORTS[type] = "list" 16OE_IMPORTS[type] = "list"
17 17
18PACKAGECONFIG_CONFARGS ??= "" 18PACKAGECONFIG_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
91addtask do_deploy_source_date_epoch before do_configure after do_patch 91addtask do_deploy_source_date_epoch before do_configure after do_patch
92 92
93python create_source_date_epoch_stamp() { 93python create_source_date_epoch_stamp() {
94 import oe.reproducible
95
96 epochfile = d.getVar('SDE_FILE')
97 tmp_file = "%s.new" % epochfile
98
99 source_date_epoch = oe.reproducible.get_source_date_epoch(d, d.getVar('S')) 94 source_date_epoch = oe.reproducible.get_source_date_epoch(d, d.getVar('S'))
100 95 oe.reproducible.epochfile_write(source_date_epoch, d.getVar('SDE_FILE'), d)
101 bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch)
102 bb.utils.mkdirhier(d.getVar('SDE_DIR'))
103 with open(tmp_file, 'w') as f:
104 f.write(str(source_date_epoch))
105
106 os.rename(tmp_file, epochfile)
107} 96}
108 97
109EPOCHTASK = "do_deploy_source_date_epoch" 98EPOCHTASK = "do_deploy_source_date_epoch"
@@ -112,29 +101,7 @@ EPOCHTASK = "do_deploy_source_date_epoch"
112do_unpack[postfuncs] += "create_source_date_epoch_stamp" 101do_unpack[postfuncs] += "create_source_date_epoch_stamp"
113 102
114def get_source_date_epoch_value(d): 103def get_source_date_epoch_value(d):
115 epochfile = d.getVar('SDE_FILE') 104 return oe.reproducible.epochfile_read(d.getVar('SDE_FILE'), d)
116 cached, efile = d.getVar('__CACHED_SOURCE_DATE_EPOCH') or (None, None)
117 if cached and efile == epochfile:
118 return cached
119
120 if cached and epochfile != efile:
121 bb.debug(1, "Epoch file changed from %s to %s" % (efile, epochfile))
122
123 source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK'))
124 try:
125 with open(epochfile, 'r') as f:
126 s = f.read()
127 try:
128 source_date_epoch = int(s)
129 except ValueError:
130 bb.warn("SOURCE_DATE_EPOCH value '%s' is invalid. Reverting to SOURCE_DATE_EPOCH_FALLBACK" % s)
131 source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK'))
132 bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch)
133 except FileNotFoundError:
134 bb.debug(1, "Cannot find %s. SOURCE_DATE_EPOCH will default to %d" % (epochfile, source_date_epoch))
135
136 d.setVar('__CACHED_SOURCE_DATE_EPOCH', (str(source_date_epoch), epochfile))
137 return str(source_date_epoch)
138 105
139export SOURCE_DATE_EPOCH ?= "${@get_source_date_epoch_value(d)}" 106export SOURCE_DATE_EPOCH ?= "${@get_source_date_epoch_value(d)}"
140BB_HASHBASE_WHITELIST += "SOURCE_DATE_EPOCH" 107BB_HASHBASE_WHITELIST += "SOURCE_DATE_EPOCH"