diff options
-rwxr-xr-x | bitbake/bin/bitbake-runtask | 3 | ||||
-rw-r--r-- | bitbake/lib/bb/cooker.py | 3 | ||||
-rw-r--r-- | bitbake/lib/bb/data.py | 10 | ||||
-rw-r--r-- | bitbake/lib/bb/runqueue.py | 1 | ||||
-rw-r--r-- | bitbake/lib/bb/utils.py | 48 |
5 files changed, 48 insertions, 17 deletions
diff --git a/bitbake/bin/bitbake-runtask b/bitbake/bin/bitbake-runtask index 88101a5c0f..9079f5725b 100755 --- a/bitbake/bin/bitbake-runtask +++ b/bitbake/bin/bitbake-runtask | |||
@@ -100,6 +100,9 @@ the_data = cooker.bb_cache.loadDataFull(fn, cooker.get_file_appends(fn), cooker. | |||
100 | cooker.bb_cache.setData(fn, buildfile, the_data) | 100 | cooker.bb_cache.setData(fn, buildfile, the_data) |
101 | cooker.bb_cache.handle_data(fn, cooker.status) | 101 | cooker.bb_cache.handle_data(fn, cooker.status) |
102 | 102 | ||
103 | exportlist = bb.utils.preserved_envvars_export_list() | ||
104 | bb.utils.filter_environment(exportlist) | ||
105 | |||
103 | if taskname.endswith("_setscene"): | 106 | if taskname.endswith("_setscene"): |
104 | the_data.setVarFlag(taskname, "quieterrors", "1") | 107 | the_data.setVarFlag(taskname, "quieterrors", "1") |
105 | 108 | ||
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 8c55e3e643..95f38f6236 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
@@ -918,7 +918,8 @@ class BBCooker: | |||
918 | def pre_serve(self): | 918 | def pre_serve(self): |
919 | # Empty the environment. The environment will be populated as | 919 | # Empty the environment. The environment will be populated as |
920 | # necessary from the data store. | 920 | # necessary from the data store. |
921 | bb.utils.empty_environment() | 921 | #bb.utils.empty_environment() |
922 | return | ||
922 | 923 | ||
923 | def post_serve(self): | 924 | def post_serve(self): |
924 | bb.event.fire(CookerExit(), self.configuration.event_data) | 925 | bb.event.fire(CookerExit(), self.configuration.event_data) |
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py index fee10ccda4..d4d43fd8c8 100644 --- a/bitbake/lib/bb/data.py +++ b/bitbake/lib/bb/data.py | |||
@@ -161,10 +161,12 @@ def expandKeys(alterdata, readdata = None): | |||
161 | 161 | ||
162 | def inheritFromOS(d): | 162 | def inheritFromOS(d): |
163 | """Inherit variables from the environment.""" | 163 | """Inherit variables from the environment.""" |
164 | exportlist = bb.utils.preserved_envvars_export_list() | ||
164 | for s in os.environ.keys(): | 165 | for s in os.environ.keys(): |
165 | try: | 166 | try: |
166 | setVar(s, os.environ[s], d) | 167 | setVar(s, os.environ[s], d) |
167 | setVarFlag(s, "export", True, d) | 168 | if s in exportlist: |
169 | setVarFlag(s, "export", True, d) | ||
168 | except TypeError: | 170 | except TypeError: |
169 | pass | 171 | pass |
170 | 172 | ||
@@ -244,6 +246,12 @@ def export_vars(d): | |||
244 | pass | 246 | pass |
245 | return ret | 247 | return ret |
246 | 248 | ||
249 | def export_envvars(v, d): | ||
250 | for s in os.environ.keys(): | ||
251 | if s not in v: | ||
252 | v[s] = os.environ[s] | ||
253 | return v | ||
254 | |||
247 | def emit_func(func, o=sys.__stdout__, d = init()): | 255 | def emit_func(func, o=sys.__stdout__, d = init()): |
248 | """Emits all items in the data store in a format such that it can be sourced by a shell.""" | 256 | """Emits all items in the data store in a format such that it can be sourced by a shell.""" |
249 | 257 | ||
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py index 3300db75cb..e26aa4e075 100644 --- a/bitbake/lib/bb/runqueue.py +++ b/bitbake/lib/bb/runqueue.py | |||
@@ -1062,6 +1062,7 @@ class RunQueueExecute: | |||
1062 | the_data = self.cooker.bb_cache.loadDataFull(fn, self.cooker.get_file_appends(fn), self.cooker.configuration.data) | 1062 | the_data = self.cooker.bb_cache.loadDataFull(fn, self.cooker.get_file_appends(fn), self.cooker.configuration.data) |
1063 | 1063 | ||
1064 | env = bb.data.export_vars(the_data) | 1064 | env = bb.data.export_vars(the_data) |
1065 | env = bb.data.export_envvars(env, the_data) | ||
1065 | 1066 | ||
1066 | taskdep = self.rqdata.dataCache.task_deps[fn] | 1067 | taskdep = self.rqdata.dataCache.task_deps[fn] |
1067 | if 'fakeroot' in taskdep and taskname in taskdep['fakeroot']: | 1068 | if 'fakeroot' in taskdep and taskname in taskdep['fakeroot']: |
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 | ||
468 | def preserved_envvars_list(): | 468 | # Variables which are preserved from the original environment *and* exported |
469 | # into our worker context | ||
470 | def 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) | ||
485 | def 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 | ||
504 | def 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 | |||
501 | def filter_environment(good_vars): | 515 | def 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 | ||
535 | def create_intereactive_env(d): | ||
536 | for k in preserved_envvars_export_interactive_list(): | ||
537 | os.setenv(k, bb.data.getVar(k, d, True)) | ||
538 | |||
521 | def clean_environment(): | 539 | def 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 |