|
|
eb5f31 |
commit 7e7f374c1ac6984fc50726dd649c4f4c2f56266c
|
|
|
eb5f31 |
Author: Valentina Mukhamedzhanova <vmukhame@redhat.com>
|
|
|
eb5f31 |
Date: Wed Jan 29 12:08:30 2014 -0500
|
|
|
eb5f31 |
|
|
|
eb5f31 |
Make 'yum install @group' give an error when trying to install a
|
|
|
eb5f31 |
non-existent group.
|
|
|
eb5f31 |
|
|
|
eb5f31 |
diff --git a/cli.py b/cli.py
|
|
|
eb5f31 |
index c8884ae..eed63a2 100755
|
|
|
eb5f31 |
--- a/cli.py
|
|
|
eb5f31 |
+++ b/cli.py
|
|
|
eb5f31 |
@@ -964,6 +964,8 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
|
|
|
eb5f31 |
else:
|
|
|
eb5f31 |
assert basecmd == 'install', basecmd
|
|
|
eb5f31 |
txmbrs = self.install(pattern=arg)
|
|
|
eb5f31 |
+ except yum.Errors.GroupInstallError, e:
|
|
|
eb5f31 |
+ self.verbose_logger.log(yum.logginglevels.INFO_2, e)
|
|
|
eb5f31 |
except yum.Errors.InstallError:
|
|
|
eb5f31 |
self.verbose_logger.log(yum.logginglevels.INFO_2,
|
|
|
eb5f31 |
_('No package %s%s%s available.'),
|
|
|
eb5f31 |
@@ -1922,6 +1924,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
|
|
|
eb5f31 |
for igrp in self.igroups.groups:
|
|
|
eb5f31 |
pkgs_used.extend(self._at_groupupgrade('@' + igrp))
|
|
|
eb5f31 |
|
|
|
eb5f31 |
+ done = False
|
|
|
eb5f31 |
for group_string in grouplist:
|
|
|
eb5f31 |
|
|
|
eb5f31 |
grp_grp = True
|
|
|
eb5f31 |
@@ -1966,11 +1969,19 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
|
|
|
eb5f31 |
if not group_matched:
|
|
|
eb5f31 |
self.logger.error(_('Warning: group %s does not exist.'), group_string)
|
|
|
eb5f31 |
continue
|
|
|
eb5f31 |
+ done = True
|
|
|
eb5f31 |
|
|
|
eb5f31 |
if not pkgs_used:
|
|
|
eb5f31 |
if self.conf.group_command == 'objects':
|
|
|
eb5f31 |
self.logger.critical(_("Maybe run: yum groups mark install (see man yum)"))
|
|
|
eb5f31 |
- return 0, [_('No packages in any requested group available to install or update')]
|
|
|
eb5f31 |
+ exit_status = 1
|
|
|
eb5f31 |
+ if upgrade:
|
|
|
eb5f31 |
+ # upgrades don't fail
|
|
|
eb5f31 |
+ exit_status = 0
|
|
|
eb5f31 |
+ if done:
|
|
|
eb5f31 |
+ # at least one group_string was a valid group
|
|
|
eb5f31 |
+ exit_status = 0
|
|
|
eb5f31 |
+ return exit_status, [_('No packages in any requested group available to install or update')]
|
|
|
eb5f31 |
else:
|
|
|
eb5f31 |
return 2, [P_('%d package to Install', '%d packages to Install', len(pkgs_used)) % len(pkgs_used)]
|
|
|
eb5f31 |
|
|
|
eb5f31 |
diff --git a/yum/Errors.py b/yum/Errors.py
|
|
|
eb5f31 |
index 70de539..2c2f022 100644
|
|
|
eb5f31 |
--- a/yum/Errors.py
|
|
|
eb5f31 |
+++ b/yum/Errors.py
|
|
|
eb5f31 |
@@ -105,6 +105,9 @@ class GroupsError(YumBaseError):
|
|
|
eb5f31 |
class InstallError(YumBaseError):
|
|
|
eb5f31 |
pass
|
|
|
eb5f31 |
|
|
|
eb5f31 |
+class GroupInstallError(InstallError):
|
|
|
eb5f31 |
+ pass
|
|
|
eb5f31 |
+
|
|
|
eb5f31 |
class UpdateError(YumBaseError):
|
|
|
eb5f31 |
pass
|
|
|
eb5f31 |
|
|
|
eb5f31 |
diff --git a/yum/__init__.py b/yum/__init__.py
|
|
|
eb5f31 |
index bbd20f3..b40c7e4 100644
|
|
|
eb5f31 |
--- a/yum/__init__.py
|
|
|
eb5f31 |
+++ b/yum/__init__.py
|
|
|
eb5f31 |
@@ -1158,8 +1158,7 @@ class YumBase(depsolve.Depsolve):
|
|
|
eb5f31 |
if hasattr(self, 'term'):
|
|
|
eb5f31 |
hibeg, hiend = self.term.MODE['bold'], self.term.MODE['normal']
|
|
|
eb5f31 |
|
|
|
eb5f31 |
- func(_("The program %s%s%s is found in the yum-utils package.") %
|
|
|
eb5f31 |
- (hibeg, prog, hiend))
|
|
|
eb5f31 |
+ func(_("The program %s is found in the yum-utils package.") % self._try_bold(prog))
|
|
|
eb5f31 |
|
|
|
eb5f31 |
def buildTransaction(self, unfinished_transactions_check=True):
|
|
|
eb5f31 |
"""Go through the packages in the transaction set, find them
|
|
|
eb5f31 |
@@ -4451,6 +4450,12 @@ much more problems).
|
|
|
eb5f31 |
if node == slow:
|
|
|
eb5f31 |
return None
|
|
|
eb5f31 |
|
|
|
eb5f31 |
+ def _try_bold(self, string_):
|
|
|
eb5f31 |
+ """Attempt to make the string look bold in terminal."""
|
|
|
eb5f31 |
+ if hasattr(self, 'term'):
|
|
|
eb5f31 |
+ return '%s%s%s' % (self.term.MODE['bold'], string_, self.term.MODE['normal'])
|
|
|
eb5f31 |
+ return string_
|
|
|
eb5f31 |
+
|
|
|
eb5f31 |
def _at_groupinstall(self, pattern, upgrade=False):
|
|
|
eb5f31 |
" Do groupinstall via. leading @ on the cmd line, for install."
|
|
|
eb5f31 |
assert pattern[0] == '@'
|
|
|
eb5f31 |
@@ -4464,42 +4469,31 @@ much more problems).
|
|
|
eb5f31 |
self.logger.warning(e)
|
|
|
eb5f31 |
return tx_return
|
|
|
eb5f31 |
|
|
|
eb5f31 |
+ found = False
|
|
|
eb5f31 |
if group_string and group_string[0] == '^':
|
|
|
eb5f31 |
group_string = group_string[1:]
|
|
|
eb5f31 |
# Actually dealing with "environment groups".
|
|
|
eb5f31 |
- found = False
|
|
|
eb5f31 |
for env_grp in comps.return_environments(group_string):
|
|
|
eb5f31 |
found = True
|
|
|
eb5f31 |
- try:
|
|
|
eb5f31 |
- txmbrs = self.selectEnvironment(env_grp.environmentid,
|
|
|
eb5f31 |
- upgrade=upgrade)
|
|
|
eb5f31 |
- tx_return.extend(txmbrs)
|
|
|
eb5f31 |
- except yum.Errors.GroupsError:
|
|
|
eb5f31 |
- assert False, "Checked in for loop."
|
|
|
eb5f31 |
- continue
|
|
|
eb5f31 |
- if not found:
|
|
|
eb5f31 |
- self.logger.error(_('Warning: Environment group %s does not exist.'),
|
|
|
eb5f31 |
- group_string)
|
|
|
eb5f31 |
- return tx_return
|
|
|
eb5f31 |
-
|
|
|
eb5f31 |
- found = False
|
|
|
eb5f31 |
- for group in comps.return_groups(group_string):
|
|
|
eb5f31 |
- found = True
|
|
|
eb5f31 |
- try:
|
|
|
eb5f31 |
+ txmbrs = self.selectEnvironment(env_grp.environmentid,
|
|
|
eb5f31 |
+ upgrade=upgrade)
|
|
|
eb5f31 |
+ tx_return.extend(txmbrs)
|
|
|
eb5f31 |
+ else:
|
|
|
eb5f31 |
+ for group in comps.return_groups(group_string):
|
|
|
eb5f31 |
+ found = True
|
|
|
eb5f31 |
txmbrs = self.selectGroup(group.groupid, upgrade=upgrade)
|
|
|
eb5f31 |
tx_return.extend(txmbrs)
|
|
|
eb5f31 |
- except yum.Errors.GroupsError:
|
|
|
eb5f31 |
- assert False, "Checked in for loop."
|
|
|
eb5f31 |
- continue
|
|
|
eb5f31 |
if not found:
|
|
|
eb5f31 |
- self.logger.error(_('Warning: Package group %s does not exist.'),
|
|
|
eb5f31 |
- group_string)
|
|
|
eb5f31 |
-
|
|
|
eb5f31 |
+ raise Errors.GroupInstallError, _('Group %s does not exist.') % self._try_bold(group_string)
|
|
|
eb5f31 |
return tx_return
|
|
|
eb5f31 |
|
|
|
eb5f31 |
def _at_groupupgrade(self, pattern):
|
|
|
eb5f31 |
" Do group upgrade via. leading @ on the cmd line, for update."
|
|
|
eb5f31 |
- return self._at_groupinstall(pattern, upgrade=True)
|
|
|
eb5f31 |
+ try:
|
|
|
eb5f31 |
+ return self._at_groupinstall(pattern, upgrade=True)
|
|
|
eb5f31 |
+ except Errors.GroupInstallError, e:
|
|
|
eb5f31 |
+ self.logger.warning(_('Warning: %s'), e)
|
|
|
eb5f31 |
+ return []
|
|
|
eb5f31 |
|
|
|
eb5f31 |
def _at_groupremove(self, pattern):
|
|
|
eb5f31 |
" Do groupremove via. leading @ on the cmd line, for remove."
|