]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Drop gpg path locations
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 3 May 2023 11:25:07 +0000 (13:25 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 3 May 2023 13:56:04 +0000 (15:56 +0200)
All of our gpg paths point to locations in rpms gpg database so they
should already be known by dnf and as such there's no point in listing
them explicitly in the config file. Let's only keep the urls in mkosi.

mkosi/distributions/alma.py
mkosi/distributions/centos.py
mkosi/distributions/fedora.py
mkosi/distributions/mageia.py
mkosi/distributions/openmandriva.py
mkosi/distributions/rocky.py

index 9486f9cbeda6d1eae00fff29afd171299519f811..9febabe1173fc76da11128dc7197df1107ba5cff 100644 (file)
@@ -1,24 +1,16 @@
 # SPDX-License-Identifier: LGPL-2.1+
 
-from pathlib import Path
-
 from mkosi.distributions.centos import CentosInstaller
 
 
 class AlmaInstaller(CentosInstaller):
     @staticmethod
-    def _gpg_locations(release: int) -> tuple[Path, str]:
-        return (
-            Path("/etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-$releasever"),
-            "https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux-$releasever",
-        )
+    def _gpgurl(release: int) -> str:
+        return "https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux-$releasever"
 
     @staticmethod
-    def _extras_gpg_locations(release: int) -> tuple[Path, str]:
-        return (
-            Path("/etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-$releasever"),
-            "https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux-$releasever",
-        )
+    def _extras_gpgurl(release: int) -> str:
+        return "https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux-$releasever"
 
     @classmethod
     def _mirror_directory(cls) -> str:
index f6173fe482bafaaa5ce86a813c0b57ef44fd4c4c..4a0a3a172bf3065401751d20de466961fcfeecc7 100644 (file)
@@ -110,25 +110,16 @@ class CentosInstaller(DistributionInstaller):
         invoke_dnf(state, "remove", packages)
 
     @staticmethod
-    def _gpg_locations(release: int) -> tuple[Path, str]:
-        return (
-            Path("/etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial"),
-            "https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official"
-        )
+    def _gpgurl(release: int) -> str:
+        return "https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official"
 
     @staticmethod
-    def _epel_gpg_locations() -> tuple[Path, str]:
-        return (
-            Path("/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever"),
-            "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-$releasever",
-        )
+    def _epel_gpgurl() -> str:
+        return "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-$releasever"
 
     @staticmethod
-    def _extras_gpg_locations(release: int) -> tuple[Path, str]:
-        return (
-            Path("/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras-SHA512"),
-            "https://www.centos.org/keys/RPM-GPG-KEY-CentOS-SIG-Extras"
-        )
+    def _extras_gpgurl(release: int) -> str:
+        return "https://www.centos.org/keys/RPM-GPG-KEY-CentOS-SIG-Extras"
 
     @classmethod
     def _mirror_directory(cls) -> str:
@@ -140,7 +131,7 @@ class CentosInstaller(DistributionInstaller):
 
     @classmethod
     def _epel_repos(cls, config: MkosiConfig) -> list[Repo]:
-        epel_gpgpath, epel_gpgurl = cls._epel_gpg_locations()
+        epel_gpgurl = cls._epel_gpgurl()
 
         if config.local_mirror:
             return []
@@ -153,8 +144,8 @@ class CentosInstaller(DistributionInstaller):
             epel_testing_url = "metalink=https://mirrors.fedoraproject.org/metalink?repo=testing-epel$releasever&arch=$basearch"
 
         return [
-            Repo("epel", epel_url, epel_gpgpath, epel_gpgurl, enabled=False),
-            Repo("epel-testing", epel_testing_url, epel_gpgpath, epel_gpgurl, enabled=False),
+            Repo("epel", epel_url, epel_gpgurl, enabled=False),
+            Repo("epel-testing", epel_testing_url, epel_gpgurl, enabled=False),
         ]
 
     @classmethod
@@ -162,7 +153,7 @@ class CentosInstaller(DistributionInstaller):
         # Repos for CentOS Linux 8, CentOS Stream 8 and CentOS variants
 
         directory = cls._mirror_directory()
-        gpgpath, gpgurl = cls._gpg_locations(release)
+        gpgurl = cls._gpgurl(release)
 
         if config.local_mirror:
             appstream_url = f"baseurl={config.local_mirror}"
@@ -188,15 +179,15 @@ class CentosInstaller(DistributionInstaller):
                 crb_url = None
                 powertools_url = f"mirrorlist={cls._mirror_repo_url('PowerTools')}"
 
-        repos = [Repo("appstream", appstream_url, gpgpath, gpgurl)]
+        repos = [Repo("appstream", appstream_url, gpgurl)]
         if baseos_url is not None:
-            repos += [Repo("baseos", baseos_url, gpgpath, gpgurl)]
+            repos += [Repo("baseos", baseos_url, gpgurl)]
         if extras_url is not None:
-            repos += [Repo("extras", extras_url, gpgpath, gpgurl)]
+            repos += [Repo("extras", extras_url, gpgurl)]
         if crb_url is not None:
-            repos += [Repo("crb", crb_url, gpgpath, gpgurl)]
+            repos += [Repo("crb", crb_url, gpgurl)]
         if powertools_url is not None:
-            repos += [Repo("powertools", powertools_url, gpgpath, gpgurl)]
+            repos += [Repo("powertools", powertools_url, gpgurl)]
         repos += cls._epel_repos(config)
 
         return repos
@@ -205,8 +196,8 @@ class CentosInstaller(DistributionInstaller):
     def _stream_repos(cls, config: MkosiConfig, release: int) -> list[Repo]:
         # Repos for CentOS Stream 9 and later
 
-        gpgpath, gpgurl = cls._gpg_locations(release)
-        extras_gpgpath, extras_gpgurl = cls._extras_gpg_locations(release)
+        gpgurl = cls._gpgurl(release)
+        extras_gpgurl = cls._extras_gpgurl(release)
 
         if config.local_mirror:
             appstream_url = f"baseurl={config.local_mirror}"
@@ -222,13 +213,13 @@ class CentosInstaller(DistributionInstaller):
             extras_url = "metalink=https://mirrors.centos.org/metalink?repo=centos-extras-sig-extras-common-$stream&arch=$basearch&protocol=https,http"
             crb_url = "metalink=https://mirrors.centos.org/metalink?repo=centos-crb-$stream&arch=$basearch&protocol=https,http"
 
-        repos = [Repo("appstream", appstream_url, gpgpath, gpgurl)]
+        repos = [Repo("appstream", appstream_url, gpgurl)]
         if baseos_url is not None:
-            repos += [Repo("baseos", baseos_url, gpgpath, gpgurl)]
+            repos += [Repo("baseos", baseos_url, gpgurl)]
         if extras_url is not None:
-            repos += [Repo("extras", extras_url, extras_gpgpath, extras_gpgurl)]
+            repos += [Repo("extras", extras_url, extras_gpgurl)]
         if crb_url is not None:
-            repos += [Repo("crb", crb_url, gpgpath, gpgurl)]
+            repos += [Repo("crb", crb_url, gpgurl)]
         repos += cls._epel_repos(config)
 
         return repos
index ae248b7d15a26254bbf22139ea0cd7ec7eadbac1..522f9d757a6d4f833e090b26d0f53469685d02fe 100644 (file)
@@ -52,13 +52,12 @@ class FedoraInstaller(DistributionInstaller):
             # In other versions, the "fedora" repo is frozen at release, and "updates" provides any new packages.
             updates_url = None
 
-        gpgpath = Path(f"/etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-{releasever}-{state.config.architecture}")
         # See: https://fedoraproject.org/security/
         gpgurl = "https://fedoraproject.org/fedora.gpg"
 
-        repos = [Repo("fedora", release_url, gpgpath, gpgurl)]
+        repos = [Repo("fedora", release_url, gpgurl)]
         if updates_url is not None:
-            repos += [Repo("updates", updates_url, gpgpath, gpgurl)]
+            repos += [Repo("updates", updates_url, gpgurl)]
 
         setup_dnf(state, repos)
         invoke_dnf(state, "install", packages, apivfs=apivfs)
@@ -90,7 +89,6 @@ def url_exists(url: str) -> bool:
 class Repo(NamedTuple):
     id: str
     url: str
-    gpgpath: Path
     gpgurl: str
     enabled: bool = True
 
@@ -98,19 +96,13 @@ class Repo(NamedTuple):
 def setup_dnf(state: MkosiState, repos: Sequence[Repo] = ()) -> None:
     with state.workspace.joinpath("dnf.conf").open("w") as f:
         for repo in repos:
-
-            if repo.gpgpath.exists():
-                gpgkey = f"file://{repo.gpgpath}"
-            else:
-                gpgkey = repo.gpgurl
-
             f.write(
                 dedent(
                     f"""\
                     [{repo.id}]
                     name={repo.id}
                     {repo.url}
-                    gpgkey={gpgkey}
+                    gpgkey={repo.gpgurl}
                     gpgcheck=1
                     enabled={int(repo.enabled)}
                     """
index dd049812a7d1e6aa216afc11131e7e8be959fb19..c9e09b17fec0a1dc5c3f469eb79e959e1920bf4a 100644 (file)
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: LGPL-2.1+
 
 from collections.abc import Sequence
-from pathlib import Path
 
 from mkosi.distributions import DistributionInstaller
 from mkosi.distributions.fedora import Repo, invoke_dnf, setup_dnf
@@ -39,12 +38,11 @@ class MageiaInstaller(DistributionInstaller):
             else:
                 updates_url = f"mirrorlist={baseurl}&repo=updates"
 
-        gpgpath = Path("/etc/pki/rpm-gpg/RPM-GPG-KEY-Mageia")
         gpgurl = f"https://mirrors.kernel.org/mageia/distrib/{release}/{state.config.architecture}/media/core/release/media_info/pubkey"
 
-        repos = [Repo(f"mageia-{release}", release_url, gpgpath, gpgurl)]
+        repos = [Repo(f"mageia-{release}", release_url, gpgurl)]
         if updates_url is not None:
-            repos += [Repo(f"mageia-{release}-updates", updates_url, gpgpath, gpgurl)]
+            repos += [Repo(f"mageia-{release}-updates", updates_url, gpgurl)]
 
         setup_dnf(state, repos)
         invoke_dnf(state, "install", packages, apivfs=apivfs)
index 52e841f160c7a165081b640d781502e8624cb25f..6954af173143e285cbc10bcff66df8b1ccd7748a 100644 (file)
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: LGPL-2.1+
 
 from collections.abc import Sequence
-from pathlib import Path
 
 from mkosi.distributions import DistributionInstaller
 from mkosi.distributions.fedora import Repo, invoke_dnf, setup_dnf
@@ -40,12 +39,11 @@ class OpenmandrivaInstaller(DistributionInstaller):
             release_url = f"mirrorlist={baseurl}&release=release"
             updates_url = f"mirrorlist={baseurl}&release=updates"
 
-        gpgpath = Path("/etc/pki/rpm-gpg/RPM-GPG-KEY-OpenMandriva")
         gpgurl = "https://raw.githubusercontent.com/OpenMandrivaAssociation/openmandriva-repos/master/RPM-GPG-KEY-OpenMandriva"
 
-        repos = [Repo("openmandriva", release_url, gpgpath, gpgurl)]
+        repos = [Repo("openmandriva", release_url, gpgurl)]
         if updates_url is not None:
-            repos += [Repo("updates", updates_url, gpgpath, gpgurl)]
+            repos += [Repo("updates", updates_url, gpgurl)]
 
         setup_dnf(state, repos)
         invoke_dnf(state, "install", packages, apivfs=apivfs)
index c0242a80189914cb7e293240bb94652fdfe09d69..d480493d3eba020366349f5b9cfb729206c43457 100644 (file)
@@ -1,26 +1,18 @@
 # SPDX-License-Identifier: LGPL-2.1+
 
-from pathlib import Path
-
 from mkosi.distributions.centos import CentosInstaller
 
 
 class RockyInstaller(CentosInstaller):
     @staticmethod
-    def _gpg_locations(release: int) -> tuple[Path, str]:
+    def _gpgurl(release: int) -> str:
         keyname = "Rocky-$releasever" if release >= 9 else "rockyofficial"
-        return (
-             Path(f"/etc/pki/rpm-gpg/RPM-GPG-KEY-{keyname}"),
-             f"https://download.rockylinux.org/pub/rocky/RPM-GPG-KEY-{keyname}"
-        )
+        return f"https://download.rockylinux.org/pub/rocky/RPM-GPG-KEY-{keyname}"
 
     @staticmethod
-    def _extras_gpg_locations(release: int) -> tuple[Path, str]:
+    def _extras_gpgurl(release: int) -> str:
         keyname = "Rocky-$releasever" if release >= 9 else "rockyofficial"
-        return (
-             Path(f"/etc/pki/rpm-gpg/RPM-GPG-KEY-{keyname}"),
-             f"https://download.rockylinux.org/pub/rocky/RPM-GPG-KEY-{keyname}"
-        )
+        return f"https://download.rockylinux.org/pub/rocky/RPM-GPG-KEY-{keyname}"
 
     @classmethod
     def _mirror_directory(cls) -> str: