From: Daan De Meyer Date: Wed, 3 Jul 2024 10:17:03 +0000 (+0200) Subject: Call rmtree() on context.root after finalize_staging() X-Git-Tag: v24~64^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc9fd404359dbe2884175e0a8f82a513e0b4a79c;p=thirdparty%2Fmkosi.git Call rmtree() on context.root after finalize_staging() 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. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 34ac6f469..b6fcc62fd 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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)