summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-06-08 19:16:56 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-06-08 19:38:28 (GMT)
commitc7f76a1bc9868ea4709688967d9794acd4d784ec (patch)
tree0599fe8923b2dc0a89853b03b4eb17b836bacc54 /bitbake
parentbdab8e93543bfc0d7b07c61da043b410036ac2c7 (diff)
downloadpoky-c7f76a1bc9868ea4709688967d9794acd4d784ec.tar.gz
bitbake/data/runqueue: Sync up with upstream to clean up environment variable handling
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/data.py27
-rw-r--r--bitbake/lib/bb/runqueue.py11
2 files changed, 12 insertions, 26 deletions
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py
index 50f2218..720dd76 100644
--- a/bitbake/lib/bb/data.py
+++ b/bitbake/lib/bb/data.py
@@ -234,25 +234,20 @@ def emit_env(o=sys.__stdout__, d = init(), all=False):
234 for key in keys: 234 for key in keys:
235 emit_var(key, o, d, all and not isfunc) and o.write('\n') 235 emit_var(key, o, d, all and not isfunc) and o.write('\n')
236 236
237def export_vars(d): 237def exported_keys(d):
238 keys = (key for key in d.keys() if d.getVarFlag(key, "export")) 238 return (key for key in d.keys() if not key.startswith('__') and
239 ret = {} 239 d.getVarFlag(key, 'export') and
240 for k in keys: 240 not d.getVarFlag(key, 'unexport'))
241
242def exported_vars(d):
243 for key in exported_keys(d):
241 try: 244 try:
242 v = d.getVar(k, True) 245 value = d.getVar(key, True)
243 if v: 246 except Exception:
244 ret[k] = v
245 except (KeyboardInterrupt, bb.build.FuncFailed):
246 raise
247 except Exception, exc:
248 pass 247 pass
249 return ret
250 248
251def export_envvars(v, d): 249 if value is not None:
252 for s in os.environ.keys(): 250 yield key, str(value)
253 if s not in v:
254 v[s] = os.environ[s]
255 return v
256 251
257def emit_func(func, o=sys.__stdout__, d = init()): 252def emit_func(func, o=sys.__stdout__, d = init()):
258 """Emits all items in the data store in a format such that it can be sourced by a shell.""" 253 """Emits all items in the data store in a format such that it can be sourced by a shell."""
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
index 772b366..af21eae 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -1062,7 +1062,6 @@ class RunQueueExecute:
1062 # We need to setup the environment BEFORE the fork, since 1062 # We need to setup the environment BEFORE the fork, since
1063 # a fork() or exec*() activates PSEUDO... 1063 # a fork() or exec*() activates PSEUDO...
1064 1064
1065 env = {}
1066 envbackup = {} 1065 envbackup = {}
1067 1066
1068 taskdep = self.rqdata.dataCache.task_deps[fn] 1067 taskdep = self.rqdata.dataCache.task_deps[fn]
@@ -1071,7 +1070,6 @@ class RunQueueExecute:
1071 for key, value in (var.split('=') for var in envvars): 1070 for key, value in (var.split('=') for var in envvars):
1072 envbackup[key] = os.environ.get(key) 1071 envbackup[key] = os.environ.get(key)
1073 os.environ[key] = value 1072 os.environ[key] = value
1074 env[key] = value
1075 1073
1076 fakedirs = (self.rqdata.dataCache.fakerootdirs[fn] or "").split() 1074 fakedirs = (self.rqdata.dataCache.fakerootdirs[fn] or "").split()
1077 for p in fakedirs: 1075 for p in fakedirs:
@@ -1118,14 +1116,7 @@ class RunQueueExecute:
1118 for h in self.rqdata.hash_deps: 1116 for h in self.rqdata.hash_deps:
1119 the_data.setVar("BBHASHDEPS_%s" % h, self.rqdata.hash_deps[h]) 1117 the_data.setVar("BBHASHDEPS_%s" % h, self.rqdata.hash_deps[h])
1120 1118
1121 env2 = bb.data.export_vars(the_data) 1119 os.environ.update(bb.data.exported_vars(the_data))
1122 env2 = bb.data.export_envvars(env2, the_data)
1123 for e in os.environ:
1124 os.unsetenv(e)
1125 for e in env2:
1126 os.putenv(e, env2[e])
1127 for e in env:
1128 os.putenv(e, env[e])
1129 1120
1130 if quieterrors: 1121 if quieterrors:
1131 the_data.setVarFlag(taskname, "quieterrors", "1") 1122 the_data.setVarFlag(taskname, "quieterrors", "1")