]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add nspawn version check to check_native() 959/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 5 May 2022 09:23:29 +0000 (11:23 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 5 May 2022 10:23:59 +0000 (12:23 +0200)
From systemd-nspawn v250 onwards, it's possible to run build scripts
on non-native architectures (as long as binfmt.d is configured correctly)
so update the native check to consider that.

mkosi/__init__.py
mkosi/backend.py

index 3cbfa177cfb84515b520f4136e10fa48a8a7f23d..c3abea7293dd72b117963d737b69f464010d0e1f 100644 (file)
@@ -85,6 +85,7 @@ from .backend import (
     nspawn_executable,
     nspawn_params_for_blockdev_access,
     nspawn_rlimit_params,
+    nspawn_version,
     patch_file,
     path_relative_to_cwd,
     run,
@@ -7471,7 +7472,7 @@ def check_root() -> None:
 
 
 def check_native(args: MkosiArgs) -> None:
-    if args.architecture is not None and args.architecture != platform.machine() and args.build_script:
+    if args.architecture is not None and args.architecture != platform.machine() and args.build_script and nspawn_version() < 250:
         die("Cannot (currently) override the architecture and run build commands")
 
 
index 384494db68beb116e4c7f217a76ff9eba8f7b464..2f35b065dff5c2bd0422e41e3877fdc3439633ae 100644 (file)
@@ -631,6 +631,10 @@ def nspawn_executable() -> str:
     return os.getenv("MKOSI_NSPAWN_EXECUTABLE", "systemd-nspawn")
 
 
+def nspawn_version() -> int:
+    return int(run([nspawn_executable(), "--version"], stdout=subprocess.PIPE).stdout.strip().split()[1])
+
+
 def run_workspace_command(
     args: MkosiArgs,
     root: Path,