]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
dnf: Fix /var package cache directory check in package_subdirs()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 12 Sep 2025 08:53:52 +0000 (10:53 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 12 Sep 2025 10:44:28 +0000 (12:44 +0200)
package_subdirs() receives the full cache directory path, not the
configured package cache directory (something like /var/cache/libdnf5),
so we fix the check to check if the parent directory of the given
cache directory is /var/cache so we don't have to know whether the
last component is dnf or libdnf5.

mkosi/installer/dnf.py

index 4f3ceb266bc68ecc87252076060234f7710adcfc..b966dbbafa31e9323d1f84d1f97d10319fe2c6fe 100644 (file)
@@ -29,8 +29,10 @@ class Dnf(PackageManager):
         dirs = [p for p in cache.iterdir() if p.is_dir() and "-" in p.name and "mkosi" not in p.name]
         return [
             (
+                # If the package cache directory is set to /var, we need to make sure we look up packages
+                # where they were stored by dnf, so don't do any special handling in that case.
                 d.relative_to(cache) / "packages"
-                if cache == Path("/var")
+                if cache.parent == Path("/var/cache")
                 # Cache directories look like <repo-id>-<baseurl-hash> so let's strip off the hash to reuse
                 # the same package cache directory regardless of baseurl.
                 else Path("packages") / d.name[: d.name.rfind("-")],