]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
fedora: also look for secondary GPG keys
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 16 Feb 2024 16:07:04 +0000 (17:07 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 16 Feb 2024 16:07:04 +0000 (17:07 +0100)
Older Fedora versions distributed and used those. No recent
versions do that, but I think they are still generated "just in case".
So let's check for them, in case Fedora decides to use them
again, and so that checking for the very old versions works too.

mkosi/distributions/fedora.py
mkosi/util.py

index 8fa6a5ddd41352fee6c76db8415845a7beea6aac..d4d3a666a69a3e77ef16a7a562ec360f2a3b17af 100644 (file)
@@ -14,7 +14,20 @@ from mkosi.installer import PackageManager
 from mkosi.installer.dnf import Dnf
 from mkosi.installer.rpm import RpmRepository, find_rpm_gpgkey, setup_rpm
 from mkosi.log import die
-from mkosi.util import listify
+from mkosi.util import listify, tuplify
+
+
+@tuplify
+def find_fedora_rpm_gpgkeys(context: Context) -> Iterable[str]:
+    key1 = find_rpm_gpgkey(context, key=f"RPM-GPG-KEY-fedora-{context.config.release}-primary")
+    key2 = find_rpm_gpgkey(context, key=f"RPM-GPG-KEY-fedora-{context.config.release}-secondary")
+
+    if key1:
+        yield key1
+    if key2:
+        yield key2
+    if not key1 and not key2:
+        yield "https://fedoraproject.org/fedora.gpg"
 
 
 class Installer(DistributionInstaller):
@@ -74,12 +87,7 @@ class Installer(DistributionInstaller):
     @classmethod
     @listify
     def repositories(cls, context: Context) -> Iterable[RpmRepository]:
-        gpgurls = (
-            find_rpm_gpgkey(
-                context,
-                key=f"RPM-GPG-KEY-fedora-{context.config.release}-primary",
-            ) or "https://fedoraproject.org/fedora.gpg",
-        )
+        gpgurls = find_fedora_rpm_gpgkeys(context)
 
         if context.config.local_mirror:
             yield RpmRepository("fedora", f"baseurl={context.config.local_mirror}", gpgurls)
index ba7c272553ba5bde6222d113a56f3f377596d3b7..a375dd8058379752ec9b412b2ad96d378171d09c 100644 (file)
@@ -40,6 +40,13 @@ def listify(f: Callable[..., Iterable[T]]) -> Callable[..., list[T]]:
     return functools.update_wrapper(wrapper, f)
 
 
+def tuplify(f: Callable[..., Iterable[T]]) -> Callable[..., tuple[T, ...]]:
+    def wrapper(*args: Any, **kwargs: Any) -> tuple[T, ...]:
+        return tuple(f(*args, **kwargs))
+
+    return functools.update_wrapper(wrapper, f)
+
+
 @dictify
 def read_env_file(path: Path) -> Iterator[tuple[str, str]]:
     with path.open() as f: