diff options
author | Dohyung Kim <dohyung2.kim@samsung.com> | 2017-06-05 14:49:23 +0900 |
---|---|---|
committer | yuhuan.yang <yuhuan.yang@samsung.com> | 2018-01-30 10:18:53 +0800 |
commit | b6dcc8b96ee150bc7afce70aa619a01c59c029fd (patch) | |
tree | 33981dddabb659ba1541b2bdd811fa6566193b8f | |
parent | 9619ad84e8ce0e70d882c859c97b86cc9b3233f8 (diff) | |
download | mic-b6dcc8b96ee150bc7afce70aa619a01c59c029fd.tar.gz mic-b6dcc8b96ee150bc7afce70aa619a01c59c029fd.tar.bz2 mic-b6dcc8b96ee150bc7afce70aa619a01c59c029fd.zip |
use registered qemu emulator filename if already registered.
1. preserve-argv[0] flag is enabled
copy both qemu-XXX and qemu-XXX-binfmt and use them.
2. flag is disabled and the copied qemu and the registered qemu are different
create symlink as the registered qemu emulator filename and use symlink
Change-Id: I3f9050a01cc3bd0431b37a2c1e29729ef15ee765
Signed-off-by: Dohyung Kim <dohyung2.kim@samsung.com>
-rw-r--r-- | mic/chroot.py | 8 | ||||
-rwxr-xr-x | mic/imager/baseimager.py | 12 | ||||
-rwxr-xr-x | mic/utils/misc.py | 24 |
3 files changed, 32 insertions, 12 deletions
diff --git a/mic/chroot.py b/mic/chroot.py index 85e8ba0..a8a41db 100644 --- a/mic/chroot.py +++ b/mic/chroot.py @@ -304,11 +304,11 @@ def chroot(chrootdir, bindmounts = None, execute = "/bin/bash"): arch = ELF_arch(chrootdir) if arch == "arm": - qemu_emulator = misc.setup_qemu_emulator(chrootdir, "arm") + qemu_emulators = misc.setup_qemu_emulator(chrootdir, "arm") elif arch == "mipsel": - qemu_emulator = misc.setup_qemu_emulator(chrootdir, "mipsel") + qemu_emulators = misc.setup_qemu_emulator(chrootdir, "mipsel") else: - qemu_emulator = None + qemu_emulators = [] savefs_before_chroot(chrootdir, None) @@ -326,5 +326,5 @@ def chroot(chrootdir, bindmounts = None, execute = "/bin/bash"): finally: cleanup_chrootenv(chrootdir, bindmounts, globalmounts) - if qemu_emulator: + for qemu_emulator in qemu_emulators: os.unlink(chrootdir + qemu_emulator) diff --git a/mic/imager/baseimager.py b/mic/imager/baseimager.py index b10f2ed..257af8e 100755 --- a/mic/imager/baseimager.py +++ b/mic/imager/baseimager.py @@ -144,8 +144,8 @@ class BaseImageCreator(object): self.image_format = None - # Save qemu emulator file name in order to clean up it finally - self.qemu_emulator = None + # Save qemu emulator file names in order to clean up it finally + self.qemu_emulators = [] # No ks provided when called by convertor, so skip the dependency check if self.ks: @@ -826,8 +826,8 @@ class BaseImageCreator(object): fs.makedirs(self._instroot + d) if self.target_arch and self.target_arch.startswith("arm") or \ - self.target_arch == "aarch64" or self.target_arch == "mipsel" : - self.qemu_emulator = misc.setup_qemu_emulator(self._instroot, + self.target_arch == "aarch64": + self.qemu_emulators = misc.setup_qemu_emulator(self._instroot, self.target_arch) self.get_cachedir(cachedir) @@ -868,8 +868,8 @@ class BaseImageCreator(object): if not os.path.islink(mtab): os.unlink(self._instroot + "/etc/mtab") - if self.qemu_emulator: - os.unlink(self._instroot + self.qemu_emulator) + for qemu_emulator in self.qemu_emulators: + os.unlink(self._instroot + qemu_emulator) except OSError: pass diff --git a/mic/utils/misc.py b/mic/utils/misc.py index 873ebbe..5aa5b16 100755 --- a/mic/utils/misc.py +++ b/mic/utils/misc.py @@ -898,6 +898,7 @@ def is_statically_linked(binary): return ", statically linked, " in runner.outs(['file', binary]) def setup_qemu_emulator(rootdir, arch): + qemu_emulators = [] # mount binfmt_misc if it doesn't exist if not os.path.exists("/proc/sys/fs/binfmt_misc"): modprobecmd = find_binary_path("modprobe") @@ -940,6 +941,7 @@ def setup_qemu_emulator(rootdir, arch): if not os.path.exists(rootdir + "/usr/bin"): makedirs(rootdir + "/usr/bin") shutil.copy(qemu_emulator, rootdir + qemu_emulator) + qemu_emulators.append(qemu_emulator) # disable selinux, selinux will block qemu emulator to run if os.path.exists("/usr/sbin/setenforce"): @@ -957,8 +959,26 @@ def setup_qemu_emulator(rootdir, arch): with open("/proc/sys/fs/binfmt_misc/register", "w") as fd: fd.write(qemu_arm_string) - - return qemu_emulator + else: + flags = "" + interpreter = "" + with open(node, "r") as fd: + for line in fd.readlines(): + if line.startswith("flags:"): + flags = line[len("flags:"):].strip() + elif line.startswith("interpreter"): + interpreter = line[len("interpreter"):].strip() + + if flags == "P" and interpreter.endswith("-binfmt"): + # copy binfmt wrapper when preserve-argv[0] flag is enabled + shutil.copy(os.path.realpath(interpreter), rootdir + interpreter) + qemu_emulators.append(interpreter) + elif not flags and interpreter != qemu_emulator: + # create symlink as registered qemu emulator + os.symlink(qemu_emulator, rootdir + interpreter) + qemu_emulators.append(interpreter) + + return qemu_emulators def SrcpkgsDownload(pkgs, repometadata, instroot, cachedir): def get_source_repometadata(repometadata): |