]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add stubs for --nspawn-keep-unit, --default and --cache
authorLuca Boccassi <bluca@debian.org>
Sun, 2 Jul 2023 23:30:03 +0000 (00:30 +0100)
committerLuca Boccassi <bluca@debian.org>
Tue, 4 Jul 2023 00:35:36 +0000 (01:35 +0100)
Avoid breaking existing scripts and tools. Catch, print a warning
and delete.

mkosi/config.py

index 5f180a4e972515ce10be2636ed3b19b760130dd4..e1d86d95a094161436b9dabd3035a1133d28c4a5 100644 (file)
@@ -1658,6 +1658,20 @@ class MkosiConfigParser:
             default=[],
             help="Build the specified preset",
         )
+        parser.add_argument(
+            "--nspawn-keep-unit",
+            action="store_true",
+            help=argparse.SUPPRESS,
+        )
+        parser.add_argument(
+            "--default",
+            help=argparse.SUPPRESS,
+        )
+        parser.add_argument(
+            "--cache",
+            metavar="PATH",
+            help=argparse.SUPPRESS,
+        )
 
         last_section = None
 
@@ -1690,6 +1704,21 @@ class MkosiConfigParser:
 
         return parser
 
+    def backward_compat_stubs(self, namespace: argparse.Namespace) -> None:
+        # These can be removed once mkosi v15 is available in LTS distros and compatibility with <= v14
+        # is no longer needed in build infrastructure (e.g.: OBS).
+        if getattr(namespace, "nspawn_keep_unit", None):
+            delattr(namespace, "nspawn_keep_unit")
+            print("Warning: --nspawn-keep-unit is no longer supported")
+
+        if getattr(namespace, "default", None):
+            delattr(namespace, "default")
+            print("Warning: --default is no longer supported")
+
+        if getattr(namespace, "cache", None):
+            delattr(namespace, "cache")
+            print("Warning: --cache is no longer supported")
+
     def parse(self, argv: Optional[Sequence[str]] = None) -> tuple[MkosiArgs, tuple[MkosiConfig, ...]]:
         presets = []
         namespace = argparse.Namespace()
@@ -1769,6 +1798,10 @@ class MkosiConfigParser:
 
                 setattr(ns, s.dest, default)
 
+        # Manipulate some old settings to make them work with the new settings, for those typically used in
+        # infrastructure scripts rather than image-specific configuration.
+        self.backward_compat_stubs(namespace)
+
         return args, tuple(load_config(ns) for ns in presets)