aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/cookerdata.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-02-15 23:17:29 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-02-21 23:36:47 +0000
commitbd50a5d5e4b4fa90844464396887ebdff0d4e5f7 (patch)
tree53ca101b6a0ac59949895bc40e00b72f59aba7b1 /lib/bb/cookerdata.py
parent7cae11f558f9ff5fd05ef23b789aaef92fb5a327 (diff)
downloadbitbake-bd50a5d5e4b4fa90844464396887ebdff0d4e5f7.tar.gz
data_smart/cookerdata: Add variable remapping support
This change adds support for improving the user experience when variables are renamed. This isn't as simple as it might first appear since some bitbake variables are used through the environment before the datastore exists, some are bitbake variables which we know about straight away and some are metadata defined which we don't know about until later. This patch adds support for handling these different cases, allowing a list of bitbake renamed variables to be defined in bitbake itself and allows this to be extended through the metadata using BB_RENAMED_VARIABLES. In order to give the best feedback to the user, we default to turning on variable history tracking in the base data store from knotty, which allows filename and line number information to be shown. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/cookerdata.py')
-rw-r--r--lib/bb/cookerdata.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/bb/cookerdata.py b/lib/bb/cookerdata.py
index e4d91486d..8426ed786 100644
--- a/lib/bb/cookerdata.py
+++ b/lib/bb/cookerdata.py
@@ -247,6 +247,9 @@ class CookerDataBuilder(object):
self.savedenv = bb.data.init()
for k in cookercfg.env:
self.savedenv.setVar(k, cookercfg.env[k])
+ if k in bb.data_smart.bitbake_renamed_vars:
+ bb.error('Variable %s from the shell environment has been renamed to %s' % (k, bb.data_smart.bitbake_renamed_vars[k]))
+ bb.fatal("Exiting to allow enviroment variables to be corrected")
filtered_keys = bb.utils.approved_variables()
bb.data.inheritFromOS(self.basedata, self.savedenv, filtered_keys)
@@ -307,6 +310,24 @@ class CookerDataBuilder(object):
logger.exception("Error parsing configuration files")
raise bb.BBHandledException()
+
+ # Handle obsolete variable names
+ d = self.data
+ renamedvars = d.getVarFlags('BB_RENAMED_VARIABLES') or {}
+ renamedvars.update(bb.data_smart.bitbake_renamed_vars)
+ issues = False
+ for v in renamedvars:
+ if d.getVar(v) != None or d.hasOverrides(v):
+ issues = True
+ history = d.varhistory.get_variable_refs(v)
+ for h in history:
+ for line in history[h]:
+ bb.erroronce('Variable %s has been renamed to %s (file: %s line: %s)' % (v, renamedvars[v], h, line))
+ if not history:
+ bb.erroronce('Variable %s has been renamed to %s' % (v, renamedvars[v]))
+ if issues:
+ raise bb.BBHandledException()
+
# Create a copy so we can reset at a later date when UIs disconnect
self.origdata = self.data
self.data = bb.data.createCopy(self.origdata)