summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2011-03-18 09:42:33 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-03-31 12:26:40 +0100
commitc564fb09097648a7f28d701c9ccea05d7dc49b01 (patch)
treeb75e03fb1a19b7e1f5ba4aa5ca74cce2a0136305 /bitbake/lib
parent31521d748460b7e9135b745574c55d33d8f0e7f3 (diff)
downloadast2050-yocto-poky-c564fb09097648a7f28d701c9ccea05d7dc49b01.zip
ast2050-yocto-poky-c564fb09097648a7f28d701c9ccea05d7dc49b01.tar.gz
runqueue: simplify fakeroot environment handling
(Bitbake rev: 88f0d1db88bdba95e488fba34f40dc0b72a85c33) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/runqueue.py32
1 files changed, 17 insertions, 15 deletions
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
index dcb2e0a..9000c5c 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -1060,23 +1060,24 @@ class RunQueueExecute:
return
def fork_off_task(self, fn, task, taskname, quieterrors=False):
+ # We need to setup the environment BEFORE the fork, since
+ # a fork() or exec*() activates PSEUDO...
- envbackup = os.environ.copy()
- env = {}
+ envbackup = {}
taskdep = self.rqdata.dataCache.task_deps[fn]
if 'fakeroot' in taskdep and taskname in taskdep['fakeroot']:
envvars = (self.rqdata.dataCache.fakerootenv[fn] or "").split()
- for var in envvars:
- comps = var.split("=")
- env[comps[0]] = comps[1]
+ for key, value in (var.split('=') for var in envvars):
+ envbackup[key] = os.environ.get(key)
+ os.environ[key] = value
fakedirs = (self.rqdata.dataCache.fakerootdirs[fn] or "").split()
for p in fakedirs:
- bb.mkdirhier(p)
- logger.debug(2, "Running %s:%s under fakeroot, state dir is %s" % (fn, taskname, fakedirs))
- for e in env:
- os.putenv(e, env[e])
+ bb.utils.mkdirhier(p)
+
+ logger.debug(2, 'Running %s:%s under fakeroot, fakedirs: %s' %
+ (fn, taskname, ', '.join(fakedirs)))
sys.stdout.flush()
sys.stderr.flush()
@@ -1087,6 +1088,7 @@ class RunQueueExecute:
pid = os.fork()
except OSError as e:
bb.msg.fatal(bb.msg.domain.RunQueue, "fork failed: %d (%s)" % (e.errno, e.strerror))
+
if pid == 0:
pipein.close()
@@ -1143,12 +1145,12 @@ class RunQueueExecute:
os._exit(ret)
except:
os._exit(1)
-
- for e in env:
- os.unsetenv(e)
- for e in envbackup:
- if e in env:
- os.putenv(e, envbackup[e])
+ else:
+ for key, value in envbackup.iteritems():
+ if value is None:
+ del os.environ[key]
+ else:
+ os.environ[key] = value
return pid, pipein, pipeout
OpenPOWER on IntegriCloud