]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Call rmtree() on context.root after finalize_staging()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 3 Jul 2024 10:17:03 +0000 (12:17 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 3 Jul 2024 10:17:03 +0000 (12:17 +0200)
After we've finalized the staging directory, there is no more need
for the root directory in the workspace. It used to get cleaned by
the setup_workspace() context manager but this is rather slow (can
take more than a second). By calling rmtree() explicitly, if we're
on a btrfs filesystem, we'll call btrfs subvolume delete which is
much faster than rm.

mkosi/__init__.py

index 34ac6f469ece8c51117f49800f9f05549011358c..b6fcc62fdde1f01ead1600295d22e8b6564a3ad0 100644 (file)
@@ -3835,6 +3835,7 @@ def build_image(context: Context) -> None:
 
         if context.config.output_format == OutputFormat.none:
             finalize_staging(context)
+            rmtree(context.root)
             return
 
         install_volatile_packages(context)
@@ -3928,6 +3929,7 @@ def build_image(context: Context) -> None:
 
     run_postoutput_scripts(context)
     finalize_staging(context)
+    rmtree(context.root)
 
     print_output_size(context.config.output_dir_or_cwd() / context.config.output_with_compression)