summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/data.py21
-rw-r--r--bitbake/lib/bb/data_smart.py3
-rw-r--r--bitbake/lib/bb/utils.py54
3 files changed, 60 insertions, 18 deletions
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py
index 54b2615afb..82eef44989 100644
--- a/bitbake/lib/bb/data.py
+++ b/bitbake/lib/bb/data.py
@@ -324,21 +324,15 @@ def expandData(alterdata, readdata = None):
324 if val != expanded: 324 if val != expanded:
325 setVar(key, expanded, alterdata) 325 setVar(key, expanded, alterdata)
326 326
327import os
328
329def inheritFromOS(d): 327def inheritFromOS(d):
330 """Inherit variables from the environment.""" 328 """Inherit variables from the environment."""
331# fakeroot needs to be able to set these
332 non_inherit_vars = [ "LD_LIBRARY_PATH", "LD_PRELOAD" ]
333 for s in os.environ.keys(): 329 for s in os.environ.keys():
334 if not s in non_inherit_vars: 330 try:
335 try: 331 setVar(s, os.environ[s], d)
336 setVar(s, os.environ[s], d) 332 except TypeError:
337 setVarFlag(s, 'matchesenv', '1', d) 333 pass
338 except TypeError: 334 os.unsetenv(s)
339 pass 335 del os.environ[s]
340
341import sys
342 336
343def emit_var(var, o=sys.__stdout__, d = init(), all=False): 337def emit_var(var, o=sys.__stdout__, d = init(), all=False):
344 """Emit a variable to be sourced by a shell.""" 338 """Emit a variable to be sourced by a shell."""
@@ -379,9 +373,6 @@ def emit_var(var, o=sys.__stdout__, d = init(), all=False):
379 o.write('unset %s\n' % varExpanded) 373 o.write('unset %s\n' % varExpanded)
380 return 1 374 return 1
381 375
382 if getVarFlag(var, 'matchesenv', d):
383 return 0
384
385 val.rstrip() 376 val.rstrip()
386 if not val: 377 if not val:
387 return 0 378 return 0
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py
index b3a51b0edf..0d39d20a45 100644
--- a/bitbake/lib/bb/data_smart.py
+++ b/bitbake/lib/bb/data_smart.py
@@ -149,9 +149,6 @@ class DataSmart:
149 149
150 if not var in self.dict: 150 if not var in self.dict:
151 self._makeShadowCopy(var) 151 self._makeShadowCopy(var)
152 if self.getVarFlag(var, 'matchesenv'):
153 self.delVarFlag(var, 'matchesenv')
154 self.setVarFlag(var, 'export', 1)
155 152
156 # more cookies for the cookie monster 153 # more cookies for the cookie monster
157 if '_' in var: 154 if '_' in var:
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 9c8d8e8435..3c1fd31b03 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/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!