From: Daan De Meyer Date: Thu, 5 May 2022 09:23:29 +0000 (+0200) Subject: Add nspawn version check to check_native() X-Git-Tag: v13~43^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F959%2Fhead;p=thirdparty%2Fmkosi.git Add nspawn version check to check_native() 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. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 3cbfa177c..c3abea729 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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") diff --git a/mkosi/backend.py b/mkosi/backend.py index 384494db6..2f35b065d 100644 --- a/mkosi/backend.py +++ b/mkosi/backend.py @@ -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,