[PATCH] Make 'yum install @group' give an error when trying to install a non-existent group

Valentina Mukhamedzhanova vmukhame at redhat.com
Thu Jan 23 16:07:15 UTC 2014


The purpose of this change is to make 'yum install @group' behaviour consistent with 'yum install package' behaviour.
When user tries to install a non-existent package he gets an error and the exit code gets set to 1. This patch 
makes group install behave in the same way.

The _at_groupinstall() code for normal groups and for environment groups was basically identical, so I merged it a little bit.
I have also removed the try/except block since it appeared to have no effect.

---
 cli.py          |  5 +++++
 yum/__init__.py | 31 ++++++++-----------------------
 2 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/cli.py b/cli.py
index c8884ae..a576f16 100755
--- a/cli.py
+++ b/cli.py
@@ -970,6 +970,11 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
                                         self.term.MODE['bold'], arg,
                                         self.term.MODE['normal'])
                 self._maybeYouMeant(arg)
+            except yum.Errors.GroupsError:
+                self.verbose_logger.log(yum.logginglevels.INFO_2,
+                                        _('Group %s%s%s does not exist.'),
+                                        self.term.MODE['bold'], arg,
+                                        self.term.MODE['normal'])
             else:
                 done = True
                 self._install_upgraded_requires(txmbrs)
diff --git a/yum/__init__.py b/yum/__init__.py
index bbd20f3..d4143ee 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -4464,37 +4464,22 @@ much more problems).
             self.logger.warning(e)
             return tx_return
 
+        found = False
         if group_string and group_string[0] == '^':
             group_string = group_string[1:]
             # Actually dealing with "environment groups".
-            found = False
             for env_grp in comps.return_environments(group_string):
                 found = True
-                try:
-                    txmbrs = self.selectEnvironment(env_grp.environmentid,
-                                                    upgrade=upgrade)
-                    tx_return.extend(txmbrs)
-                except yum.Errors.GroupsError:
-                    assert False, "Checked in for loop."
-                    continue
-            if not found:
-                self.logger.error(_('Warning: Environment group %s does not exist.'),
-                                  group_string)
-            return tx_return
-
-        found = False
-        for group in comps.return_groups(group_string):
-            found = True
-            try:
+                txmbrs = self.selectEnvironment(env_grp.environmentid,
+                                                upgrade=upgrade)
+                tx_return.extend(txmbrs)
+        else:
+            for group in comps.return_groups(group_string):
+                found = True
                 txmbrs = self.selectGroup(group.groupid, upgrade=upgrade)
                 tx_return.extend(txmbrs)
-            except yum.Errors.GroupsError:
-                assert False, "Checked in for loop."
-                continue
         if not found:
-            self.logger.error(_('Warning: Package group %s does not exist.'),
-                              group_string)
-
+            raise yum.Errors.GroupsError
         return tx_return
 
     def _at_groupupgrade(self, pattern):


More information about the Yum-devel mailing list