]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
ensure builds with cache over device boundaries
authorDeniz Adrian <deniz@adrianer.de>
Wed, 23 Jul 2025 20:04:53 +0000 (22:04 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 24 Jul 2025 05:49:37 +0000 (07:49 +0200)
when running mkosi with the default cache dir/XDG_CACHE_HOME on a
different device than the mkosi working directory, mkosi falls back to
trying to copy the cache using `copy_tree` from tree.py.

the cache contains symlinks which are pointing to files on the host:

e.g. `mkosi.cache/debian...cache/usr/bin/mt -> /etc/alternatives/mt`

`os.listxattr()` defaults to `follow_symlinks=True`, which leads to
`FileNotFoundError`s if the files don't exist on the host, which stops
the build.

this patch ignores symlinks, but feels like a workaround, as our
assumption would be that such absolute links should not be traversed
outside the chroot in the first place.

Co-authored-by: ZauberNerd <zaubernerd@zaubernerd.de>
mkosi/tree.py

index 2090db8ed5e51aac148dc367a3d6458b9bfe8a3b..f90ed8ca9f6ce351d2134390554aa5fe5a343d28 100644 (file)
@@ -88,7 +88,7 @@ def maybe_make_nocow(path: Path) -> None:
 
 
 def tree_has_selinux_xattr(path: Path) -> bool:
-    return any("security.selinux" in os.listxattr(p) for p in (path, *path.rglob("*")))
+    return any("security.selinux" in os.listxattr(p, follow_symlinks=False) for p in (path, *path.rglob("*")))
 
 
 def copy_tree(