def run(self, cmds, env={}, *kargs): renv = os.environ cmds[0] = progs.get(cmds[0]) for key, value in env.items(): renv[key] = value for key, value in self._host.fs.env().items(): renv[key] = value return call(cmds, env=renv, stdout=config.stdout, stderr=config.stderr)
def _ch_setup(self): shutil.copy(progs.get(QEMU_BIN), self._qemudst) open(self._rcddst, "w").write(self.RCDFILE_CONTENT) os.chmod(self._rcddst, 0755) # resolv.conf handling # If there is a resolv.conf move it to resolv.conf.real # Move host resolv.conf to target resolv.conf and store its md5 in self._resolvhash tconf=config.rootfs(RESOLV_CONF_PATH) if os.path.lexists(tconf): os.rename(tconf, tconf+".real") shutil.copy(RESOLV_CONF_PATH, tconf) open(tconf, "a").write(""" # This is the Hosts resolv.conf. # If changed in any way the target resolv.conf will not be restored. """) self._resolvhash = hashfile(tconf)
def run(self, cmds, env=None, stdoutfunc=None, stderrfunc=None, *kargs): stdout = self._host.stdoutfd() stderr = self._host.stderrfd() renv = os.environ cmds[0] = progs.get(cmds[0]) if env: for key, value in env.items(): renv[key] = value for key, value in self._host.fs.env().items(): renv[key] = value if stdout != 1 or stderr != 2: self._host.add_outcb(stdoutfunc, *kargs) self._host.add_errcb(stderrfunc, *kargs) self._host.text("$ " + " ".join(cmds)) p = Popen(cmds, env=env, stdout=stdout, stderr=stderr) while p.poll() == None: self._host.poller.poll(.01) ret = p.wait() self._host.remove_outcb(stdoutfunc) self._host.remove_errcb(stderrfunc) return ret return call(cmds, env=renv)
def _ch_setup(self): shutil.copy(progs.get(QEMU_BIN), self._qemudst) open(self._rcddst, "w").write(self.RCDFILE_CONTENT) os.chmod(self._rcddst, 0755)
def __init__(self, host): self._host = host self._rcddst = config.rootfs("/usr/sbin/policy-rc.d") progs.register(QEMU_BIN) progs.register("chroot") self._qemudst = config.rootfs(progs.get(QEMU_BIN))