diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2010-11-28 17:39:09 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-12-09 13:16:14 +0000 |
commit | 0ba9a9fffee966ec912eec5fd52c468338560e6a (patch) | |
tree | 667079024d685b4f7ed1be59d3f23b7e00e97b2b /bitbake/lib/bb/utils.py | |
parent | 39dd60462c6d1e87f7c4105e1a3913e0aa54dba0 (diff) | |
download | openembedded-core-0ba9a9fffee966ec912eec5fd52c468338560e6a.tar.gz openembedded-core-0ba9a9fffee966ec912eec5fd52c468338560e6a.tar.bz2 openembedded-core-0ba9a9fffee966ec912eec5fd52c468338560e6a.zip |
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>
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r-- | bitbake/lib/bb/utils.py | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 5419af6246..f468fafc12 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py @@ -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 |