Blob Blame Raw
From 41b908adfc9f58a881aab546103e5f03322df106 Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <ignatenko@redhat.com>
Date: Thu, 23 Feb 2017 16:46:38 +0100
Subject: [PATCH 1/5] builddep: install requirements by provides
 (RhBug:1332830)

This way we will also get support for rich dependencies for free.

Reported-by: Neal Gompa <ngompa13@gmail.com>
References: https://bugzilla.redhat.com/show_bug.cgi?id=1332830
Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>

Closes: #204
Approved by: jmracek

(cherry picked from commit 6b48454b10f9be3c26c86d451431066737071175)
---
 plugins/builddep.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/plugins/builddep.py b/plugins/builddep.py
index 7abd7b0..03a6efc 100644
--- a/plugins/builddep.py
+++ b/plugins/builddep.py
@@ -156,13 +156,15 @@ class BuildDepCommand(dnf.cli.Command):
         return rpm_dep.DNEVR()[2:]
 
     def _install(self, reldep_str):
-        try:
-            self.base.install(reldep_str)
-        except dnf.exceptions.MarkingError:
+        sltr = dnf.selector.Selector(self.base.sack)
+        sltr = sltr.set(provides=reldep_str)
+        if sltr.matches():
+            self.base._goal.install(select=sltr)
+            return True
+        else:
             msg = _("No matching package to install: '%s'")
             logger.warning(msg, reldep_str)
             return False
-        return True
 
     def _src_deps(self, src_fn):
         fd = os.open(src_fn, os.O_RDONLY)
-- 
2.12.1