summaryrefslogtreecommitdiffstats
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
parent31521d748460b7e9135b745574c55d33d8f0e7f3 (diff)
downloadpoky-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>
-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 dcb2e0a86b..9000c5cafc 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -1060,23 +1060,24 @@ class RunQueueExecute:
1060 return 1060 return
1061 1061
1062 def fork_off_task(self, fn, task, taskname, quieterrors=False): 1062 def fork_off_task(self, fn, task, taskname, quieterrors=False):
1063 # We need to setup the environment BEFORE the fork, since
1064 # a fork() or exec*() activates PSEUDO...
1063 1065
1064 envbackup = os.environ.copy() 1066 envbackup = {}
1065 env = {}
1066 1067
1067 taskdep = self.rqdata.dataCache.task_deps[fn] 1068 taskdep = self.rqdata.dataCache.task_deps[fn]
1068 if 'fakeroot' in taskdep and taskname in taskdep['fakeroot']: 1069 if 'fakeroot' in taskdep and taskname in taskdep['fakeroot']:
1069 envvars = (self.rqdata.dataCache.fakerootenv[fn] or "").split() 1070 envvars = (self.rqdata.dataCache.fakerootenv[fn] or "").split()
1070 for var in envvars: 1071 for key, value in (var.split('=') for var in envvars):
1071 comps = var.split("=") 1072 envbackup[key] = os.environ.get(key)
1072 env[comps[0]] = comps[1] 1073 os.environ[key] = value
1073 1074
1074 fakedirs = (self.rqdata.dataCache.fakerootdirs[fn] or "").split() 1075 fakedirs = (self.rqdata.dataCache.fakerootdirs[fn] or "").split()
1075 for p in fakedirs: 1076 for p in fakedirs:
1076 bb.mkdirhier(p) 1077 bb.utils.mkdirhier(p)
1077 logger.debug(2, "Running %s:%s under fakeroot, state dir is %s" % (fn, taskname, fakedirs)) 1078
1078 for e in env: 1079 logger.debug(2, 'Running %s:%s under fakeroot, fakedirs: %s' %
1079 os.putenv(e, env[e]) 1080 (fn, taskname, ', '.join(fakedirs)))
1080 1081
1081 sys.stdout.flush() 1082 sys.stdout.flush()
1082 sys.stderr.flush() 1083 sys.stderr.flush()
@@ -1087,6 +1088,7 @@ class RunQueueExecute:
1087 pid = os.fork() 1088 pid = os.fork()
1088 except OSError as e: 1089 except OSError as e:
1089 bb.msg.fatal(bb.msg.domain.RunQueue, "fork failed: %d (%s)" % (e.errno, e.strerror)) 1090 bb.msg.fatal(bb.msg.domain.RunQueue, "fork failed: %d (%s)" % (e.errno, e.strerror))
1091
1090 if pid == 0: 1092 if pid == 0:
1091 pipein.close() 1093 pipein.close()
1092 1094
@@ -1143,12 +1145,12 @@ class RunQueueExecute:
1143 os._exit(ret) 1145 os._exit(ret)
1144 except: 1146 except:
1145 os._exit(1) 1147 os._exit(1)
1146 1148 else:
1147 for e in env: 1149 for key, value in envbackup.iteritems():
1148 os.unsetenv(e) 1150 if value is None:
1149 for e in envbackup: 1151 del os.environ[key]
1150 if e in env: 1152 else:
1151 os.putenv(e, envbackup[e]) 1153 os.environ[key] = value
1152 1154
1153 return pid, pipein, pipeout 1155 return pid, pipein, pipeout
1154 1156