[PATCH] Make 'yum install @group' give an error when trying to install a non-existent group
Valentina Mukhamedzhanova
vmukhame at redhat.com
Tue Jan 28 16:42:17 UTC 2014
Here is the updated patch.
1. The exception is now an instance of GroupInstallError (which inherits from InstallError) and contains the information about the string.
2. Upgrading via 'yum upgrade @sdoi' now doesn't fail, the exception is handled.
3. 'yum group install' now gives an error, while 'yum group upgrade' doesn't.
You were concerned about reinstalls, but the patch doesn't affect them in any way.
cli.py | 6 +++++-
yum/Errors.py | 3 +++
yum/__init__.py | 39 +++++++++++++++------------------------
3 files changed, 23 insertions(+), 25 deletions(-)
diff --git a/cli.py b/cli.py
index c8884ae..0afa994 100755
--- a/cli.py
+++ b/cli.py
@@ -964,6 +964,8 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
else:
assert basecmd == 'install', basecmd
txmbrs = self.install(pattern=arg)
+ except yum.Errors.GroupInstallError, e:
+ self.verbose_logger.log(yum.logginglevels.INFO_2, e)
except yum.Errors.InstallError:
self.verbose_logger.log(yum.logginglevels.INFO_2,
_('No package %s%s%s available.'),
@@ -1922,6 +1924,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
for igrp in self.igroups.groups:
pkgs_used.extend(self._at_groupupgrade('@' + igrp))
+ done = False
for group_string in grouplist:
grp_grp = True
@@ -1966,11 +1969,12 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
if not group_matched:
self.logger.error(_('Warning: group %s does not exist.'), group_string)
continue
+ done = True
if not pkgs_used:
if self.conf.group_command == 'objects':
self.logger.critical(_("Maybe run: yum groups mark install (see man yum)"))
- return 0, [_('No packages in any requested group available to install or update')]
+ return not upgrade and not done, [_('No packages in any requested group available to install or update')]
else:
return 2, [P_('%d package to Install', '%d packages to Install', len(pkgs_used)) % len(pkgs_used)]
diff --git a/yum/Errors.py b/yum/Errors.py
index 70de539..2c2f022 100644
--- a/yum/Errors.py
+++ b/yum/Errors.py
@@ -105,6 +105,9 @@ class GroupsError(YumBaseError):
class InstallError(YumBaseError):
pass
+class GroupInstallError(InstallError):
+ pass
+
class UpdateError(YumBaseError):
pass
diff --git a/yum/__init__.py b/yum/__init__.py
index bbd20f3..9485d9e 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -4464,42 +4464,33 @@ 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.GroupInstallError, _('Group %s%s%s does not exist.') % (
+ self.term.MODE['bold'], group_string,
+ self.term.MODE['normal'])
return tx_return
def _at_groupupgrade(self, pattern):
" Do group upgrade via. leading @ on the cmd line, for update."
- return self._at_groupinstall(pattern, upgrade=True)
+ try:
+ return self._at_groupinstall(pattern, upgrade=True)
+ except yum.Errors.GroupInstallError, e:
+ self.logger.warning('Warning: %s', e)
+ return []
def _at_groupremove(self, pattern):
" Do groupremove via. leading @ on the cmd line, for remove."
_______________________________________________
Yum-devel mailing list
Yum-devel at lists.baseurl.org
http://lists.baseurl.org/mailman/listinfo/yum-devel
More information about the Yum-devel
mailing list