summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/utils.py
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-11-28 17:39:09 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2010-12-09 13:16:14 +0000
commit0ba9a9fffee966ec912eec5fd52c468338560e6a (patch)
tree667079024d685b4f7ed1be59d3f23b7e00e97b2b /bitbake/lib/bb/utils.py
parent39dd60462c6d1e87f7c4105e1a3913e0aa54dba0 (diff)
downloadpoky-0ba9a9fffee966ec912eec5fd52c468338560e6a.tar.gz
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.py48
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):
465 s.update(line) 465 s.update(line)
466 return s.hexdigest() 466 return s.hexdigest()
467 467
468def preserved_envvars_list(): 468# Variables which are preserved from the original environment *and* exported
469# into our worker context
470def preserved_envvars_export_list():
469 return [ 471 return [
470 'BBPATH',
471 'BB_PRESERVE_ENV',
472 'BB_ENV_WHITELIST',
473 'BB_ENV_EXTRAWHITE',
474 'BB_TASKHASH', 472 'BB_TASKHASH',
473 'HOME',
474 'LOGNAME',
475 'PATH',
476 'PWD',
477 'SHELL',
478 'TERM',
479 'USER',
480 'USERNAME',
481 ]
482
483# Variables which are preserved from the original environment *and* exported
484# into our worker context for interactive tasks (e.g. requiring X)
485def preserved_envvars_export_interactive_list():
486 return [
475 'COLORTERM', 487 'COLORTERM',
476 'DBUS_SESSION_BUS_ADDRESS', 488 'DBUS_SESSION_BUS_ADDRESS',
477 'DESKTOP_SESSION', 489 'DESKTOP_SESSION',
@@ -481,23 +493,25 @@ def preserved_envvars_list():
481 'GNOME_KEYRING_SOCKET', 493 'GNOME_KEYRING_SOCKET',
482 'GPG_AGENT_INFO', 494 'GPG_AGENT_INFO',
483 'GTK_RC_FILES', 495 'GTK_RC_FILES',
484 'HOME',
485 'LANG',
486 'LOGNAME',
487 'PATH',
488 'PWD',
489 'SESSION_MANAGER', 496 'SESSION_MANAGER',
490 'SHELL',
491 'SSH_AUTH_SOCK', 497 'SSH_AUTH_SOCK',
492 'TERM',
493 'USER',
494 'USERNAME',
495 '_',
496 'XAUTHORITY', 498 'XAUTHORITY',
497 'XDG_DATA_DIRS', 499 'XDG_DATA_DIRS',
498 'XDG_SESSION_COOKIE', 500 'XDG_SESSION_COOKIE',
499 ] 501 ]
500 502
503# Variables which are preserved from the original environment into the datastore
504def preserved_envvars_list():
505 v = [
506 'BBPATH',
507 'BB_PRESERVE_ENV',
508 'BB_ENV_WHITELIST',
509 'BB_ENV_EXTRAWHITE',
510 'LANG',
511 '_',
512 ]
513 return v + preserved_envvars_export_list() + preserved_envvars_export_interactive_list()
514
501def filter_environment(good_vars): 515def filter_environment(good_vars):
502 """ 516 """
503 Create a pristine environment for bitbake. This will remove variables that 517 Create a pristine environment for bitbake. This will remove variables that
@@ -518,6 +532,10 @@ def filter_environment(good_vars):
518 532
519 return removed_vars 533 return removed_vars
520 534
535def create_intereactive_env(d):
536 for k in preserved_envvars_export_interactive_list():
537 os.setenv(k, bb.data.getVar(k, d, True))
538
521def clean_environment(): 539def clean_environment():
522 """ 540 """
523 Clean up any spurious environment variables. This will remove any 541 Clean up any spurious environment variables. This will remove any