diff --git a/pmb/chroot/binfmt.py b/pmb/chroot/binfmt.py index 5f30ee54..0d47e0af 100644 --- a/pmb/chroot/binfmt.py +++ b/pmb/chroot/binfmt.py @@ -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) diff --git a/pmb/helpers/other.py b/pmb/helpers/other.py index 9b8dc535..d5ed667f 100644 --- a/pmb/helpers/other.py +++ b/pmb/helpers/other.py @@ -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: