summaryrefslogtreecommitdiffstats
path: root/meta/classes/base.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-09 00:14:38 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-11 16:09:14 +0000
commit94790a8254d63d63759ca3598b42f3f67bc97d02 (patch)
treeb3df3f28c12a6e9270a6763affabc14052c594fd /meta/classes/base.bbclass
parent6df0da0aa1aa8f5f3bbb16bc3af03d14007f2791 (diff)
downloadpoky-94790a8254d63d63759ca3598b42f3f67bc97d02.tar.gz
base/bitbake.conf: Filter contents of PATH to only allow whitelisted tools
We currently have a determinism problem in that the host tools present in PATH can influence the build. In particular, the presence of pkg-config on the build host can mask missing pkgconfig class dependencies. This adds in a new HOSTTOOLS variable and then uses it to set up a directory of symlinks to the whitelisted host tools. This directory is placed as PATH instead of the usual /usr/bin:/bin and so on. This should improve determinism of builds and avoid the issues which have been particularly obvious since the introduction of recipe specific sysroots. If users find there is a tool missing, they can extend HOSTTOOLS from a global class or global conf file. Right now the settings should be enough to build everything in OE-Core. (From OE-Core rev: fa764a403da34bb0ca9fa3767a9e9dba8d685965) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/base.bbclass')
-rw-r--r--meta/classes/base.bbclass22
1 files changed, 22 insertions, 0 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 14293f83c4..fec351a890 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -119,6 +119,25 @@ def get_lic_checksum_file_list(d):
119 bb.fatal(d.getVar('PN') + ": LIC_FILES_CHKSUM contains an invalid URL: " + url) 119 bb.fatal(d.getVar('PN') + ": LIC_FILES_CHKSUM contains an invalid URL: " + url)
120 return " ".join(filelist) 120 return " ".join(filelist)
121 121
122def setup_hosttools_dir(dest, toolsvar, d, fatal=True):
123 tools = d.getVar(toolsvar).split()
124 origbbenv = d.getVar("BB_ORIGENV", False)
125 path = origbbenv.getVar("PATH")
126 bb.utils.mkdirhier(dest)
127 notfound = []
128 for tool in tools:
129 desttool = os.path.join(dest, tool)
130 if not os.path.exists(desttool):
131 srctool = bb.utils.which(path, tool)
132 if "ccache" in srctool:
133 srctool = bb.utils.which(path, tool, direction=1)
134 if srctool:
135 os.symlink(srctool, desttool)
136 else:
137 notfound.append(tool)
138 if notfound and fatal:
139 bb.fatal("These tools appear to be unavailable in PATH, please install them in order to proceed:\n%s" % " ".join(notfound))
140
122addtask fetch 141addtask fetch
123do_fetch[dirs] = "${DL_DIR}" 142do_fetch[dirs] = "${DL_DIR}"
124do_fetch[file-checksums] = "${@bb.fetch.get_checksum_file_list(d)}" 143do_fetch[file-checksums] = "${@bb.fetch.get_checksum_file_list(d)}"
@@ -219,6 +238,9 @@ python base_eventhandler() {
219 pkgarch_mapping(e.data) 238 pkgarch_mapping(e.data)
220 oe.utils.features_backfill("DISTRO_FEATURES", e.data) 239 oe.utils.features_backfill("DISTRO_FEATURES", e.data)
221 oe.utils.features_backfill("MACHINE_FEATURES", e.data) 240 oe.utils.features_backfill("MACHINE_FEATURES", e.data)
241 # Works with the line in layer.conf which changes PATH to point here
242 setup_hosttools_dir(d.expand('${TMPDIR}/hosttools'), 'HOSTTOOLS', d)
243 setup_hosttools_dir(d.expand('${TMPDIR}/hosttools'), 'HOSTTOOLS_NONFATAL', d, fatal=False)
222 244
223 if isinstance(e, bb.event.BuildStarted): 245 if isinstance(e, bb.event.BuildStarted):
224 localdata = bb.data.createCopy(e.data) 246 localdata = bb.data.createCopy(e.data)