From: Luca Boccassi Date: Sun, 2 Jul 2023 23:30:03 +0000 (+0100) Subject: Add stubs for --nspawn-keep-unit, --default and --cache X-Git-Tag: v15~90^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bbf7b64188f182428f02f30b371f49d59dc4ff26;p=thirdparty%2Fmkosi.git Add stubs for --nspawn-keep-unit, --default and --cache Avoid breaking existing scripts and tools. Catch, print a warning and delete. --- diff --git a/mkosi/config.py b/mkosi/config.py index 5f180a4e9..e1d86d95a 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -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)