]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Empty install directory before running build script
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 21 Apr 2023 10:25:01 +0000 (12:25 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 21 Apr 2023 10:51:36 +0000 (12:51 +0200)
The install directory is shared between distros, and depending on
the distro, different files might be installed. Let's make sure we
empty the install directory before running the build so that files
from different distros don't end up mixed in the install directory.

mkosi/__init__.py

index aa15cf0a9e19391fbb568d1129560f9e623bbe09..a026b31b987c2a77d3750bbf07ac49b4f3763b23 100644 (file)
@@ -1801,6 +1801,10 @@ def run_build_script(state: MkosiState) -> None:
     if state.config.build_script is None or state.for_cache:
         return
 
+    # Make sure that if mkosi.installdir/ is used, any leftover files from a previous run are removed.
+    if state.config.install_dir:
+        empty_directory(state.config.install_dir)
+
     with complete_step("Running build script…"), mount_build_overlay(state, read_only=True):
         bwrap: list[PathString] = [
             "--bind", state.config.build_sources, "/work/src",