]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Fix mirror paths for centos/fedora family of distributions.
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 29 Jun 2024 09:16:47 +0000 (11:16 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sat, 29 Jun 2024 11:13:21 +0000 (13:13 +0200)
We assumed that fedora would always be in the fedora subdirectory
of the mirror and that centos would always be in the centos-stream
subdirectory of the mirror but this is not guaranteed to be true
(see https://pagure.io/centos-infra/issue/1430).

Let's fix this by not always appending centos-stream/ or fedora/ to
the given mirror so the user can determine whether to include this
or not.

This is a breaking change but making sure all mirrors can be used
regardless of layout seems more important in this case.

For EPEL we do make a bigger assumption on the mirror layout since
we're forced to as we don't have a mechanism to specify more than one
mirror. We also allow users to override the epel mirror via an
environment variable.

mkosi/distributions/alma.py
mkosi/distributions/centos.py
mkosi/distributions/fedora.py
mkosi/distributions/rocky.py
mkosi/distributions/ubuntu.py
mkosi/resources/mkosi.md

index dcc4064b06128b60c95d6e72b8ed9e8a75cf1ea5..d2577d084063a00483d803648492055a24119416 100644 (file)
@@ -22,7 +22,7 @@ class Installer(centos.Installer):
     @classmethod
     def repository_variants(cls, context: Context, repo: str) -> list[RpmRepository]:
         if context.config.mirror:
-            url = f"baseurl={join_mirror(context.config.mirror, f'almalinux/$releasever/{repo}/$basearch/os')}"
+            url = f"baseurl={join_mirror(context.config.mirror, f'$releasever/{repo}/$basearch/os')}"
         else:
             url = f"mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/{repo.lower()}"
 
index e3459e8a65db1784c9061c39db68d18f7abeecc8..d8497102e596bee5c7424e535ae0f74759deec28 100644 (file)
@@ -117,12 +117,12 @@ class Installer(DistributionInstaller):
             if repo == "extras":
                 yield RpmRepository(
                     repo.lower(),
-                    f"baseurl={join_mirror(mirror, f'centos-stream/SIGs/$stream/{repo}/$basearch/extras-common')}",
+                    f"baseurl={join_mirror(mirror, f'SIGs/$stream/{repo}/$basearch/extras-common')}",
                     cls.gpgurls(context),
                 )
                 yield RpmRepository(
                     f"{repo.lower()}-source",
-                    f"baseurl={join_mirror(mirror, f'centos-stream/SIGs/$stream/{repo}/source/extras-common')}",
+                    f"baseurl={join_mirror(mirror, f'SIGs/$stream/{repo}/source/extras-common')}",
                     cls.gpgurls(context),
                     enabled=False,
                 )
@@ -130,18 +130,18 @@ class Installer(DistributionInstaller):
             else:
                 yield RpmRepository(
                     repo.lower(),
-                    f"baseurl={join_mirror(mirror, f'centos-stream/$stream/{repo}/$basearch/os')}",
+                    f"baseurl={join_mirror(mirror, f'$stream/{repo}/$basearch/os')}",
                     cls.gpgurls(context),
                 )
                 yield RpmRepository(
                     f"{repo.lower()}-debuginfo",
-                    f"baseurl={join_mirror(mirror, f'centos-stream/$stream/{repo}/$basearch/debug/tree')}",
+                    f"baseurl={join_mirror(mirror, f'$stream/{repo}/$basearch/debug/tree')}",
                     cls.gpgurls(context),
                     enabled=False,
                 )
                 yield RpmRepository(
                     f"{repo.lower()}-source",
-                    f"baseurl={join_mirror(mirror, f'centos-stream/$stream/{repo}/source/tree')}",
+                    f"baseurl={join_mirror(mirror, f'$stream/{repo}/source/tree')}",
                     cls.gpgurls(context),
                     enabled=False,
                 )
@@ -213,21 +213,25 @@ class Installer(DistributionInstaller):
                 ("epel-testing", "epel/testing"),
                 ("epel-next-testing", "epel/testing/next")
             ):
+                # For EPEL we make the assumption that epel is mirrored in the parent directory of the mirror URL and
+                # path we were given. Since this doesn't work for all scenarios, we also allow overriding the mirror
+                # via ane environment variable.
+                url = context.config.environment.get("EPEL_MIRROR", join_mirror(mirror, "../fedora"))
                 yield RpmRepository(
                     repo,
-                    f"baseurl={join_mirror(mirror, f'fedora/{dir}/$releasever/Everything/$basearch')}",
+                    f"baseurl={url}/{dir}/$releasever/Everything/$basearch",
                     gpgurls,
                     enabled=False,
                 )
                 yield RpmRepository(
                     f"{repo}-debuginfo",
-                    f"baseurl={join_mirror(mirror, f'fedora/{dir}/$releasever/Everything/$basearch/debug')}",
+                    f"baseurl={url}/{dir}/$releasever/Everything/$basearch/debug",
                     gpgurls,
                     enabled=False,
                 )
                 yield RpmRepository(
                     f"{repo}-source",
-                    f"baseurl={join_mirror(mirror, f'fedora/{dir}/$releasever/Everything/source/tree')}",
+                    f"baseurl={url}/{dir}/$releasever/Everything/source/tree",
                     gpgurls,
                     enabled=False,
                 )
@@ -305,21 +309,21 @@ class Installer(DistributionInstaller):
                 if mirror := context.config.mirror:
                     yield RpmRepository(
                         f"{sig}-{c}",
-                        f"baseurl={join_mirror(mirror, f'centos-stream/SIGs/$stream/{sig}/$basearch/{c}')}",
+                        f"baseurl={join_mirror(mirror, f'SIGs/$stream/{sig}/$basearch/{c}')}",
                         gpgurls,
                         enabled=False,
                         priority=CENTOS_SIG_REPO_PRIORITY,
                     )
                     yield RpmRepository(
                         f"{sig}-{c}-debuginfo",
-                        f"baseurl={join_mirror(mirror, f'centos-stream/SIGs/$stream/{sig}/$basearch/{c}/debug')}",
+                        f"baseurl={join_mirror(mirror, f'SIGs/$stream/{sig}/$basearch/{c}/debug')}",
                         gpgurls,
                         enabled=False,
                         priority=CENTOS_SIG_REPO_PRIORITY,
                     )
                     yield RpmRepository(
                         f"{sig}-{c}-source",
-                        f"baseurl={join_mirror(mirror, f'centos-stream/SIGs/$stream/{sig}/source/{c}')}",
+                        f"baseurl={join_mirror(mirror, f'SIGs/$stream/{sig}/source/{c}')}",
                         gpgurls,
                         enabled=False,
                         priority=CENTOS_SIG_REPO_PRIORITY,
index 1cd10787394cdc33cf97b74b87c62925e2a354c0..fd391be241475f61ba2ee869707e95b946a40af1 100644 (file)
@@ -113,18 +113,18 @@ class Installer(DistributionInstaller):
                 yield RpmRepository(repo.lower(), f"{url}/source/tree", gpgurls, enabled=False)
         elif (m := context.config.mirror):
             directory = "development" if context.config.release == "rawhide" else "releases"
-            url = f"baseurl={join_mirror(m, f'fedora/linux/{directory}/$releasever/Everything')}"
+            url = f"baseurl={join_mirror(m, f'linux/{directory}/$releasever/Everything')}"
             yield RpmRepository("fedora", f"{url}/$basearch/os", gpgurls)
             yield RpmRepository("fedora-debuginfo", f"{url}/$basearch/debug/tree", gpgurls, enabled=False)
             yield RpmRepository("fedora-source", f"{url}/source/tree", gpgurls, enabled=False)
 
             if context.config.release != "rawhide":
-                url = f"baseurl={join_mirror(m, 'fedora/linux/updates/$releasever/Everything')}"
+                url = f"baseurl={join_mirror(m, 'linux/updates/$releasever/Everything')}"
                 yield RpmRepository("updates", f"{url}/$basearch", gpgurls)
                 yield RpmRepository("updates-debuginfo", f"{url}/$basearch/debug", gpgurls, enabled=False)
                 yield RpmRepository("updates-source", f"{url}/source/tree", gpgurls, enabled=False)
 
-                url = f"baseurl={join_mirror(m, 'fedora/linux/updates/testing/$releasever/Everything')}"
+                url = f"baseurl={join_mirror(m, 'linux/updates/testing/$releasever/Everything')}"
                 yield RpmRepository("updates-testing", f"{url}/$basearch", gpgurls, enabled=False)
                 yield RpmRepository("updates-testing-debuginfo", f"{url}/$basearch/debug", gpgurls, enabled=False)
                 yield RpmRepository("updates-testing-source", f"{url}/source/tree", gpgurls, enabled=False)
index a02fb13bea91b622b6c2126c4d99181e3afe614a..7e33d12429bacf269d29a2e9e8a9104ec7caa277 100644 (file)
@@ -22,7 +22,7 @@ class Installer(centos.Installer):
     @classmethod
     def repository_variants(cls, context: Context, repo: str) -> list[RpmRepository]:
         if context.config.mirror:
-            url = f"baseurl={join_mirror(context.config.mirror, f'rocky/$releasever/{repo}/$basearch/os')}"
+            url = f"baseurl={join_mirror(context.config.mirror, f'$releasever/{repo}/$basearch/os')}"
         else:
             url = f"mirrorlist=https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo={repo}-$releasever"
 
index 786d7c0a21631c5b806995a59264586bfe3ec69c..5d9516f586f5dab3c00635c950d5963d494c5237 100644 (file)
@@ -67,9 +67,9 @@ class Installer(debian.Installer):
 
         # Security updates repos are never mirrored. But !x86 are on the ports server.
         if context.config.architecture.is_x86_variant():
-            mirror = "http://security.ubuntu.com/ubuntu/"
+            mirror = "http://security.ubuntu.com/ubuntu"
         else:
-            mirror = "http://ports.ubuntu.com/"
+            mirror = "http://ports.ubuntu.com"
 
         yield AptRepository(
             types=types,
index 19f65893a631cd650b5d14eaece724d38ee49c46..c2bf5a4644355d442781c2fd85627a538f868105 100644 (file)
@@ -2445,6 +2445,13 @@ repository.
 * `$MKOSI_DNF` can be used to override the executable used as `dnf`.
   This is particularly useful to select between `dnf` and `dnf5`.
 
+* `$EPEL_MIRROR` can be used to override the default mirror location
+  used for the epel repositories when `Mirror=` is used. By default
+  mkosi looks for the epel repositories in the `fedora` subdirectory of
+  the parent directory of the mirror specified in `Mirror=`. For example
+  if the mirror is set to `https://mirror.net/centos-stream` mkosi will
+  look for the epel repositories in `https://mirror.net/fedora/epel`.
+
 # EXAMPLES
 
 Create and run a raw *GPT* image with *ext4*, as `image.raw`: