Bug 1457507 - [api] Explicitly set metalink is not substituted
Summary: [api] Explicitly set metalink is not substituted
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: 26
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jaroslav Mracek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-05-31 20:18 UTC by Miro Hrončok
Modified: 2017-08-09 16:00 UTC (History)
5 users (show)

Fixed In Version: dnf-2.6.3-1.fc26
Clone Of:
Environment:
Last Closed: 2017-08-09 16:00:19 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Miro Hrončok 2017-05-31 20:18:52 UTC
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

Comment 1 Igor Gnatenko 2017-06-07 09:41:00 UTC
IMO completely valid request.

Comment 2 Jaroslav Mracek 2017-06-14 17:32:07 UTC
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.

Comment 3 Fedora Update System 2017-08-07 12:51:26 UTC
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

Comment 4 Fedora Update System 2017-08-08 01:24:52 UTC
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

Comment 5 Fedora Update System 2017-08-09 16:00:19 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.