)
-def run_clean(args: Args, config: Config, *, resources: Path) -> None:
+def run_clean(args: Args, config: Config) -> None:
# We remove any cached images if either the user used --force twice, or he/she called "clean"
# with it passed once. Let's also remove the downloaded package cache if the user specified one
# additional "--force".
if remove_image_cache and config.cache_dir:
metadata = [metadata_cache(config)] if not config.image else []
- initrd = (
- cache_tree_paths(finalize_default_initrd(config, tools=False, resources=resources))
- if config.distribution != Distribution.custom
- else []
- )
-
- if any(p.exists() for p in itertools.chain(cache_tree_paths(config), initrd, metadata)):
+ if any(p.exists() for p in itertools.chain(cache_tree_paths(config), metadata)):
with complete_step(f"Removing cache entries of {config.name()} imageā¦"):
rmtree(
- *(p for p in itertools.chain(cache_tree_paths(config), initrd, metadata) if p.exists()),
+ *(p for p in itertools.chain(cache_tree_paths(config), metadata) if p.exists()),
sandbox=sandbox,
)
if args.verb == Verb.clean:
if tools:
- run_clean(args, tools, resources=resources)
+ run_clean(args, tools)
for config in images:
- run_clean(args, config, resources=resources)
+ run_clean(args, config)
+
+ if last.output_format != OutputFormat.none:
+ run_clean(args, finalize_default_initrd(last, tools=False, resources=resources))
rmtree(Path(".mkosi-private"))
hint="Build once with -i yes to update the tools tree",
)
- run_clean(args, tools, resources=resources)
+ run_clean(args, tools)
# First, process all directory removals because otherwise if different images share directories
# a later image build could end up deleting the output generated by an earlier image build.
if args.verb.needs_build() and (needs_build(args, last) or args.wipe_build_dir):
for config in images:
- run_clean(args, config, resources=resources)
+ run_clean(args, config)
+
+ if last.output_format != OutputFormat.none:
+ run_clean(args, finalize_default_initrd(last, tools=False, resources=resources))
if tools and not (tools.output_dir_or_cwd() / tools.output).exists():
with prepend_to_environ_path(tools):