1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-31 12:49:46 +00:00

bitbake: Overhaul environment handling

Currently, anything whitelisted in the environment makes it into the worker
processes. This is undesireable and the worker environment should be as
clean as possible. This patch adapts bitbake sosme variables are loaded into
bitbake's datastore but not exported by default. Any variable can be exported
by setting its export flag.

Currently, this code only finalises the environment in he worker as doing so
in the server means variables are unavailable in the worker. If we switch
back to fork() calls instead of exec() this code will need revisting.

Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
This commit is contained in:
Richard Purdie
2010-11-28 17:39:09 +00:00
parent 39dd60462c
commit 0ba9a9fffe
5 changed files with 48 additions and 17 deletions
+33 -15
View File
@@ -465,13 +465,25 @@ def sha256_file(filename):
s.update(line)
return s.hexdigest()
def preserved_envvars_list():
# Variables which are preserved from the original environment *and* exported
# into our worker context
def preserved_envvars_export_list():
return [
'BBPATH',
'BB_PRESERVE_ENV',
'BB_ENV_WHITELIST',
'BB_ENV_EXTRAWHITE',
'BB_TASKHASH',
'HOME',
'LOGNAME',
'PATH',
'PWD',
'SHELL',
'TERM',
'USER',
'USERNAME',
]
# Variables which are preserved from the original environment *and* exported
# into our worker context for interactive tasks (e.g. requiring X)
def preserved_envvars_export_interactive_list():
return [
'COLORTERM',
'DBUS_SESSION_BUS_ADDRESS',
'DESKTOP_SESSION',
@@ -481,23 +493,25 @@ def preserved_envvars_list():
'GNOME_KEYRING_SOCKET',
'GPG_AGENT_INFO',
'GTK_RC_FILES',
'HOME',
'LANG',
'LOGNAME',
'PATH',
'PWD',
'SESSION_MANAGER',
'SHELL',
'SSH_AUTH_SOCK',
'TERM',
'USER',
'USERNAME',
'_',
'XAUTHORITY',
'XDG_DATA_DIRS',
'XDG_SESSION_COOKIE',
]
# Variables which are preserved from the original environment into the datastore
def preserved_envvars_list():
v = [
'BBPATH',
'BB_PRESERVE_ENV',
'BB_ENV_WHITELIST',
'BB_ENV_EXTRAWHITE',
'LANG',
'_',
]
return v + preserved_envvars_export_list() + preserved_envvars_export_interactive_list()
def filter_environment(good_vars):
"""
Create a pristine environment for bitbake. This will remove variables that
@@ -518,6 +532,10 @@ def filter_environment(good_vars):
return removed_vars
def create_intereactive_env(d):
for k in preserved_envvars_export_interactive_list():
os.setenv(k, bb.data.getVar(k, d, True))
def clean_environment():
"""
Clean up any spurious environment variables. This will remove any