[Yum-devel] [PATCH 2/2] Create a _rpmdb_warn_checks function, and use that when we find an rpmdb version warning.

James Antill james at and.org
Fri Dec 11 07:11:10 UTC 2009


 Change the text on the warning, hopefully Panu will be happier :).

 Use the rpmdb.check_* functions, to see if we find any problems.
---
 output.py       |    3 +--
 yum/__init__.py |   28 ++++++++++++++++++++++++++--
 yumcommands.py  |    3 +--
 3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/output.py b/output.py
index b748ef9..f87247d 100755
--- a/output.py
+++ b/output.py
@@ -1287,8 +1287,7 @@ to exit.
             # match the current rpmdb ... then mark it as bad.
             rpmdbv  = self.rpmdb.simpleVersion(main_only=True)[0]
             if lastdbv.end_rpmdbversion != rpmdbv:
-                errstring = _('Warning: RPMDB has been altered since the last yum transaction.')
-                self.logger.warning(errstring)
+                self._rpmdb_warn_checks()
 
     def _history_get_transactions(self, extcmds):
         if len(extcmds) < 2:
diff --git a/yum/__init__.py b/yum/__init__.py
index c2ac471..9fa700d 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1062,6 +1062,31 @@ class YumBase(depsolve.Depsolve):
             toRemove.add(dep)
             self._getDepsToRemove(dep, deptree, toRemove)
 
+    def _rpmdb_warn_checks(self, out=None, warn=True, chkcmd='all'):
+        if out is None:
+            out = self.logger.warning
+        if warn:
+            out(_('Warning: RPMDB altered outside of yum.'))
+
+        rc = 0
+        if chkcmd in ('all', 'duplicates'):
+            prob2ui = {'requires' : _('missing requires'),
+                       'conflicts' : _('installed conflict')}
+            for (pkg, prob, ver, opkgs) in self.rpmdb.check_dependencies():
+                rc += 1
+                if opkgs:
+                    opkgs = ": " + ', '.join(map(str, opkgs))
+                else:
+                    opkgs = ''
+                out("%s %s %s%s" % (pkg, prob2ui[prob], ver, opkgs))
+
+        if chkcmd in ('all', 'duplicates'):
+            iopkgs = set(self.conf.installonlypkgs)
+            for (pkg, prob, opkg) in self.rpmdb.check_duplicates(iopkgs):
+                rc += 1
+                out(_("%s is a duplicate of %s") % (pkg, opkg))
+        return rc
+
     def runTransaction(self, cb):
         """takes an rpm callback object, performs the transaction"""
 
@@ -1081,8 +1106,7 @@ class YumBase(depsolve.Depsolve):
         if lastdbv is not None:
             lastdbv = lastdbv.end_rpmdbversion
         if lastdbv is not None and rpmdbv != lastdbv:
-            errstring = _('Warning: RPMDB has been altered since the last yum transaction.')
-            self.logger.warning(errstring)
+            self._rpmdb_warn_checks()
         if self.conf.history_record:
             self.history.beg(rpmdbv, using_pkgs, list(self.tsInfo))
 
diff --git a/yumcommands.py b/yumcommands.py
index 4fe2fe1..211b277 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -1170,8 +1170,7 @@ class VersionCommand(YumCommand):
                 if lastdbv is not None:
                     lastdbv = lastdbv.end_rpmdbversion
                 if lastdbv is not None and data[0] != lastdbv:
-                    errstring = _('Warning: RPMDB has been altered since the last yum transaction.')
-                    base.logger.warning(errstring)
+                    base._rpmdb_warn_checks()
                 if vcmd not in ('group-installed', 'group-all'):
                     cols.append(("%s %s/%s" % (_("Installed:"), rel, ba),
                                  str(data[0])))
-- 
1.6.5.2



More information about the Yum-devel mailing list