diff options
-rw-r--r-- | lib/bb/cache.py | 10 | ||||
-rw-r--r-- | lib/bb/runqueue.py | 29 |
2 files changed, 38 insertions, 1 deletions
diff --git a/lib/bb/cache.py b/lib/bb/cache.py index 421bd7918..2d04ee77c 100644 --- a/lib/bb/cache.py +++ b/lib/bb/cache.py @@ -43,7 +43,7 @@ except ImportError: logger.info("Importing cPickle failed. " "Falling back to a very slow implementation.") -__cache_version__ = "137" +__cache_version__ = "138" recipe_fields = ( 'pn', @@ -78,6 +78,8 @@ recipe_fields = ( 'summary', 'license', 'section', + 'fakerootenv', + 'fakerootdirs', ) @@ -172,6 +174,8 @@ class RecipeInfo(namedtuple('RecipeInfo', recipe_fields)): summary = cls.getvar('SUMMARY', metadata), license = cls.getvar('LICENSE', metadata), section = cls.getvar('SECTION', metadata), + fakerootenv = cls.getvar('FAKEROOTENV', metadata), + fakerootdirs = cls.getvar('FAKEROOTDIRS', metadata), ) @@ -584,6 +588,8 @@ class CacheData(object): self.summary = {} self.license = {} self.section = {} + self.fakerootenv = {} + self.fakerootdirs = {} # Indirect Cache variables (set elsewhere) self.ignored_dependencies = [] @@ -647,3 +653,5 @@ class CacheData(object): self.summary[fn] = info.summary self.license[fn] = info.license self.section[fn] = info.section + self.fakerootenv[fn] = info.fakerootenv + self.fakerootdirs[fn] = info.fakerootdirs diff --git a/lib/bb/runqueue.py b/lib/bb/runqueue.py index 85a944199..57df4c0ec 100644 --- a/lib/bb/runqueue.py +++ b/lib/bb/runqueue.py @@ -1058,6 +1058,28 @@ 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... + + # Capture a copy of the environment as a backup if we overwrite anything... + envbackup = os.environ.copy() + env = {} + + 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] + + fakedirs = (self.rqdata.dataCache.fakerootdirs[fn] or "").split() + for p in fakedirs: + bb.utils.mkdirhier(p) + logger.debug(2, "Running %s:%s under fakeroot, state dir is %s" % (fn, taskname, fakedirs)) + # Setup fakeroot/pseudo environment + for e in env: + os.putenv(e, env[e]) + sys.stdout.flush() sys.stderr.flush() try: @@ -1099,6 +1121,13 @@ class RunQueueExecute: os._exit(ret) except: os._exit(1) + else: + # Now restore the environment back to the way we found it... + for e in env: + os.unsetenv(e) + for e in envbackup: + if e in env: + os.putenv(e, envbackup[e]) return pid, pipein, pipeout |