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)
finally:
cleanup_chrootenv(chrootdir, bindmounts, globalmounts)
- if qemu_emulator:
+ for qemu_emulator in qemu_emulators:
os.unlink(chrootdir + qemu_emulator)
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:
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)
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
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")
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"):
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):