return cast(str, namespace.distribution.default_release())
-def config_default_mirror(namespace: argparse.Namespace) -> Optional[str]:
- if namespace.distribution == Distribution.debian:
- return "http://deb.debian.org/debian"
- elif namespace.distribution == Distribution.ubuntu:
- if namespace.architecture in (Architecture.x86, Architecture.x86_64):
- return "http://archive.ubuntu.com/ubuntu"
- else:
- return "http://ports.ubuntu.com"
- elif namespace.distribution == Distribution.arch:
- if namespace.architecture == Architecture.arm64:
- return "http://mirror.archlinuxarm.org"
- else:
- return "https://geo.mirror.pkgbuild.com"
- elif namespace.distribution == Distribution.opensuse:
- return "http://download.opensuse.org"
- elif namespace.distribution == Distribution.fedora and namespace.release == "eln":
- return "https://odcs.fedoraproject.org/composes/production/latest-Fedora-ELN/compose"
- elif namespace.distribution == Distribution.gentoo:
- return "https://distfiles.gentoo.org"
- elif namespace.distribution == Distribution.rhel_ubi:
- return "https://cdn-ubi.redhat.com/content/public/ubi/dist/"
-
- return None
-
-
def config_default_source_date_epoch(namespace: argparse.Namespace) -> Optional[int]:
for env in namespace.environment:
if env.startswith("SOURCE_DATE_EPOCH="):
dest="mirror",
short="-m",
section="Distribution",
- default_factory=config_default_mirror,
- default_factory_depends=("distribution", "release", "architecture"),
help="Distribution mirror to use",
),
MkosiConfigSetting(
@staticmethod
def repositories(state: MkosiState, local: bool = True) -> list[str]:
- assert state.config.mirror
-
archives = ("deb", "deb-src")
components = ' '.join(("main", *state.config.repositories))
if state.config.local_mirror and local:
return [f"deb [trusted=yes] {state.config.local_mirror} {state.config.release} {components}"]
+ mirror = state.config.mirror or "http://deb.debian.org/debian"
+
repos = [
- f"{archive} {state.config.mirror} {state.config.release} {components}"
+ f"{archive} {mirror} {state.config.release} {components}"
for archive in archives
]
return repos
repos += [
- f"{archive} {state.config.mirror} {state.config.release}-updates {components}"
+ f"{archive} {mirror} {state.config.release}-updates {components}"
for archive in archives
]
if state.config.local_mirror:
repos += [Repo("fedora", f"baseurl={state.config.mirror}", gpgurls)]
elif state.config.release == "eln":
- assert state.config.mirror
+ mirror = state.config.mirror or "https://odcs.fedoraproject.org/composes/production/latest-Fedora-ELN/compose"
for repo in ("Appstream", "BaseOS", "Extras", "CRB"):
- url = f"baseurl={urllib.parse.urljoin(state.config.mirror, repo)}"
+ url = f"baseurl={urllib.parse.urljoin(mirror, repo)}"
repos += [
Repo(repo.lower(), f"{url}/$basearch/os", gpgurls),
Repo(repo.lower(), f"{url}/$basearch/debug/tree", gpgurls, enabled=False),
def install(cls, state: MkosiState) -> None:
arch = state.config.distribution.architecture(state.config.architecture)
- assert state.config.mirror
+ mirror = state.config.mirror or "https://distfiles.gentoo.org"
# http://distfiles.gentoo.org/releases/amd64/autobuilds/latest-stage3.txt
stage3tsf_path_url = urllib.parse.urljoin(
- state.config.mirror.partition(" ")[0],
+ mirror.partition(" ")[0],
f"releases/{arch}/autobuilds/latest-stage3.txt",
)
else:
die("profile names changed upstream?")
- stage3_url = urllib.parse.urljoin(state.config.mirror, f"releases/{arch}/autobuilds/{stage3_latest}")
+ stage3_url = urllib.parse.urljoin(mirror, f"releases/{arch}/autobuilds/{stage3_latest}")
stage3_tar = state.cache_dir / "stage3.tar"
stage3 = state.cache_dir / "stage3"
if release == "leap":
release = "stable"
+ mirror = state.config.mirror or "http://download.opensuse.org"
+
# If the release looks like a timestamp, it's Tumbleweed. 13.x is legacy
# (14.x won't ever appear). For anything else, let's default to Leap.
if state.config.local_mirror:
release_url = f"{state.config.local_mirror}"
updates_url = None
if release.isdigit() or release == "tumbleweed":
- release_url = f"{state.config.mirror}/tumbleweed/repo/oss/"
- updates_url = f"{state.config.mirror}/update/tumbleweed/"
+ release_url = f"{mirror}/tumbleweed/repo/oss/"
+ updates_url = f"{mirror}/update/tumbleweed/"
elif release in ("current", "stable"):
- release_url = f"{state.config.mirror}/distribution/openSUSE-{release}/repo/oss/"
- updates_url = f"{state.config.mirror}/update/openSUSE-{release}/"
+ release_url = f"{mirror}/distribution/openSUSE-{release}/repo/oss/"
+ updates_url = f"{mirror}/update/openSUSE-{release}/"
else:
- release_url = f"{state.config.mirror}/distribution/leap/{release}/repo/oss/"
- updates_url = f"{state.config.mirror}/update/leap/{release}/oss/"
+ release_url = f"{mirror}/distribution/leap/{release}/repo/oss/"
+ updates_url = f"{mirror}/update/leap/{release}/oss/"
zypper = shutil.which("zypper")
if state.config.local_mirror:
yield Repo(repo, f"baseurl={state.config.local_mirror}", cls.gpgurls(state))
else:
- assert state.config.mirror
+ mirror = state.config.mirror or "https://cdn-ubi.redhat.com/content/public/ubi/dist/"
v = state.config.release
yield Repo(
f"ubi-{v}-{repo}-rpms",
- f"baseurl={centos.join_mirror(state.config.mirror, f'ubi{v}/{v}/$basearch/{repo}/os')}",
+ f"baseurl={centos.join_mirror(mirror, f'ubi{v}/{v}/$basearch/{repo}/os')}",
cls.gpgurls(state),
)
yield Repo(
f"ubi-{v}-{repo}-debug-rpms",
- f"baseurl={centos.join_mirror(state.config.mirror, f'ubi{v}/{v}/$basearch/{repo}/debug')}",
+ f"baseurl={centos.join_mirror(mirror, f'ubi{v}/{v}/$basearch/{repo}/debug')}",
cls.gpgurls(state),
enabled=False,
)
yield Repo(
f"ubi-{v}-{repo}-source",
- f"baseurl={centos.join_mirror(state.config.mirror, f'ubi{v}/{v}/$basearch/{repo}/source')}",
+ f"baseurl={centos.join_mirror(mirror, f'ubi{v}/{v}/$basearch/{repo}/source')}",
cls.gpgurls(state),
enabled=False,
)
if repo == "codeready-builder":
yield Repo(
f"ubi-{v}-{repo}",
- f"baseurl={centos.join_mirror(state.config.mirror, f'ubi{v}/{v}/$basearch/{repo}/os')}",
+ f"baseurl={centos.join_mirror(mirror, f'ubi{v}/{v}/$basearch/{repo}/os')}",
cls.gpgurls(state),
enabled=False,
)
archives = ("deb", "deb-src")
+ if state.config.architecture in (Architecture.x86, Architecture.x86_64):
+ mirror = state.config.mirror or "http://archive.ubuntu.com/ubuntu"
+ else:
+ mirror = state.config.mirror or "http://ports.ubuntu.com"
+
# From kinetic onwards, the usr-is-merged package is available in universe and is required by
# mkosi to set up a proper usr-merged system so we add the universe repository unconditionally.
components = ["main"] + (["universe"] if state.config.release not in ("focal", "jammy") else [])
components = ' '.join((*components, *state.config.repositories))
repos = [
- f"{archive} {state.config.mirror} {state.config.release} {components}"
+ f"{archive} {mirror} {state.config.release} {components}"
for archive in archives
]
repos += [
- f"{archive} {state.config.mirror} {state.config.release}-updates {components}"
+ f"{archive} {mirror} {state.config.release}-updates {components}"
for archive in archives
]
# Security updates repos are never mirrored. But !x86 are on the ports server.
if state.config.architecture in [Architecture.x86, Architecture.x86_64]:
- url = "http://security.ubuntu.com/ubuntu/"
+ mirror = "http://security.ubuntu.com/ubuntu/"
else:
- url = "http://ports.ubuntu.com/"
+ mirror = "http://ports.ubuntu.com/"
repos += [
- f"{archive} {url} {state.config.release}-security {components}"
+ f"{archive} {mirror} {state.config.release}-security {components}"
for archive in archives
]
def setup_pacman(state: MkosiState) -> None:
- assert state.config.mirror
-
if state.config.local_mirror:
server = f"Server = {state.config.local_mirror}"
else:
if state.config.architecture == Architecture.arm64:
- server = f"Server = {state.config.mirror}/$arch/$repo"
+ server = f"Server = {state.config.mirror or 'http://mirror.archlinuxarm.org'}/$arch/$repo"
else:
- server = f"Server = {state.config.mirror}/$repo/os/$arch"
+ server = f"Server = {state.config.mirror or 'https://geo.mirror.pkgbuild.com'}/$repo/os/$arch"
if state.config.repository_key_check:
sig_level = "Required DatabaseOptional"
`Mirror=`, `--mirror=`, `-m`
: The mirror to use for downloading the distribution packages. Expects
- a mirror URL as argument.
+ a mirror URL as argument. If not provided, the default mirror for the
+ distribution is used.
+
+: The default mirrors for each distribution are as follows (unless
+ specified, the same mirror is used for all architectures):
+
+ | | x86-64 | aarch64 |
+ |----------------|--------------------------------------------------------------------|
+ | `debian` | http://deb.debian.org/debian | |
+ | `arch` | https://geo.mirror.pkgbuild.com | http://mirror.archlinuxarm.org |
+ | `opensuse` | http://download.opensuse.org | |
+ | `ubuntu` | http://archive.ubuntu.com | http://ports.ubuntu.com |
+ | `centos` | https://mirrors.centos.org | |
+ | `rocky` | https://mirrors.rockylinux.org | |
+ | `alma` | https://mirrors.almalinux.org | |
+ | `fedora` | https://mirrors.fedoraproject.org | |
+ | `rhel-ubi` | https://cdn-ubi.redhat.com | |
+ | `mageia` | https://www.mageia.org | |
+ | `openmandriva` | http://mirrors.openmandriva.org | |
`LocalMirror=`, `--local-mirror=`