summaryrefslogtreecommitdiffstats
path: root/bitbake-dev/lib/bb/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake-dev/lib/bb/utils.py')
-rw-r--r--bitbake-dev/lib/bb/utils.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/bitbake-dev/lib/bb/utils.py b/bitbake-dev/lib/bb/utils.py
index 0a0c9ada34..9c9eb5d328 100644
--- a/bitbake-dev/lib/bb/utils.py
+++ b/bitbake-dev/lib/bb/utils.py
@@ -296,6 +296,60 @@ def sha256_file(filename):
296 s.update(line) 296 s.update(line)
297 return s.hexdigest() 297 return s.hexdigest()
298 298
299def preserved_envvars_list():
300 return [
301 'BBPATH',
302 'BB_PRESERVE_ENV',
303 'BB_ENV_WHITELIST',
304 'BB_ENV_EXTRAWHITE',
305 'COLORTERM',
306 'DBUS_SESSION_BUS_ADDRESS',
307 'DESKTOP_SESSION',
308 'DESKTOP_STARTUP_ID',
309 'DISPLAY',
310 'GNOME_KEYRING_PID',
311 'GNOME_KEYRING_SOCKET',
312 'GPG_AGENT_INFO',
313 'GTK_RC_FILES',
314 'HOME',
315 'LANG',
316 'LOGNAME',
317 'PATH',
318 'PWD',
319 'SESSION_MANAGER',
320 'SHELL',
321 'SSH_AUTH_SOCK',
322 'TERM',
323 'USER',
324 'USERNAME',
325 '_',
326 'XAUTHORITY',
327 'XDG_DATA_DIRS',
328 'XDG_SESSION_COOKIE',
329 ]
330
331def filter_environment(good_vars):
332 """
333 Create a pristine environment for bitbake. This will remove variables that
334 are not known and may influence the build in a negative way.
335 """
336
337 import bb
338
339 removed_vars = []
340 for key in os.environ.keys():
341 if key in good_vars:
342 continue
343
344 removed_vars.append(key)
345 os.unsetenv(key)
346 del os.environ[key]
347
348 if len(removed_vars):
349 bb.debug(1, "Removed the following variables from the environment:", ",".join(removed_vars))
350
351 return removed_vars
352
299def prunedir(topdir): 353def prunedir(topdir):
300 # Delete everything reachable from the directory named in 'topdir'. 354 # Delete everything reachable from the directory named in 'topdir'.
301 # CAUTION: This is dangerous! 355 # CAUTION: This is dangerous!