]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Make package_subdirs() return relative paths
authorDaanDeMeyer <daan.j.demeyer@gmail.com>
Sat, 5 Jul 2025 21:47:51 +0000 (23:47 +0200)
committerDaanDeMeyer <daan.j.demeyer@gmail.com>
Fri, 22 Aug 2025 19:54:52 +0000 (21:54 +0200)
mkosi/__init__.py
mkosi/installer/__init__.py
mkosi/installer/apt.py
mkosi/installer/dnf.py
mkosi/installer/pacman.py
mkosi/installer/zypper.py

index caf66151013ee997bd7c7c8be48242b21befd67e..9d654a13f7477ca0974665db8d60c098aef3e414 100644 (file)
@@ -3922,7 +3922,7 @@ def copy_repository_metadata(config: Config, dst: Path) -> None:
                 # cp doesn't support excluding directories but we can imitate it by bind mounting
                 # an empty directory over the directories we want to exclude.
                 exclude = flatten(
-                    ("--ro-bind", tmp, workdir(p))
+                    ("--ro-bind", tmp, workdir(cachedir / p))
                     for p in config.distribution.package_manager(config).package_subdirs(cachedir)
                 )
 
@@ -4896,7 +4896,7 @@ def sync_repository_metadata(
 
     src = last.package_cache_dir_or_default() / "cache" / subdir
     for p in last.distribution.package_manager(last).package_subdirs(src):
-        p.mkdir(parents=True, exist_ok=True)
+        (src / p).mkdir(parents=True, exist_ok=True)
 
     # If we're in incremental mode and caching metadata is not explicitly disabled, cache the keyring and the
     # synced repository metadata so we can reuse them later.
index fa7418ae09a65d3531ce3a85c372cf7a389db7db..92d5a49b89313bcbd56a56c6b789428b4978c9ca 100644 (file)
@@ -89,12 +89,12 @@ class PackageManager:
                 mounts += flatten(
                     (
                         "--bind",
-                        context.config.package_cache_dir_or_default() / d / subdir / p.relative_to(src),
-                        Path("/var") / d / subdir / p.relative_to(src),
+                        context.config.package_cache_dir_or_default() / d / subdir / p,
+                        Path("/var") / d / subdir / p,
                     )
                     for p in caches
                     if (
-                        context.config.package_cache_dir_or_default() / d / subdir / p.relative_to(src)
+                        context.config.package_cache_dir_or_default() / d / subdir / p
                     ).exists()
                 )
 
index 6b6842ebc5f4ef7253853d768018710579a586eb..16816ac33c5c102cdf886a3e396a06c4f569b395 100644 (file)
@@ -55,7 +55,7 @@ class Apt(PackageManager):
 
     @classmethod
     def package_subdirs(cls, cache: Path) -> list[Path]:
-        return [cache / "archives"]
+        return [Path("archives")]
 
     @classmethod
     def state_subdirs(cls, state: Path) -> list[Path]:
index ec69a145a5957cb0d8d5b259a4113d4ddca0ce91..9e65cff2e03ae6e4879561c938ba53d6ace136f8 100644 (file)
@@ -27,7 +27,7 @@ class Dnf(PackageManager):
     @classmethod
     def package_subdirs(cls, cache: Path) -> list[Path]:
         return [
-            p / "packages" for p in cache.iterdir() if p.is_dir() and "-" in p.name and "mkosi" not in p.name
+            (p / "packages").relative_to(cache) for p in cache.iterdir() if p.is_dir() and "-" in p.name and "mkosi" not in p.name
         ]
 
     @classmethod
index 9d6343b1cb8625f0e969bc7f3857ad15790bbe5f..0d85fdcc753d7d2d75414bc6c108d67fc1d1f64d 100644 (file)
@@ -36,7 +36,7 @@ class Pacman(PackageManager):
 
     @classmethod
     def package_subdirs(cls, cache: Path) -> list[Path]:
-        return [cache / "pkg"]
+        return [Path("pkg")]
 
     @classmethod
     def state_subdirs(cls, state: Path) -> list[Path]:
index 0f6c689be88f5f0a5520ea491b758ab4e0f37c2f..d513f23bfbe14e33eb3beab8a1a2b2cc77a1155b 100644 (file)
@@ -24,7 +24,7 @@ class Zypper(PackageManager):
 
     @classmethod
     def package_subdirs(cls, cache: Path) -> list[Path]:
-        return [cache / "packages"]
+        return [Path("packages")]
 
     @classmethod
     def scripts(cls, context: Context) -> dict[str, list[PathString]]: