Blame SOURCES/BZ-1352585-detect-installed-provide.patch

5e9bef
commit ed2a41fe646a1dcfc4f216f8babf25f93fde40e3
5e9bef
Author: Michal Domonkos <mdomonko@redhat.com>
5e9bef
Date:   Fri Feb 3 18:24:37 2017 +0100
5e9bef
5e9bef
    Detect installed virtual provide in install(). BZ 1352585
5e9bef
    
5e9bef
    Normally, when the user tries to install something that's already
5e9bef
    installed, we exit gracefully with 0.  However, that's not the case if
5e9bef
    what we're looking for is a provide that, despite being installed, is
5e9bef
    not available in any of the enabled repos, in which case we error out.
5e9bef
    This commit makes sure we exit gracefully in that case too.
5e9bef
    
5e9bef
    The old code path for "yum install foo" looks like this:
5e9bef
    
5e9bef
    1) Look for foo in pkgSack
5e9bef
    2) If no success, look for a package in pkgSack providing foo
5e9bef
    3) If no success, look for foo in rpmdb
5e9bef
    4) If no success, error out with "No package foo available." and exit
5e9bef
       code 1
5e9bef
    
5e9bef
    What we're adding with this commit is the following in between 3 and 4:
5e9bef
    
5e9bef
    - If no success, look for a package in rpmdb providing foo
5e9bef
    
5e9bef
    Note that we only search for the provide in pkgSack if the kwarg
5e9bef
    'pattern' is set, so let's adhere to this with the newly added rpmdb
5e9bef
    search too.
5e9bef
5e9bef
diff --git a/yum/__init__.py b/yum/__init__.py
5e9bef
index 9780d96..451b2b8 100644
5e9bef
--- a/yum/__init__.py
5e9bef
+++ b/yum/__init__.py
5e9bef
@@ -4910,8 +4910,14 @@ much more problems).
5e9bef
             # Do we still want to return errors here?
5e9bef
             # We don't in the cases below, so I didn't here...
5e9bef
             if 'pattern' in kwargs:
5e9bef
-                pkgs = self.rpmdb.returnPackages(patterns=[kwargs['pattern']],
5e9bef
+                arg = kwargs['pattern']
5e9bef
+                pkgs = self.rpmdb.returnPackages(patterns=[arg],
5e9bef
                                                  ignore_case=False)
5e9bef
+                if not pkgs:
5e9bef
+                    self.verbose_logger.debug(
5e9bef
+                        _('Checking for installed virtual provide or file-provide for %s'),
5e9bef
+                        arg)
5e9bef
+                    pkgs = self.returnInstalledPackagesByDep(arg)
5e9bef
             if 'name' in kwargs:
5e9bef
                 pkgs = self.rpmdb.searchNevra(name=kwargs['name'])
5e9bef
             if 'pkgtup' in kwargs: