[Yum-devel] [PATCH] Be nice and don't traceback when people screw their rpmdb, BZ 522259
Seth Vidal
skvidal at fedoraproject.org
Fri Sep 18 18:27:39 UTC 2009
On Fri, 18 Sep 2009, James Antill wrote:
At first glance this looks great but a number of places where we do the
same thing we'd want more or less the same function but a different
exception raised.
Given it is a generic "Your rpmdb is screwed" exception would it make
sense to raise the same exception we raise in rpmsack.py:
raise Errors.PackageSackError, 'Rpmdb changed underneath us'
more or less.
Thoughts?
If you think we should have one of these per major command method in yum,
that's fine, too - just a thought.
-sv
> ---
> yum/__init__.py | 15 ++++++++++++---
> 1 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/yum/__init__.py b/yum/__init__.py
> index d13f7a9..c5ca780 100644
> --- a/yum/__init__.py
> +++ b/yum/__init__.py
> @@ -2592,12 +2592,21 @@ class YumBase(depsolve.Depsolve):
> pkgnames.update(thisgroup.packages)
> return self.pkgSack.searchNames(pkgnames)
>
> + def _safeInstPkgObj(self, pkgtup):
> + """ This gets the first package object for a pkgtup which should be
> + installed. We just don't blow up if it's not there (usually
> + because someone as screwed their rpmdb). """
> + ret = self.rpmdb.searchPkgTuple(pkgtup)
> + if not ret:
> + raise Errors.InstallError, _('No match for pkgtup %s in rpmdb') % str(pkgtup)
> + return ret[0]
> +
> def _find_obsoletees(self, po):
> """ Return the pkgs. that are obsoleted by the po we pass in. """
> if not isinstance(po, YumLocalPackage):
> for (obstup, inst_tup) in self.up.getObsoletersTuples(name=po.name):
> if po.pkgtup == obstup:
> - installed_pkg = self.rpmdb.searchPkgTuple(inst_tup)[0]
> + installed_pkg = self._safeInstPkgObj(inst_tup)
> yield installed_pkg
> else:
> for (obs_n, obs_f, (obs_e, obs_v, obs_r)) in po.obsoletes:
> @@ -2901,7 +2910,7 @@ class YumBase(depsolve.Depsolve):
> topkg = self._test_loop(obsoleting_pkg, self._pkg2obspkg)
> if topkg is not None:
> obsoleting_pkg = topkg
> - installed_pkg = self.rpmdb.searchPkgTuple(installed)[0]
> + installed_pkg = self._safeInstPkgObj(installed)
> txmbr = self.tsInfo.addObsoleting(obsoleting_pkg, installed_pkg)
> self.tsInfo.addObsoleted(installed_pkg, obsoleting_pkg)
> if requiringPo:
> @@ -3062,7 +3071,7 @@ class YumBase(depsolve.Depsolve):
> updated)
>
> else:
> - updated_pkg = self.rpmdb.searchPkgTuple(updated)[0]
> + updated_pkg = self._safeInstPkgObj(updated)
> txmbr = self.tsInfo.addUpdate(available_pkg, updated_pkg)
> if requiringPo:
> txmbr.setAsDep(requiringPo)
> --
> 1.6.2.5
>
> _______________________________________________
> 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