From: Daan De Meyer Date: Thu, 4 Aug 2022 12:54:00 +0000 (+0200) Subject: Add compat with older nspawn that doesn't know --rlimit X-Git-Tag: v14~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6434b665fc554cb90b700aad9d84f99a89ccd23d;p=thirdparty%2Fmkosi.git Add compat with older nspawn that doesn't know --rlimit Required for compat with Ubuntu 18.04 --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index fbc8d9b99..9cce217a5 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -86,6 +86,7 @@ from .backend import ( is_epel_variant, is_rpm_distribution, nspawn_executable, + nspawn_knows_arg, nspawn_params_for_blockdev_access, nspawn_rlimit_params, nspawn_version, @@ -7325,10 +7326,6 @@ def install_dir(args: MkosiArgs, root: Path) -> Path: return args.install_dir or workspace(root).joinpath("dest") -def nspawn_knows_arg(arg: str) -> bool: - return bytes("unrecognized option", "UTF-8") not in run([nspawn_executable(), arg], stderr=PIPE, check=False).stderr - - def run_build_script(args: MkosiArgs, root: Path, raw: Optional[BinaryIO]) -> None: if args.build_script is None: return diff --git a/mkosi/backend.py b/mkosi/backend.py index 48c7e30d2..9402a5d34 100644 --- a/mkosi/backend.py +++ b/mkosi/backend.py @@ -610,6 +610,10 @@ def var_tmp(root: Path) -> Path: return p +def nspawn_knows_arg(arg: str) -> bool: + return "unrecognized option" not in run([nspawn_executable(), arg], stderr=subprocess.PIPE, check=False, text=True).stderr + + def nspawn_params_for_blockdev_access(args: MkosiArgs, loopdev: Path) -> List[str]: assert args.partition_table is not None @@ -643,7 +647,7 @@ def format_rlimit(rlimit: int) -> str: def nspawn_rlimit_params() -> Sequence[str]: return [ f"--rlimit=RLIMIT_CORE={format_rlimit(resource.RLIMIT_CORE)}", - ] + ] if nspawn_knows_arg("--rlimit") else [] def nspawn_executable() -> str: