Skip to content

Commit

Permalink
config: option not to update if there is a config file
Browse files Browse the repository at this point in the history
The '--update' option of virtme-configkernel is there to "update
existing config for virtme" according to the help message.

vng was calling 'virtme-configkernel --update', but the goal was not to
modify the config file if it was present, just in case it has been
modified in between two build calls. To support that, the '--update'
option had been modified ... not to update the config file if it was
present, in contradiction with the option name and its 'help' text.

A new '--no-update' parameter is now available: if the config file
exists, nothing is done. 'vng' is then now calling:

  virtme-configkernel --defconfig --no-update

So if the config file exists, the config is not modified, but a message
is now printed in stdout (only visible when vng is used with --verbose).

Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
  • Loading branch information
matttbe committed Mar 18, 2024
1 parent 2f07be9 commit 2dda460
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
22 changes: 18 additions & 4 deletions virtme/commands/configkernel.py
Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion virtme_ng/run.py
Expand Up @@ -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}")
Expand Down

0 comments on commit 2dda460

Please sign in to comment.