Description: Add conditional control to mkfs_plugin to avoid newer filesystem options
 Over time, filesystems develop new options. vmdb2 is often used to install
 older OS releases. I added a catch-all conditional flag on mkfs to control
 the usage of options that are new-ish, to avoid breaking compatibility.
 .
 This answers to bug report #1108498, reported (and updated) to the GitLab
 tracker as issue 156. I suppose this patch will be included by the next
 release.
Author: Gunnar Wolf <gwolf@debian.org>
Origin: https://gitlab.com/larswirzenius/vmdb2/-/merge_requests/156
Bug: https://gitlab.com/larswirzenius/vmdb2/-/merge_requests/156
Forwarded: not-needed
Applied-Upstream: Commit 2468c454
Last-Update: 2025-08-17
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
Index: vmdb2/vmdb/plugins/mkfs.mdwn
===================================================================
--- vmdb2.orig/vmdb/plugins/mkfs.mdwn
+++ vmdb2/vmdb/plugins/mkfs.mdwn
@@ -11,6 +11,9 @@ Step keys:
 
 * `options` &mdash; OPTIONAL; aditional options for mkfs.
 
+* `target_old` &mdash; OPTIONAL; avoids using `ext4` options that are
+  incompatible with older (Debian Buster or earlier) systems.
+
 Example (in the .vmdb file):
 
     - mkfs: ext4
Index: vmdb2/vmdb/plugins/mkfs_plugin.py
===================================================================
--- vmdb2.orig/vmdb/plugins/mkfs_plugin.py
+++ vmdb2/vmdb/plugins/mkfs_plugin.py
@@ -26,7 +26,13 @@ class MkfsPlugin(vmdb.Plugin):
 
 class MkfsStepRunner(vmdb.StepRunnerInterface):
     def get_key_spec(self):
-        return {"mkfs": str, "partition": str, "label": "", "options": ""}
+        return {
+            "mkfs": str,
+            "partition": str,
+            "label": "",
+            "options": "",
+            "target_old": False,
+        }
 
     def run(self, values, settings, state):
         fstype = values["mkfs"]
@@ -51,16 +57,21 @@ class MkfsStepRunner(vmdb.StepRunnerInte
                 cmd.append("-L")
             cmd.append(label)
 
-        # Ext4 filesystem features large_dir and metadata_csum_seed
-        # are known to make versions of GRUB older than 2.06-8 unable
-        # to boot. Keep this around at least until it is no longer
-        # likely enough(?) users will try to build older target
-        # systems.
-        if fstype == "ext4":
-            cmd.append("-O")
-            cmd.append("^large_dir")
-            cmd.append("-O")
-            cmd.append("^metadata_csum_seed")
+        if values["target_old"]:
+            # Ext4 filesystem features large_dir and metadata_csum_seed
+            # are known to make versions of GRUB older than 2.06-8 unable
+            # to boot. Keep this around at least until it is no longer
+            # likely enough(?) users will try to build older target
+            # systems.
+            # orphan_file is known to break buster-generation installs for
+            # similar reasons.
+            if fstype == "ext4":
+                cmd.append("-O")
+                cmd.append("^large_dir")
+                cmd.append("-O")
+                cmd.append("^metadata_csum_seed")
+                cmd.append("-O")
+                cmd.append("^orphan_file")
 
         options = values["options"] or None
         if options:
