summaryrefslogtreecommitdiffstats
path: root/lib/bb
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-11-28 17:39:09 +0000
committerChris Larson <chris_larson@mentor.com>2010-12-29 23:51:07 -0700
commit8bc6f3eb7f735e606202393542b8b610d0cbc3d8 (patch)
tree04a7ff124876ba13b2d811fdbed50af6393f891a /lib/bb
parentc30630548b66e59e055e372bec4736d118bac131 (diff)
downloadbitbake-8bc6f3eb7f735e606202393542b8b610d0cbc3d8.tar.gz
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. Signed-off-by: Richard Purdie <rpurdie@linux.intel.com> Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'lib/bb')
-rw-r--r--lib/bb/data.py4
-rw-r--r--lib/bb/utils.py50
2 files changed, 37 insertions, 17 deletions
diff --git a/lib/bb/data.py b/lib/bb/data.py
index cf83c506c..e472cd24d 100644
--- a/lib/bb/data.py
+++ b/lib/bb/data.py
@@ -161,10 +161,12 @@ def expandKeys(alterdata, readdata = None):
def inheritFromOS(d):
"""Inherit variables from the environment."""
+ exportlist = bb.utils.preserved_envvars_exported()
for s in os.environ.keys():
try:
setVar(s, os.environ[s], d)
- setVarFlag(s, "export", True, d)
+ if s in exportlist:
+ setVarFlag(s, "export", True, d)
except TypeError:
pass
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index a65825c3c..459b8948d 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -473,13 +473,25 @@ def sha256_file(filename):
s.update(line)
return s.hexdigest()
-def preserved_envvars_list():
+def preserved_envvars_exported():
+ """Variables which are taken from the environment and placed in and exported
+ from the metadata"""
return [
- 'BBPATH',
- 'BB_PRESERVE_ENV',
- 'BB_ENV_WHITELIST',
- 'BB_ENV_EXTRAWHITE',
'BB_TASKHASH',
+ 'HOME',
+ 'LOGNAME',
+ 'PATH',
+ 'PWD',
+ 'SHELL',
+ 'TERM',
+ 'USER',
+ 'USERNAME',
+ ]
+
+def preserved_envvars_exported_interactive():
+ """Variables which are taken from the environment and placed in and exported
+ from the metadata, for interactive tasks"""
+ return [
'COLORTERM',
'DBUS_SESSION_BUS_ADDRESS',
'DESKTOP_SESSION',
@@ -489,23 +501,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',
]
+def preserved_envvars():
+ """Variables which are taken from the environment and placed in the metadata"""
+ v = [
+ 'BBPATH',
+ 'BB_PRESERVE_ENV',
+ 'BB_ENV_WHITELIST',
+ 'BB_ENV_EXTRAWHITE',
+ 'LANG',
+ '_',
+ ]
+ return v + preserved_envvars_exported() + preserved_envvars_exported_interactive()
+
def filter_environment(good_vars):
"""
Create a pristine environment for bitbake. This will remove variables that
@@ -526,6 +540,10 @@ def filter_environment(good_vars):
return removed_vars
+def create_interactive_env(d):
+ for k in preserved_envvars_exported_interactive():
+ os.setenv(k, bb.data.getVar(k, d, True))
+
def clean_environment():
"""
Clean up any spurious environment variables. This will remove any
@@ -535,7 +553,7 @@ def clean_environment():
if 'BB_ENV_WHITELIST' in os.environ:
good_vars = os.environ['BB_ENV_WHITELIST'].split()
else:
- good_vars = preserved_envvars_list()
+ good_vars = preserved_envvars()
if 'BB_ENV_EXTRAWHITE' in os.environ:
good_vars.extend(os.environ['BB_ENV_EXTRAWHITE'].split())
filter_environment(good_vars)