]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Rework tools tree cache manifest serialization
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 2 Oct 2024 10:15:02 +0000 (12:15 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 2 Oct 2024 16:27:59 +0000 (18:27 +0200)
Let's encode the full path and not just the name. We'll rework the
tests in the next commit to not nuke the tools tree every time.

Let's also track the timestamp of the root directory of the tools
tree as a heuristic for whether it's been updated or not.

mkosi/config.py

index d422a150dfb932d005fff7b73b1e08ddadb5c2a5..010c3047fd98e38201c58b35def4f531d81c2600 100644 (file)
@@ -1816,13 +1816,8 @@ class Config:
             "prepare_scripts": sorted(
                 base64.b64encode(script.read_bytes()).decode() for script in self.prepare_scripts
             ),
-            # We don't use the full path here since tests will often use temporary directories for the output
-            # directory which would trigger a rebuild every time.
-            "tools_tree": self.tools_tree.name if self.tools_tree else None,
-            "tools_tree_distribution": self.tools_tree_distribution,
-            "tools_tree_release": self.tools_tree_release,
-            "tools_tree_mirror": self.tools_tree_mirror,
-            "tools_tree_packages": sorted(self.tools_tree_packages),
+            # Statting the root directory of the tools tree isn't fool proof but should be good enough.
+            "tools_tree": [self.tools_tree, self.tools_tree.stat().st_mtime_ns] if self.tools_tree else [],
         }
 
     def to_dict(self) -> dict[str, Any]: