|
Seth Vidal |
264039e |
From ca2768f92d9b6f8655a74ced6bad33d971e8c27f Mon Sep 17 00:00:00 2001
|
|
Seth Vidal |
264039e |
From: James Antill <james@and.org>
|
|
Seth Vidal |
264039e |
Date: Fri, 18 Sep 2009 11:30:32 -0400
|
|
Seth Vidal |
264039e |
Subject: [PATCH] Be nice and don't traceback when people screw their rpmdb, BZ 522259
|
|
Seth Vidal |
264039e |
|
|
Seth Vidal |
264039e |
---
|
|
Seth Vidal |
264039e |
yum/Errors.py | 3 +++
|
|
Seth Vidal |
264039e |
yum/__init__.py | 25 +++++++++++++++----------
|
|
Seth Vidal |
264039e |
2 files changed, 18 insertions(+), 10 deletions(-)
|
|
Seth Vidal |
264039e |
|
|
Seth Vidal |
264039e |
diff --git a/yum/Errors.py b/yum/Errors.py
|
|
Seth Vidal |
264039e |
index 6f0ffe4..3a5aca9 100644
|
|
Seth Vidal |
264039e |
--- a/yum/Errors.py
|
|
Seth Vidal |
264039e |
+++ b/yum/Errors.py
|
|
Seth Vidal |
264039e |
@@ -101,6 +101,9 @@ class RepoMDError(YumBaseError):
|
|
Seth Vidal |
264039e |
class PackageSackError(YumBaseError):
|
|
Seth Vidal |
264039e |
pass
|
|
Seth Vidal |
264039e |
|
|
Seth Vidal |
264039e |
+class RpmDBError(YumBaseError):
|
|
Seth Vidal |
264039e |
+ pass
|
|
Seth Vidal |
264039e |
+
|
|
Seth Vidal |
264039e |
class CompsException(YumBaseError):
|
|
Seth Vidal |
264039e |
pass
|
|
Seth Vidal |
264039e |
|
|
Seth Vidal |
264039e |
diff --git a/yum/__init__.py b/yum/__init__.py
|
|
Seth Vidal |
264039e |
index 79c9712..eca0bfb 100644
|
|
Seth Vidal |
264039e |
--- a/yum/__init__.py
|
|
Seth Vidal |
264039e |
+++ b/yum/__init__.py
|
|
Seth Vidal |
264039e |
@@ -1087,7 +1087,7 @@ class YumBase(depsolve.Depsolve):
|
|
Seth Vidal |
264039e |
self.logger.critical(_('%s was supposed to be installed' \
|
|
Seth Vidal |
264039e |
' but is not!' % txmbr.po))
|
|
Seth Vidal |
264039e |
continue
|
|
Seth Vidal |
264039e |
- po = self.rpmdb.searchPkgTuple(txmbr.pkgtup)[0]
|
|
Seth Vidal |
264039e |
+ po = self.getInstalledPackageObject(txmbr.pkgtup)
|
|
Seth Vidal |
264039e |
rpo = txmbr.po
|
|
Seth Vidal |
264039e |
po.yumdb_info.from_repo = rpo.repoid
|
|
Seth Vidal |
264039e |
po.yumdb_info.reason = txmbr.reason
|
|
Seth Vidal |
264039e |
@@ -1802,7 +1802,7 @@ class YumBase(depsolve.Depsolve):
|
|
Seth Vidal |
264039e |
for (pkgtup, instTup) in self.up.getObsoletesTuples():
|
|
Seth Vidal |
264039e |
(n,a,e,v,r) = pkgtup
|
|
Seth Vidal |
264039e |
pkgs = self.pkgSack.searchNevra(name=n, arch=a, ver=v, rel=r, epoch=e)
|
|
Seth Vidal |
264039e |
- instpo = self.rpmdb.searchPkgTuple(instTup)[0] # the first one
|
|
Seth Vidal |
264039e |
+ instpo = self.getInstalledPackageObject(instTup)
|
|
Seth Vidal |
264039e |
for po in pkgs:
|
|
Seth Vidal |
264039e |
obsoletes.append(po)
|
|
Seth Vidal |
264039e |
obsoletesTuples.append((po, instpo))
|
|
Seth Vidal |
264039e |
@@ -2345,11 +2345,16 @@ class YumBase(depsolve.Depsolve):
|
|
Seth Vidal |
264039e |
return result
|
|
Seth Vidal |
264039e |
|
|
Seth Vidal |
264039e |
def getInstalledPackageObject(self, pkgtup):
|
|
Seth Vidal |
264039e |
- """returns a YumInstallPackage object for the pkgtup specified"""
|
|
Seth Vidal |
264039e |
- warnings.warn(_('getInstalledPackageObject() will go away, use self.rpmdb.searchPkgTuple().\n'),
|
|
Seth Vidal |
264039e |
- Errors.YumFutureDeprecationWarning, stacklevel=2)
|
|
Seth Vidal |
264039e |
-
|
|
Seth Vidal |
264039e |
- po = self.rpmdb.searchPkgTuple(pkgtup)[0] # take the first one
|
|
Seth Vidal |
264039e |
+ """ Returns a YumInstallPackage object for the pkgtup specified, or
|
|
Seth Vidal |
264039e |
+ raises an exception. You should use this instead of
|
|
Seth Vidal |
264039e |
+ searchPkgTuple() if you are assuming there is a value. """
|
|
Seth Vidal |
264039e |
+
|
|
Seth Vidal |
264039e |
+ pkgs = self.rpmdb.searchPkgTuple(pkgtup)
|
|
Seth Vidal |
264039e |
+ if len(pkgs) == 0:
|
|
Seth Vidal |
264039e |
+ raise Errors.RpmDBError, _('Package tuple %s could not be found in rpmdb') % str(pkgtup)
|
|
Seth Vidal |
264039e |
+
|
|
Seth Vidal |
264039e |
+ # Dito. FIXME from getPackageObject() for len() > 1 ... :)
|
|
Seth Vidal |
264039e |
+ po = pkgs[0] # take the first one
|
|
Seth Vidal |
264039e |
return po
|
|
Seth Vidal |
264039e |
|
|
Seth Vidal |
264039e |
def gpgKeyCheck(self):
|
|
Seth Vidal |
264039e |
@@ -2613,7 +2618,7 @@ class YumBase(depsolve.Depsolve):
|
|
Seth Vidal |
264039e |
if not isinstance(po, YumLocalPackage):
|
|
Seth Vidal |
264039e |
for (obstup, inst_tup) in self.up.getObsoletersTuples(name=po.name):
|
|
Seth Vidal |
264039e |
if po.pkgtup == obstup:
|
|
Seth Vidal |
264039e |
- installed_pkg = self.rpmdb.searchPkgTuple(inst_tup)[0]
|
|
Seth Vidal |
264039e |
+ installed_pkg = self.getInstalledPackageObject(inst_tup)
|
|
Seth Vidal |
264039e |
yield installed_pkg
|
|
Seth Vidal |
264039e |
else:
|
|
Seth Vidal |
264039e |
for (obs_n, obs_f, (obs_e, obs_v, obs_r)) in po.obsoletes:
|
|
Seth Vidal |
264039e |
@@ -2917,7 +2922,7 @@ class YumBase(depsolve.Depsolve):
|
|
Seth Vidal |
264039e |
topkg = self._test_loop(obsoleting_pkg, self._pkg2obspkg)
|
|
Seth Vidal |
264039e |
if topkg is not None:
|
|
Seth Vidal |
264039e |
obsoleting_pkg = topkg
|
|
Seth Vidal |
264039e |
- installed_pkg = self.rpmdb.searchPkgTuple(installed)[0]
|
|
Seth Vidal |
264039e |
+ installed_pkg = self.getInstalledPackageObject(installed)
|
|
Seth Vidal |
264039e |
txmbr = self.tsInfo.addObsoleting(obsoleting_pkg, installed_pkg)
|
|
Seth Vidal |
264039e |
self.tsInfo.addObsoleted(installed_pkg, obsoleting_pkg)
|
|
Seth Vidal |
264039e |
if requiringPo:
|
|
Seth Vidal |
264039e |
@@ -3078,7 +3083,7 @@ class YumBase(depsolve.Depsolve):
|
|
Seth Vidal |
264039e |
updated)
|
|
Seth Vidal |
264039e |
|
|
Seth Vidal |
264039e |
else:
|
|
Seth Vidal |
264039e |
- updated_pkg = self.rpmdb.searchPkgTuple(updated)[0]
|
|
Seth Vidal |
264039e |
+ updated_pkg = self.getInstalledPackageObject(updated)
|
|
Seth Vidal |
264039e |
txmbr = self.tsInfo.addUpdate(available_pkg, updated_pkg)
|
|
Seth Vidal |
264039e |
if requiringPo:
|
|
Seth Vidal |
264039e |
txmbr.setAsDep(requiringPo)
|
|
Seth Vidal |
264039e |
--
|
|
Seth Vidal |
264039e |
1.6.2.5
|
|
Seth Vidal |
264039e |
|