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