]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Only bind mount /var/lib/pacman/local from image if it exists
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 9 Feb 2024 11:12:22 +0000 (12:12 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 9 Feb 2024 11:45:34 +0000 (12:45 +0100)
When running the finalize scripts, this directory might have been
cleaned up already as part of removing package manager metadata so
let's make sure we don't mount it in that case.

mkosi/installer/pacman.py

index c1906dce5ea83febae9585fec2b4b6267d3db771..d4eaca9ecb7b1dae380ebfe5484343bc87162738 100644 (file)
@@ -41,14 +41,15 @@ class Pacman(PackageManager):
     def mounts(cls, context: Context) -> list[PathString]:
         return [
             *super().mounts(context),
-            # pacman reuses the same directory for the sync databases and the local database containing the list of
-            # installed packages. The format should go in the cache directory, the latter should go in the image, so we
-            # bind mount the local directory from the image to make sure that happens.
-            "--bind", context.root / "var/lib/pacman/local", "/var/lib/pacman/local",
             # pacman writes downloaded packages to the first writable cache directory. We don't want it to write to our
             # local repository directory so we expose it as a read-only directory to pacman.
             "--ro-bind", context.packages, "/var/cache/pacman/mkosi",
-        ]
+        ] + ([
+            # pacman reuses the same directory for the sync databases and the local database containing the list of
+            # installed packages. The former should go in the cache directory, the latter should go in the image,
+            # so we bind mount the local directory from the image to make sure that happens.
+            "--bind", context.root / "var/lib/pacman/local", "/var/lib/pacman/local",
+        ] if (context.root / "var/lib/pacman/local").exists() else [])
 
     @classmethod
     def setup(cls, context: Context, repositories: Iterable[Repository]) -> None: