diff --git a/src/oebuild/app/plugins/run_qemu/run_qemu.py b/src/oebuild/app/plugins/run_qemu/run_qemu.py index fb75bce83e0e64b85162331e6832d98e89be1953..a0de6536cc01eeea7e82545917ff5233287b7a90 100644 --- a/src/oebuild/app/plugins/run_qemu/run_qemu.py +++ b/src/oebuild/app/plugins/run_qemu/run_qemu.py @@ -43,7 +43,10 @@ class RunQemu(OebuildCommand): self.container_id = None self.work_dir = os.getcwd() self.bashrc = Bashrc() - + self.oebuild_env_path = os.path.expanduser( + '~') + '/.local/oebuild/' + self.oebuild_qemuifup_yaml_path = os.path.join( + self.oebuild_env_path, 'qemu-ifup') super().__init__('run_qemu', self.help_msg, self.description) def __del__(self): @@ -129,17 +132,12 @@ fi # self.bashrc.restore_bashrc() def _check_qemu_ifup(self, ): - if not os.path.exists("/etc/qemu-ifup"): - print("""please create a virtual network interface as follows: - 1, open /etc/qemu-ifup in vim or vi - 2, add content to qemu-ifup - #!/bin/bash - ifconfig $1 192.168.10.1 up - 3, save qemu-ifup and exit - 4, run command `chmod a+x /etc/qemu-ifup` with sudo or in root usermod -now, you can continue run `oebuild runqemu` in compile directory - """) - sys.exit(0) + if not os.path.exists(self.oebuild_qemuifup_yaml_path): + os.makedirs(self.oebuild_env_path) + with open(self.oebuild_qemuifup_yaml_path, 'w', encoding="utf-8") as f: + f.write("""#!/bin/bash +ifconfig $1 192.168.7.1 up +""") def deal_env_container(self, docker_image): ''' @@ -152,7 +150,7 @@ now, you can continue run `oebuild runqemu` in compile directory ''' volumns = [] volumns.append("/dev/net/tun:/dev/net/tun") - volumns.append("/etc/qemu-ifup:/etc/qemu-ifup") + volumns.append(self.oebuild_qemuifup_yaml_path+":/etc/qemu-ifup") volumns.append(self.work_dir + ':' + oebuild_const.CONTAINER_BUILD) volumns.append(self.configure.source_dir() + ':' + oebuild_const.CONTAINER_SRC)