From: Daan De Meyer Date: Mon, 31 Mar 2025 10:43:50 +0000 (+0200) Subject: Disable orphan_file automatically if not supported X-Git-Tag: v26~285^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4f70cc16562a25fce9c2e2e7f510637b04bc15a;p=thirdparty%2Fmkosi.git Disable orphan_file automatically if not supported Let's automatically detect if the orphan_file ext4 feature needs to be disabled if it's not supported by the target distribution official kernel. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 39dd99fca..f8c28ff5d 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -3386,6 +3386,25 @@ def make_image( cmdline += ["--definitions", workdir(d)] opts += ["--ro-bind", d, workdir(d)] + def can_orphan_file(distribution: Optional[Distribution], release: Optional[str]) -> bool: + if distribution is None: + return True + + return not ( + (distribution == Distribution.centos and release and GenericVersion(release) == 9) + or (distribution == Distribution.ubuntu and release == "jammy") + ) + + # Make sure the ext4 orphan_file feature is disabled if the target distribution official kernel does not + # support it. + env = {} + if ( + not can_orphan_file(context.config.distribution, context.config.release) + and can_orphan_file(*detect_distribution(context.config.tools())) + and "SYSTEMD_REPART_MKFS_EXT4_OPTIONS" not in context.config.environment + ): + env["SYSTEMD_REPART_MKFS_EXT4_OPTIONS"] = "-O ^orphan_file" + with complete_step(msg): output = json.loads( run_systemd_sign_tool( @@ -3398,6 +3417,7 @@ def make_image( certificate_source=context.config.verity_certificate_source, key=context.config.verity_key if verity in (Verity.auto, Verity.signed) else None, key_source=context.config.verity_key_source, + env=env, stdout=subprocess.PIPE, devices=not context.config.repart_offline, ).stdout