Add a check for binfmt_misc (#1236)

Closes #1223.
This commit is contained in:
Alexander 2018-02-17 21:41:54 +01:00 committed by Oliver Smith
parent 886d19620e
commit 57b45a4798
2 changed files with 19 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import os
import logging
import pmb.helpers.run
import pmb.helpers.other
import pmb.parse
import pmb.parse.arch
@ -35,6 +36,7 @@ def register(args, arch):
arch_debian = pmb.parse.arch.alpine_to_debian(arch)
if is_registered(arch_debian):
return
pmb.helpers.other.check_binfmt_misc(args)
pmb.chroot.apk.install(args, ["qemu-user-static-repack",
"qemu-user-static-repack-binfmt"])
info = pmb.parse.binfmt_info(args, arch_debian)

View File

@ -61,6 +61,23 @@ def check_grsec(args):
" more details: <" + link + ">")
def check_binfmt_misc(args):
"""
Check if the 'binfmt_misc' module is loaded by checking, if
/proc/sys/fs/binfmt_misc/ exists. If it exists, then do nothing.
Otherwise, raise an exception pointing to user to the Wiki.
"""
path = "/proc/sys/fs/binfmt_misc/"
if os.path.exists(path):
return
link = "https://postmarketos.org/binfmt_misc"
raise RuntimeError("It appears that your system has not loaded the"
" module 'binfmt_misc'. This is required to run"
" foreign architecture programs with QEMU (eg."
" armhf on x86_64):\n See: <" + link + ">")
def migrate_success(args):
logging.info("Migration done")
with open(args.work + "/version", "w") as handle: