[elbe-devel] [PATCH] elbepack: commands: preserve compatibility with old callers
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Wed May 8 12:14:53 CEST 2024
Commit c8bc244cb7c4 ("elbepack: use devel initvm automatically when running from source tree")
and commit 97b4d7bd2c79 ("elbepack: drop option --nesting")
made the functionality behind --devel and --nesting autmatic and dropped
the CLI options.
To not break users scripts, readd the CLI options but emit a warning.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbepack/commands/__init__.py | 16 ++++++++++++++++
elbepack/commands/init.py | 4 ++++
elbepack/commands/initvm.py | 4 ++++
3 files changed, 24 insertions(+)
diff --git a/elbepack/commands/__init__.py b/elbepack/commands/__init__.py
index e69de29bb2d1..fe1b7f054779 100644
--- a/elbepack/commands/__init__.py
+++ b/elbepack/commands/__init__.py
@@ -0,0 +1,16 @@
+# ELBE - Debian Based Embedded Rootfilesystem Builder
+# SPDX-License-Identifier: GPL-3.0-or-later
+# SPDX-FileCopyrightText: 2024 Linutronix GmbH
+
+import optparse
+import sys
+
+
+def _deprecated_option_cb(option, opt, value, parser):
+ print(f'Deprecated option \'{option}\' was used. This option is a NOOP.', file=sys.stderr)
+
+
+def add_deprecated_optparse_option(oparser, *args, **kwargs):
+ oparser.add_option(*args, **kwargs,
+ action='callback', callback=_deprecated_option_cb,
+ help=optparse.SUPPRESS_HELP)
diff --git a/elbepack/commands/init.py b/elbepack/commands/init.py
index 02f0a4f5c287..6db8ed8ae53d 100644
--- a/elbepack/commands/init.py
+++ b/elbepack/commands/init.py
@@ -12,6 +12,7 @@ import sys
from optparse import OptionParser
import elbepack.init
+from elbepack.commands import add_deprecated_optparse_option
from elbepack.config import cfg
from elbepack.debinstaller import NoKinitrdException, copy_kinitrd
from elbepack.log import elbe_logging
@@ -51,6 +52,9 @@ def run_command(argv):
default=False,
help='start qemu in graphical mode to enable console switch')
+ add_deprecated_optparse_option(oparser, '--nesting')
+ add_deprecated_optparse_option(oparser, '--devel')
+
oparser.add_option(
'--skip-build-bin',
action='store_false',
diff --git a/elbepack/commands/initvm.py b/elbepack/commands/initvm.py
index 531b48d29c5d..4952a3497d69 100644
--- a/elbepack/commands/initvm.py
+++ b/elbepack/commands/initvm.py
@@ -6,6 +6,7 @@ import os
import sys
from optparse import OptionParser
+from elbepack.commands import add_deprecated_optparse_option
from elbepack.initvmaction import InitVMAction, InitVMError
from elbepack.xmlpreprocess import PreprocessWrapper
@@ -47,6 +48,9 @@ def run_command(argv):
oparser.add_option('--writeproject', dest='writeproject', default=None,
help='write project name to file')
+ add_deprecated_optparse_option(oparser, '--nesting')
+ add_deprecated_optparse_option(oparser, '--devel')
+
oparser.add_option(
'--build-sdk',
dest='build_sdk',
---
base-commit: c4d2d11ef1f913688c9a97fbfe48d09a584adb21
change-id: 20240508-deprecated-args-4e352ad9177c
Best regards,
--
Thomas Weißschuh <thomas.weissschuh at linutronix.de>
More information about the elbe-devel
mailing list