Bug 1427132
Summary: | create an API for initializing repos | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Daniel Mach <dmach> |
Component: | dnf | Assignee: | Jaroslav Mracek <jmracek> |
Status: | CLOSED ERRATA | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | 26 | CC: | dmach, jmracek, packaging-team-maint, rpm-software-management, vmukhame |
Target Milestone: | --- | Keywords: | Reopened, Triaged |
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | dnf-1.1.10-6.fc25 dnf-2.2.0-1.fc26 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2017-04-01 17:21:36 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Daniel Mach
2017-02-27 12:28:26 UTC
You mean something like this: diff --git a/dnf/cli/cli.py b/dnf/cli/cli.py index d561274a..9a091843 100644 --- a/dnf/cli/cli.py +++ b/dnf/cli/cli.py @@ -673,13 +673,7 @@ class Cli(object): self.base.read_all_repos(opts) if opts.repofrompath: for label, path in opts.repofrompath.items(): - if '://' not in path: - path = 'file://{}'.format(os.path.abspath(path)) - repofp = dnf.repo.Repo(label, self.base.conf) - try: - repofp.baseurl = path - except ValueError as e: - raise dnf.exceptions.RepoError(e) + repofp = dnf.repo.from_path(label, path, self.base.conf) self.base.repos.add(repofp) logger.info(_("Added %s repo from %s"), label, path) diff --git a/dnf/repo.py b/dnf/repo.py index 338db6b5..10366d02 100644 --- a/dnf/repo.py +++ b/dnf/repo.py @@ -483,6 +483,18 @@ class Repo(dnf.conf.RepoConf): # :api return self._repofile + @classmethod + def from_path(cls, name, path, *args, **kwargs): + # :api + if '://' not in path: + path = 'file://{}'.format(os.path.abspath(path)) + repofp = cls(name, *args, **kwargs) + try: + repofp.baseurl = path + except ValueError as e: + raise dnf.exceptions.RepoError(e) + return repofp + @repofile.setter def repofile(self, value): self._repofile = value ? This bug appears to have been reported against 'rawhide' during the Fedora 26 development cycle. Changing version to '26'. I will take care of that. (In reply to Jaroslav Mracek from comment #3) > I will take care of that. There's already patch waiting for reporter. I have created patch that should support requested feature: https://github.com/rpm-software-management/dnf/pull/752 The patch in pull request 752 looks good to me. dnf-1.1.10-6.fc25 has been submitted as an update to Fedora 25. https://bodhi.fedoraproject.org/updates/FEDORA-2017-b7cfb5cf10 dnf-1.1.10-6.fc25 has been pushed to the Fedora 25 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-b7cfb5cf10 dnf-1.1.10-6.fc25 has been pushed to the Fedora 25 stable repository. If problems still persist, please make note of it in this bug report. dnf-2.1.1-1.fc26 libdnf-0.8.0-1.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-65586fa42b dnf-2.1.1-1.1.fc26, libdnf-0.8.0-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-65586fa42b dnf-2.2.0-1.fc26, libdnf-0.8.0-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-65586fa42b dnf-2.2.0-1.fc26, libdnf-0.8.0-1.fc26 has been pushed to the Fedora 26 stable repository. If problems still persist, please make note of it in this bug report. |