]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Move /work directory cleanup out of remove_files()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 25 Feb 2025 10:50:21 +0000 (11:50 +0100)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Tue, 25 Feb 2025 12:39:10 +0000 (13:39 +0100)
This has to be done after running the finalize scripts as a
mkosi.finalize.chroot might recreate the /work directory.

mkosi/__init__.py

index b8abba0451acc347452cf4010334cc4a98bd8f6b..8a4607265c8680b6fdac9a5b014b749605efe60a 100644 (file)
@@ -215,12 +215,12 @@ def mount_base_trees(context: Context) -> Iterator[None]:
 def remove_files(context: Context) -> None:
     """Remove files based on user-specified patterns"""
 
-    if context.config.remove_files or (context.root / "work").exists():
+    if context.config.remove_files:
         with complete_step("Removing files…"):
             remove = flatten(
                 context.root.glob(pattern.lstrip("/")) for pattern in context.config.remove_files
             )
-            rmtree(*remove, context.root / "work", sandbox=context.sandbox)
+            rmtree(*remove, sandbox=context.sandbox)
 
     if context.config.output_format.is_extension_image():
         with complete_step("Removing empty directories…"):
@@ -3951,6 +3951,8 @@ def build_image(context: Context) -> None:
     remove_files(context)
     run_finalize_scripts(context)
 
+    rmtree(context.root / "work")
+
     normalize_mtime(context.root, context.config.source_date_epoch)
     partitions = make_disk(context, skip=("esp", "xbootldr"), tabs=True, msg="Generating disk image")
     install_kernel(context, partitions)