From b3456f8ec3194f3e46ec3e16aabda2fb2d2e9b73 Mon Sep 17 00:00:00 2001 From: ldericher Date: Tue, 18 Aug 2020 17:49:49 +0200 Subject: [PATCH] subcommand "conf-clean" --- src/kiwi/subcommands/__init__.py | 3 ++- src/kiwi/subcommands/conf.py | 37 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/kiwi/subcommands/__init__.py b/src/kiwi/subcommands/__init__.py index 13e27a8..637f9be 100644 --- a/src/kiwi/subcommands/__init__.py +++ b/src/kiwi/subcommands/__init__.py @@ -1,7 +1,7 @@ # local from .build import BuildCommand from .cmd import CmdCommand -from .conf import ConfCopyCommand, ConfPurgeCommand +from .conf import ConfCopyCommand, ConfPurgeCommand, ConfCleanCommand from .disable import DisableCommand from .down import DownCommand from .enable import EnableCommand @@ -22,6 +22,7 @@ __all__ = [ 'CmdCommand', 'ConfCopyCommand', 'ConfPurgeCommand', + 'ConfCleanCommand', 'DisableCommand', 'DownCommand', 'EnableCommand', diff --git a/src/kiwi/subcommands/conf.py b/src/kiwi/subcommands/conf.py index 702261e..d221943 100644 --- a/src/kiwi/subcommands/conf.py +++ b/src/kiwi/subcommands/conf.py @@ -62,3 +62,40 @@ class ConfPurgeCommand(SubCommand): ) return True + + +class ConfCleanCommand(SubCommand): + """kiwi conf-clean""" + + def __init__(self): + super().__init__( + 'conf-clean', + description="Cleanly sync all configs to target folder, relaunch affected projects" + ) + + def run(self, runner, config, args): + result = True + + # down all projects with config directories + affected_projects = [] + + for project_name in list_projects(config): + project_conf = f"{get_project_dir(config, project_name)}/{CONF_DIRECTORY_NAME}" + + if os.path.isdir(project_conf): + affected_projects.append(project_name) + + for project_name in affected_projects: + args.projects = project_name + result &= runner.run('down') + + # cleanly sync configs + result &= runner.run('conf-purge') + result &= runner.run('conf-purge') + + # bring projects back up + for project_name in affected_projects: + args.projects = project_name + result &= runner.run('up') + + return result \ No newline at end of file