From 5b831d899df0c0abe477c6da70b0a4ef81f0b32f Mon Sep 17 00:00:00 2001 From: Bart Ribbers Date: Wed, 22 Apr 2020 11:13:32 +0200 Subject: [PATCH] Automatically mount binfmt_misc if not mounted already (MR 1923) This is needed at least on Alpine Linux, and probably on distros like NixOS as well. Fixes: https://gitlab.com/postmarketOS/pmbootstrap/-/issues/1135 --- pmb/helpers/other.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pmb/helpers/other.py b/pmb/helpers/other.py index 49855744..01b92784 100644 --- a/pmb/helpers/other.py +++ b/pmb/helpers/other.py @@ -48,17 +48,19 @@ 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. + Otherwise, load the module and mount binfmt_misc. + If that fails as well, raise an exception pointing the user to the wiki. """ path = "/proc/sys/fs/binfmt_misc/status" 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 + ">") + pmb.helpers.run.root(args, ["modprobe", "binfmt_misc"]) + pmb.helpers.run.root(args, ["mount", "-t", "binfmt_misc", "none", "/proc/sys/fs/binfmt_misc"]) + + if not os.path.exists(path): + link = "https://postmarketos.org/binfmt_misc" + raise RuntimeError(f"Failed to set up binfmt_misc, see: {link}") def migrate_success(args, version):