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

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