mirror of
https://git.yoctoproject.org/poky
synced 2026-05-09 05:29:32 +00:00
bitbake/data/runqueue: Sync up with upstream to clean up environment variable handling
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
+13
-18
@@ -234,25 +234,20 @@ def emit_env(o=sys.__stdout__, d = init(), all=False):
|
|||||||
for key in keys:
|
for key in keys:
|
||||||
emit_var(key, o, d, all and not isfunc) and o.write('\n')
|
emit_var(key, o, d, all and not isfunc) and o.write('\n')
|
||||||
|
|
||||||
def export_vars(d):
|
def exported_keys(d):
|
||||||
keys = (key for key in d.keys() if d.getVarFlag(key, "export"))
|
return (key for key in d.keys() if not key.startswith('__') and
|
||||||
ret = {}
|
d.getVarFlag(key, 'export') and
|
||||||
for k in keys:
|
not d.getVarFlag(key, 'unexport'))
|
||||||
try:
|
|
||||||
v = d.getVar(k, True)
|
|
||||||
if v:
|
|
||||||
ret[k] = v
|
|
||||||
except (KeyboardInterrupt, bb.build.FuncFailed):
|
|
||||||
raise
|
|
||||||
except Exception, exc:
|
|
||||||
pass
|
|
||||||
return ret
|
|
||||||
|
|
||||||
def export_envvars(v, d):
|
def exported_vars(d):
|
||||||
for s in os.environ.keys():
|
for key in exported_keys(d):
|
||||||
if s not in v:
|
try:
|
||||||
v[s] = os.environ[s]
|
value = d.getVar(key, True)
|
||||||
return v
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if value is not None:
|
||||||
|
yield key, str(value)
|
||||||
|
|
||||||
def emit_func(func, o=sys.__stdout__, d = init()):
|
def emit_func(func, o=sys.__stdout__, d = init()):
|
||||||
"""Emits all items in the data store in a format such that it can be sourced by a shell."""
|
"""Emits all items in the data store in a format such that it can be sourced by a shell."""
|
||||||
|
|||||||
@@ -1062,7 +1062,6 @@ class RunQueueExecute:
|
|||||||
# We need to setup the environment BEFORE the fork, since
|
# We need to setup the environment BEFORE the fork, since
|
||||||
# a fork() or exec*() activates PSEUDO...
|
# a fork() or exec*() activates PSEUDO...
|
||||||
|
|
||||||
env = {}
|
|
||||||
envbackup = {}
|
envbackup = {}
|
||||||
|
|
||||||
taskdep = self.rqdata.dataCache.task_deps[fn]
|
taskdep = self.rqdata.dataCache.task_deps[fn]
|
||||||
@@ -1071,7 +1070,6 @@ class RunQueueExecute:
|
|||||||
for key, value in (var.split('=') for var in envvars):
|
for key, value in (var.split('=') for var in envvars):
|
||||||
envbackup[key] = os.environ.get(key)
|
envbackup[key] = os.environ.get(key)
|
||||||
os.environ[key] = value
|
os.environ[key] = value
|
||||||
env[key] = value
|
|
||||||
|
|
||||||
fakedirs = (self.rqdata.dataCache.fakerootdirs[fn] or "").split()
|
fakedirs = (self.rqdata.dataCache.fakerootdirs[fn] or "").split()
|
||||||
for p in fakedirs:
|
for p in fakedirs:
|
||||||
@@ -1118,14 +1116,7 @@ class RunQueueExecute:
|
|||||||
for h in self.rqdata.hash_deps:
|
for h in self.rqdata.hash_deps:
|
||||||
the_data.setVar("BBHASHDEPS_%s" % h, self.rqdata.hash_deps[h])
|
the_data.setVar("BBHASHDEPS_%s" % h, self.rqdata.hash_deps[h])
|
||||||
|
|
||||||
env2 = bb.data.export_vars(the_data)
|
os.environ.update(bb.data.exported_vars(the_data))
|
||||||
env2 = bb.data.export_envvars(env2, the_data)
|
|
||||||
for e in os.environ:
|
|
||||||
os.unsetenv(e)
|
|
||||||
for e in env2:
|
|
||||||
os.putenv(e, env2[e])
|
|
||||||
for e in env:
|
|
||||||
os.putenv(e, env[e])
|
|
||||||
|
|
||||||
if quieterrors:
|
if quieterrors:
|
||||||
the_data.setVarFlag(taskname, "quieterrors", "1")
|
the_data.setVarFlag(taskname, "quieterrors", "1")
|
||||||
|
|||||||
Reference in New Issue
Block a user