Blame SOURCES/BZ-1274211-skip-missing-names.patch

d2a170
commit d4ff5427368977f74a8ba7b0be51752023592025
d2a170
Author: Valentina Mukhamedzhanova <vmukhame@redhat.com>
d2a170
Date:   Wed Mar 16 16:22:34 2016 +0100
d2a170
d2a170
    Add config options skip_missing_names_on_install and skip_missing_names_on_update. BZ#1274211
d2a170
d2a170
diff --git a/cli.py b/cli.py
d2a170
index fd6e715..54a2e81 100755
d2a170
--- a/cli.py
d2a170
+++ b/cli.py
d2a170
@@ -982,6 +982,8 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
d2a170
                     except:
d2a170
                         self.verbose_logger.warning(_('Bad %s argument %s.'),
d2a170
                                                     basecmd, arg)
d2a170
+                        if not self.conf.skip_missing_names_on_install:
d2a170
+                            return 1, [_('Not tolerating missing names on install, stopping.')]
d2a170
                         continue
d2a170
                     txmbrs = self.install(name=n, arch=a)
d2a170
                 elif basecmd == 'install-nevra':
d2a170
@@ -992,6 +994,8 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
d2a170
                     except:
d2a170
                         self.verbose_logger.warning(_('Bad %s argument %s.'),
d2a170
                                                     basecmd, arg)
d2a170
+                        if not self.conf.skip_missing_names_on_install:
d2a170
+                            return 1, [_('Not tolerating missing names on install, stopping.')]
d2a170
                         continue
d2a170
                     txmbrs = self.install(name=n,
d2a170
                                           epoch=e, version=v, release=r, arch=a)
d2a170
@@ -1000,12 +1004,16 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
d2a170
                     txmbrs = self.install(pattern=arg)
d2a170
             except yum.Errors.GroupInstallError, e:
d2a170
                 self.verbose_logger.log(yum.logginglevels.INFO_2, e)
d2a170
+                if not self.conf.skip_missing_names_on_install:
d2a170
+                    return 1, [_('Not tolerating missing names on install, stopping.')]
d2a170
             except yum.Errors.InstallError:
d2a170
                 self.verbose_logger.log(yum.logginglevels.INFO_2,
d2a170
                                         _('No package %s%s%s available.'),
d2a170
                                         self.term.MODE['bold'], arg,
d2a170
                                         self.term.MODE['normal'])
d2a170
                 self._maybeYouMeant(arg)
d2a170
+                if not self.conf.skip_missing_names_on_install:
d2a170
+                    return 1, [_('Not tolerating missing names on install, stopping.')]
d2a170
             else:
d2a170
                 done = True
d2a170
                 self._install_upgraded_requires(txmbrs)
d2a170
@@ -1057,10 +1065,19 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
d2a170
                     self._install_upgraded_requires(txmbrs)
d2a170
                     continue
d2a170
 
d2a170
-                txmbrs = self.update(pattern=item, update_to=update_to)
d2a170
+                try:
d2a170
+                    txmbrs = self.update(pattern=item, update_to=update_to)
d2a170
+                except (yum.Errors.UpdateMissingNameError, yum.Errors.GroupInstallError):
d2a170
+                    self._checkMaybeYouMeant(item)
d2a170
+                    return 1, [_('Not tolerating missing names on update, stopping.')]
d2a170
+
d2a170
                 self._install_upgraded_requires(txmbrs)
d2a170
                 if not txmbrs:
d2a170
                     self._checkMaybeYouMeant(item)
d2a170
+                    if not self.conf.skip_missing_names_on_update:
d2a170
+                        matches = self.doPackageLists(pkgnarrow='all', patterns=[item], ignore_case=False)
d2a170
+                        if matches.available and not matches.installed:
d2a170
+                            return 1, [_('Not tolerating missing names on update, stopping.')]
d2a170
 
d2a170
         if len(self.tsInfo) > oldcount:
d2a170
             change = len(self.tsInfo) - oldcount
d2a170
diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
d2a170
index 116829a..f823c6f 100644
d2a170
--- a/docs/yum.conf.5
d2a170
+++ b/docs/yum.conf.5
d2a170
@@ -945,6 +945,17 @@ Either `0' or `1'. Set this to `0' to disable the checking for writability on
d2a170
 /usr in the installroot (when going into the depsolving stage). Default is `1'
d2a170
 (perform the check).
d2a170
 
d2a170
+.IP
d2a170
+\fBskip_missing_names_on_install\fR
d2a170
+If set to False, 'yum install' will fail if it can't find any of the provided
d2a170
+names (package, group, rpm file). Boolean (1, 0, True, False, yes, no). Defaults to True.
d2a170
+
d2a170
+.IP
d2a170
+\fBskip_missing_names_on_update\fR
d2a170
+If set to False, 'yum update' will fail if it can't find any of the provided
d2a170
+names (package, group, rpm file). It will also fail if the provided name is a package
d2a170
+which is available, but not installed. Boolean (1, 0, True, False, yes, no). Defaults to True.
d2a170
+
d2a170
 .SH "[repository] OPTIONS"
d2a170
 .LP 
d2a170
 The repository section(s) take the following form:
d2a170
diff --git a/test/testbase.py b/test/testbase.py
d2a170
index 6d240b0..b303356 100644
d2a170
--- a/test/testbase.py
d2a170
+++ b/test/testbase.py
d2a170
@@ -46,6 +46,8 @@ class FakeConf(object):
d2a170
         self.tsflags = []
d2a170
         self.installonly_limit = 0
d2a170
         self.skip_broken = False
d2a170
+        self.skip_missing_names_on_install = True
d2a170
+        self.skip_missing_names_on_update = True
d2a170
         self.disable_excludes = []
d2a170
         self.multilib_policy = 'best'
d2a170
         self.persistdir = '/should-not-exist-bad-test!'
d2a170
diff --git a/yum/Errors.py b/yum/Errors.py
d2a170
index f69c061..3f87b0b 100644
d2a170
--- a/yum/Errors.py
d2a170
+++ b/yum/Errors.py
d2a170
@@ -117,6 +117,9 @@ class GroupInstallError(InstallError):
d2a170
 
d2a170
 class UpdateError(YumBaseError):
d2a170
     pass
d2a170
+
d2a170
+class UpdateMissingNameError(UpdateError):
d2a170
+    pass
d2a170
     
d2a170
 class RemoveError(YumBaseError):
d2a170
     pass
d2a170
diff --git a/yum/__init__.py b/yum/__init__.py
d2a170
index 1f6ce16..acaa973 100644
d2a170
--- a/yum/__init__.py
d2a170
+++ b/yum/__init__.py
d2a170
@@ -4581,7 +4581,10 @@ much more problems).
d2a170
             return self._at_groupinstall(pattern, upgrade=True)
d2a170
         except Errors.GroupInstallError, e:
d2a170
             self.logger.warning(_('Warning: %s'), e)
d2a170
-            return []
d2a170
+            if self.conf.skip_missing_names_on_update:
d2a170
+                return []
d2a170
+            else:
d2a170
+                raise
d2a170
 
d2a170
     def _at_groupremove(self, pattern):
d2a170
         " Do groupremove via. leading @ on the cmd line, for remove."
d2a170
@@ -5185,6 +5188,8 @@ much more problems).
d2a170
 
d2a170
             if not availpkgs and not instpkgs:
d2a170
                 self.logger.critical(_('No Match for argument: %s') % to_unicode(arg))
d2a170
+                if not self.conf.skip_missing_names_on_update:
d2a170
+                    raise Errors.UpdateMissingNameError, _('Not tolerating missing names on update, stopping.')
d2a170
         
d2a170
         else: # we have kwargs, sort them out.
d2a170
             nevra_dict = self._nevra_kwarg_parse(kwargs)
d2a170
diff --git a/yum/config.py b/yum/config.py
d2a170
index 6bd8d24..954700b 100644
d2a170
--- a/yum/config.py
d2a170
+++ b/yum/config.py
d2a170
@@ -729,6 +729,8 @@ class StartupConf(BaseConfig):
d2a170
     syslog_facility = Option('LOG_USER')
d2a170
     syslog_device = Option('/dev/log')
d2a170
     persistdir = Option('/var/lib/yum')
d2a170
+    skip_missing_names_on_install = BoolOption(True)
d2a170
+    skip_missing_names_on_update = BoolOption(True)
d2a170
     
d2a170
 class YumConf(StartupConf):
d2a170
     """Configuration option definitions for yum.conf's [main] section.
d2a170
commit be18ab78927522db11cfae5e4f270b073ed1df0b
d2a170
Author: Valentina Mukhamedzhanova <vmukhame@redhat.com>
d2a170
Date:   Wed Mar 16 16:16:49 2016 +0100
d2a170
d2a170
    Fix returnPackages() to respect ignore_case.
d2a170
d2a170
diff --git a/yum/rpmsack.py b/yum/rpmsack.py
d2a170
index 11814f1..0990edd 100644
d2a170
--- a/yum/rpmsack.py
d2a170
+++ b/yum/rpmsack.py
d2a170
@@ -607,6 +607,9 @@ class RPMDBPackageSack(PackageSackBase):
d2a170
                 # will pick up any loads :)
d2a170
                 pkgs = self.searchNames([pat])
d2a170
                 if not pkgs:
d2a170
+                    # We could be given gliBc or mysql
d2a170
+                    if ignore_case:
d2a170
+                        break
d2a170
                     # We need to do a big search for 'pkg*'
d2a170
                     if misc.re_glob(pat):
d2a170
                         break