]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
fedora: Do GPG key symlink resolution in find_rpm_gpgkey()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 6 Feb 2025 10:26:48 +0000 (11:26 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 6 Feb 2025 11:40:37 +0000 (12:40 +0100)
We have to resolve the symlink within the tools tree if there is
one, so let's handle this in find_rpm_gpgkey() instead of outside.

mkosi/distributions/fedora.py
mkosi/installer/rpm.py

index 11f93cba5cf08f04837253d269629db90da3e60e..5e8af9c5fcabdca1ce8dd5f62c7de2c152807841 100644 (file)
@@ -37,17 +37,13 @@ def find_fedora_rpm_gpgkeys(context: Context) -> Iterable[str]:
         # For Rawhide, try to load the N+1 key, just in case our local configuration
         # still indicates that Rawhide==N, but really Rawhide==N+1.
         if context.config.release == "rawhide" and (rhs := startswith(key1, "file://")):
-            path = Path(rhs).resolve()
-            if m := versionre.match(path.name):
+            if m := versionre.match(Path(rhs).name):
                 version = int(m.group(1))
                 if key3 := find_rpm_gpgkey(
                     context,
                     key=f"RPM-GPG-KEY-fedora-{version + 1}-primary",
                     required=False,
                 ):
-                    # We yield the resolved path for key1, to make it clear that it's
-                    # for version N, and the other key is for version N+1.
-                    key1 = path.as_uri()
                     yield key3
 
         yield key1
index b3347502a090603120fae45efbb4e09f3dbaaae5..b8dcc55416b0cd5505a0363a72a6ba306b6e5558 100644 (file)
@@ -54,11 +54,13 @@ def find_rpm_gpgkey(
 ) -> Optional[str]:
     root = context.config.tools() if context.config.tools_tree_certificates else Path("/")
 
+    # We assume here that GPG keys will only ever be relative symlinks and never absolute symlinks.
+
     if gpgpath := next((root / "usr/share/distribution-gpg-keys").rglob(key), None):
-        return (Path("/") / gpgpath.relative_to(root)).as_uri()
+        return (Path("/") / gpgpath.resolve().relative_to(root)).as_uri()
 
     if gpgpath := next(Path(context.sandbox_tree / "etc/pki/rpm-gpg").rglob(key), None):
-        return (Path("/") / gpgpath.relative_to(context.sandbox_tree)).as_uri()
+        return (Path("/") / gpgpath.resolve().relative_to(context.sandbox_tree)).as_uri()
 
     if fallback and context.config.repository_key_fetch:
         return fallback