From: Daan De Meyer Date: Sun, 11 Jun 2023 18:24:10 +0000 (+0200) Subject: dnf: Write repos to /etc/yum.repos.d/.repo X-Git-Tag: v15~115^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85563edcfd641db881a7e2b9d6e0dbb8725a92a9;p=thirdparty%2Fmkosi.git dnf: Write repos to /etc/yum.repos.d/.repo Let's allow providing a config file for dnf without also overriding all the default repositories by writing the default repositories to a file in /etc/yum.repos.d/. --- diff --git a/mkosi/distributions/fedora.py b/mkosi/distributions/fedora.py index 5d8301c2d..4866b7a9a 100644 --- a/mkosi/distributions/fedora.py +++ b/mkosi/distributions/fedora.py @@ -123,28 +123,30 @@ class Repo(NamedTuple): def setup_dnf(state: MkosiState, repos: Sequence[Repo]) -> None: config = state.pkgmngr / "etc/dnf/dnf.conf" - if config.exists(): - return - - config.parent.mkdir(exist_ok=True, parents=True) - - with config.open("w") as f: - for repo in repos: - f.write( - dedent( - f"""\ - [{repo.id}] - name={repo.id} - {repo.url} - gpgcheck=1 - enabled={int(repo.enabled)} - """ + if not config.exists(): + config.parent.mkdir(exist_ok=True, parents=True) + config.touch() + + repofile = state.pkgmngr / f"etc/yum.repos.d/{state.config.distribution}.repo" + if not repofile.exists(): + repofile.parent.mkdir(exist_ok=True, parents=True) + with repofile.open("w") as f: + for repo in repos: + f.write( + dedent( + f"""\ + [{repo.id}] + name={repo.id} + {repo.url} + gpgcheck=1 + enabled={int(repo.enabled)} + """ + ) ) - ) - for i, url in enumerate(repo.gpgurls): - f.write("gpgkey=" if i == 0 else len("gpgkey=") * " ") - f.write(f"{url}\n") + for i, url in enumerate(repo.gpgurls): + f.write("gpgkey=" if i == 0 else len("gpgkey=") * " ") + f.write(f"{url}\n") def invoke_dnf(