]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bitbake/utils: Improve environment handling to allow UIs access to original environment
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 11 Feb 2013 11:00:45 +0000 (11:00 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 11 Feb 2013 11:07:16 +0000 (11:07 +0000)
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.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bin/bitbake
lib/bb/utils.py

index 89289050deab76a105eb251625ec7239b150dca0..40b50e168819d8fec114b0a09505a444b16c1b91 100755 (executable)
@@ -229,10 +229,8 @@ Default BBFILES are the .bb files in the current directory.""")
     # Before we start modifying the environment we should take a pristine
     # copy for possible later use
     initialenv = os.environ.copy()
-    # Clear away any spurious environment variables. But don't wipe the
-    # environment totally. This is necessary to ensure the correct operation
-    # of the UIs (e.g. for DISPLAY, etc.)
-    bb.utils.clean_environment()
+    # Clear away any spurious environment variables while we stoke up the cooker
+    cleanedvars = bb.utils.clean_environment()
 
     server = server.BitBakeServer()
     if configuration.bind:
@@ -258,6 +256,10 @@ Default BBFILES are the .bb files in the current directory.""")
         # Setup a connection to the server (cooker)
         server_connection = server.establishConnection()
 
+        # Restore the environment in case the UI needs it
+        for k in cleanedvars:
+            os.environ[k] = cleanedvars[k]
+
         try:
             return server.launchUI(ui_main, server_connection.connection, server_connection.events)
         finally:
index 484fb2dc765f4aa5f2d16d3d253c74928779f5c9..b1a0f25e75a95d5785b527c48ef66a3a64b61d32 100644 (file)
@@ -474,17 +474,17 @@ def filter_environment(good_vars):
     are not known and may influence the build in a negative way.
     """
 
-    removed_vars = []
+    removed_vars = {}
     for key in os.environ.keys():
         if key in good_vars:
             continue
 
-        removed_vars.append(key)
+        removed_vars[key] = os.environ[key]
         os.unsetenv(key)
         del os.environ[key]
 
     if len(removed_vars):
-        logger.debug(1, "Removed the following variables from the environment: %s", ", ".join(removed_vars))
+        logger.debug(1, "Removed the following variables from the environment: %s", ", ".join(removed_vars.keys()))
 
     return removed_vars
 
@@ -509,7 +509,9 @@ def clean_environment():
     """
     if 'BB_PRESERVE_ENV' not in os.environ:
         good_vars = approved_variables()
-        filter_environment(good_vars)
+        return filter_environment(good_vars)
+
+    return {}
 
 def empty_environment():
     """