summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-02-11 11:00:45 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-02-11 11:11:26 +0000
commitb6d8f96ee51d8897e083974bd10d48f64ddffd32 (patch)
tree94c152d4472a0700c4d6755c09c289966454f023 /bitbake
parent20b4dcace222d6b1d659a8813b4affad075ec0c6 (diff)
downloadpoky-b6d8f96ee51d8897e083974bd10d48f64ddffd32.tar.gz
bitbake: bitbake/utils: Improve environment handling to allow UIs access to original environment
We need to empty out the environment whilst we build the cooker but we need the environment for the UIs since hob uses DISPLAY and other session variables. This patch adapts the utils functions to return removed environment components so we can reinject them for use by the UI, allowing hob to work again. (Bitbake rev: fc330d810099c57fefd4e706159a73ad8401d97c) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rwxr-xr-xbitbake/bin/bitbake10
-rw-r--r--bitbake/lib/bb/utils.py10
2 files changed, 12 insertions, 8 deletions
diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
index 89289050de..40b50e1688 100755
--- a/bitbake/bin/bitbake
+++ b/bitbake/bin/bitbake
@@ -229,10 +229,8 @@ Default BBFILES are the .bb files in the current directory.""")
229 # Before we start modifying the environment we should take a pristine 229 # Before we start modifying the environment we should take a pristine
230 # copy for possible later use 230 # copy for possible later use
231 initialenv = os.environ.copy() 231 initialenv = os.environ.copy()
232 # Clear away any spurious environment variables. But don't wipe the 232 # Clear away any spurious environment variables while we stoke up the cooker
233 # environment totally. This is necessary to ensure the correct operation 233 cleanedvars = bb.utils.clean_environment()
234 # of the UIs (e.g. for DISPLAY, etc.)
235 bb.utils.clean_environment()
236 234
237 server = server.BitBakeServer() 235 server = server.BitBakeServer()
238 if configuration.bind: 236 if configuration.bind:
@@ -258,6 +256,10 @@ Default BBFILES are the .bb files in the current directory.""")
258 # Setup a connection to the server (cooker) 256 # Setup a connection to the server (cooker)
259 server_connection = server.establishConnection() 257 server_connection = server.establishConnection()
260 258
259 # Restore the environment in case the UI needs it
260 for k in cleanedvars:
261 os.environ[k] = cleanedvars[k]
262
261 try: 263 try:
262 return server.launchUI(ui_main, server_connection.connection, server_connection.events) 264 return server.launchUI(ui_main, server_connection.connection, server_connection.events)
263 finally: 265 finally:
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 484fb2dc76..b1a0f25e75 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -474,17 +474,17 @@ def filter_environment(good_vars):
474 are not known and may influence the build in a negative way. 474 are not known and may influence the build in a negative way.
475 """ 475 """
476 476
477 removed_vars = [] 477 removed_vars = {}
478 for key in os.environ.keys(): 478 for key in os.environ.keys():
479 if key in good_vars: 479 if key in good_vars:
480 continue 480 continue
481 481
482 removed_vars.append(key) 482 removed_vars[key] = os.environ[key]
483 os.unsetenv(key) 483 os.unsetenv(key)
484 del os.environ[key] 484 del os.environ[key]
485 485
486 if len(removed_vars): 486 if len(removed_vars):
487 logger.debug(1, "Removed the following variables from the environment: %s", ", ".join(removed_vars)) 487 logger.debug(1, "Removed the following variables from the environment: %s", ", ".join(removed_vars.keys()))
488 488
489 return removed_vars 489 return removed_vars
490 490
@@ -509,7 +509,9 @@ def clean_environment():
509 """ 509 """
510 if 'BB_PRESERVE_ENV' not in os.environ: 510 if 'BB_PRESERVE_ENV' not in os.environ:
511 good_vars = approved_variables() 511 good_vars = approved_variables()
512 filter_environment(good_vars) 512 return filter_environment(good_vars)
513
514 return {}
513 515
514def empty_environment(): 516def empty_environment():
515 """ 517 """