[PATCH] Make 'yum install @group' give an error when trying to install a non-existent group
James Antill
james at fedoraproject.org
Wed Jan 29 14:24:43 UTC 2014
On Tue, 2014-01-28 at 11:42 -0500, Valentina Mukhamedzhanova wrote:
> 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.
Look fine apart from a couple of minorish things:
> @@ -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')]
Just use an if statement here, esp. as this will make the first part of
the tuple a bool() and not an int().
> + raise yum.Errors.GroupInstallError, _('Group %s%s%s does not exist.') % (
> + self.term.MODE['bold'], group_string,
> + self.term.MODE['normal'])
You can't access self.term from YumBase without protecting it (see
yumUtilsMsg()).
Also you can use just Errors.GroupInstallError ...
> 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 []
This needs to be _('Warning: %s').
More information about the Yum-devel
mailing list