diff --git a/virtme/commands/configkernel.py b/virtme/commands/configkernel.py index f72e6a9..94917b7 100644 --- a/virtme/commands/configkernel.py +++ b/virtme/commands/configkernel.py @@ -38,6 +38,12 @@ def make_parser(): help="Use a custom config snippet file to override specific config options", ) + parser.add_argument( + "--no-update", + action="store_true", + help="Skip if the config file already exists", + ) + g = parser.add_argument_group(title="Mode").add_mutually_exclusive_group() g.add_argument( @@ -289,6 +295,8 @@ def do_it(): maketarget = arch.defconfig_target updatetarget = "olddefconfig" elif args.update: + if args.no_update: + arg_fail("--update and --no-update cannot be used together") maketarget = None updatetarget = "olddefconfig" else: @@ -306,10 +314,16 @@ def do_it(): if config_dir and os.path.isdir(config_dir): config = os.path.join(config_dir, config) - if maketarget is not None or not os.path.exists(config): - # Set up an initial config - if maketarget is None: - maketarget = arch.defconfig_target + if os.path.exists(config): + if args.no_update: + print(f"{config} file exists: no modifications have been done") + return 0 + else: + if args.update: + print(f"Error: {config} file is missing") + return 1 + + if maketarget is not None: try: subprocess.check_call(["make"] + archargs + [maketarget]) except Exception as exc: diff --git a/virtme_ng/run.py b/virtme_ng/run.py index 6991d2d..0e88db4 100644 --- a/virtme_ng/run.py +++ b/virtme_ng/run.py @@ -565,7 +565,7 @@ def checkout(self, args): def config(self, args): """Perform a make config operation on a kernel source directory.""" arch = args.arch - cmd = "virtme-configkernel --update" + cmd = "virtme-configkernel --defconfig --no-update" if arch is not None: if arch not in ARCH_MAPPING: arg_fail(f"unsupported architecture: {arch}")