diff mbox series

[1/3] rteval: added code to download default kernel version if no version is specified

Message ID 20230628195145.636652-2-ashelat@redhat.com
State New
Headers show
Series Updates for converting optparse to argparse in | expand

Commit Message

Anubhav Shelat June 28, 2023, 7:51 p.m. UTC
Previously, the usuage was "./rteval-cmd -S [KERNEL_VERSION]", and
rteval-cmd would throw an error if no kernel version was provided.
Now, rteval-cmd will download the default kernel version, as specified
in rteval/modules/loads/kcompile.py.

Signed-off-by: Anubhav Shelat <ashelat@redhat.com>
---
 rteval-cmd | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/rteval-cmd b/rteval-cmd
index f715fec1e21c..ae94bd98cc11 100755
--- a/rteval-cmd
+++ b/rteval-cmd
@@ -166,7 +166,7 @@  def parse_options(cfg, parser, cmdargs):
     parser.add_argument("-V", "--version", dest="rteval___version",
                       action='store_true', default=False,
                       help='print rteval version and exit')
-    parser.add_argument("-S", "--source-download", dest="rteval___srcdownload",
+    parser.add_argument("-S", "--source-download", nargs="*", dest="rteval___srcdownload",
                         type=str, default=None, metavar="KERNEL_VERSION",
                         help='download a source kernel from kernel.org and exit')
 
@@ -191,8 +191,16 @@  def parse_options(cfg, parser, cmdargs):
             ind = cmdargs.index('--raw-histogram')
         cmd_args = cmdargs[ind+1:]
         cmdargs = cmdargs[:ind+1]
+
     cmd_opts = parser.parse_args(args=cmdargs)
 
+    # if no kernel version was provided for --source-download, set version to default
+    if (sys.argv.count('-S')+sys.argv.count('--source-download')) > 0:
+        if cmd_opts.rteval___srcdownload == []:
+            cmd_opts.rteval___srcdownload = ModuleParameters()["source"]["default"].replace(".tar.xz", "")
+        else:
+            cmd_opts.rteval___srcdownload = cmd_opts.rteval___srcdownload[0]
+
     if cmd_opts.rteval___version:
         print(f"rteval version {RTEVAL_VERSION}")
         sys.exit(0)