Given the following code: >>> import dnf >>> base = dnf.Base() >>> base.conf.substitutions['releasever'] = '26' >>> repo = dnf.repo.Repo('fedora', parent_conf=base.conf) >>> repo.metalink = 'https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=$basearch' >>> base.repos.add(repo) >>> repo.skip_if_unavailable = False >>> repo.enable() >>> repo.load() It fails with: Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 229, in _perform return super(_Handle, self).perform(result) File "/usr/lib64/python3.6/site-packages/librepo/__init__.py", line 1517, in perform _librepo.Handle.perform(self, result) librepo.LibrepoException: (15, 'Cannot prepare internal mirrorlist: file "repomd.xml" was not found in metalink', 'Bad mirrorlist or metalink file') During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 910, in load self._handle_load(handle) File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 657, in _handle_load return self._handle_load_core(handle) File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 670, in _handle_load_core result = handle._perform() File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 233, in _perform raise _DetailedLibrepoError(exc, source) dnf.repo._DetailedLibrepoError During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 922, in load raise dnf.exceptions.RepoError(msg) dnf.exceptions.RepoError: Failed to synchronize cache for repo 'fedora' I've realized the problem is in the matalink that is not substituted: >>> repo.metalink 'https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=$basearch' >>> repo.metalink = dnf.conf.parser.substitute(repo.metalink, base.conf.substitutions) >>> repo.metalink 'https://mirrors.fedoraproject.org/metalink?repo=fedora-26&arch=x86_64' Reading the documentation didn't give me any idea I have to do this manually. I believe this might be fixed with one of the following: 1) Make metalink (and possibly baseurl as well) a property and do the substitution on setting it. 2) Make .load() do the substitution. 3) Document the current behavior in [1] - say "When setting the matalink, no substitution will happen, you need to manually call dnf.conf.parser.substitute() if you want the substitution of variables like $releasever to happen." [1] http://dnf.readthedocs.io/en/latest/api_repos.html#dnf.repo.Repo.metalink Version-Release number of selected component (if applicable): dnf-2.5.0-2.fc26.noarch
IMO completely valid request.
I created a patch (https://github.com/rpm-software-management/dnf/pull/842) that provide requested functionality. Please if you will provide a feedback it will be nice.
dnf-2.6.3-1.fc26 dnf-plugins-extras-2.0.2-1.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-4813633f96
dnf-2.6.3-1.fc26, dnf-plugins-extras-2.0.2-1.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-4813633f96
dnf-2.6.3-1.fc26, dnf-plugins-extras-2.0.2-1.fc26 has been pushed to the Fedora 26 stable repository. If problems still persist, please make note of it in this bug report.