[yum-commits] Branch 'yum-3_2_X' - 2 commits - cli.py docs/yum.8 yumcommands.py yummain.py

James Antill james at osuosl.org
Thu Dec 17 21:58:23 UTC 2009


 cli.py         |    1 +
 docs/yum.8     |    7 +++++++
 yumcommands.py |   28 ++++++++++++++++++++++++++++
 yummain.py     |   18 +++++++++++++-----
 4 files changed, 49 insertions(+), 5 deletions(-)

New commits:
commit bfb8214402a903798d25e4e78735a7866f018759
Author: James Antill <james at and.org>
Date:   Wed Dec 16 15:21:09 2009 -0500

    Add check command, like smart/apt

diff --git a/cli.py b/cli.py
index a70224d..b890231 100644
--- a/cli.py
+++ b/cli.py
@@ -99,6 +99,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         self.registerCommand(yumcommands.DowngradeCommand())        
         self.registerCommand(yumcommands.VersionCommand())
         self.registerCommand(yumcommands.HistoryCommand())
+        self.registerCommand(yumcommands.CheckRpmdbCommand())
 
     def registerCommand(self, command):
         for name in command.getNames():
diff --git a/docs/yum.8 b/docs/yum.8
index ced16e3..7c102f7 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -71,6 +71,8 @@ gnome\-packagekit application\&.
 .br
 .I \fR * history [info|list|summary|redo|undo|new] 
 .br
+.I \fR * check
+.br 
 .I \fR * help [command] 
 .br
 .PP 
@@ -262,6 +264,11 @@ if there was something not good with the transaction.
 .br
 
 .IP
+.IP "\fBcheck\fP"
+Checks the local rpmdb and produces information on any problems it finds. You
+can pass the check command the arguments "dependencies" or "duplicates", to
+limit the checking that is performed (the default is "all" which does both).
+.IP
 .IP "\fBhelp\fP"
 Produces help, either for all commands or if given a command name then the help
 for that particular command\&.
diff --git a/yumcommands.py b/yumcommands.py
index a09ba83..14eaf9d 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -1285,3 +1285,31 @@ class HistoryCommand(YumCommand):
         if extcmds:
             vcmd = extcmds[0]
         return vcmd in ('repeat', 'redo', 'undo')
+
+
+class CheckRpmdbCommand(YumCommand):
+    def getNames(self):
+        return ['check', 'check-rpmdb']
+
+    def getUsage(self):
+        return "[dependencies|duplicates|all]"
+
+    def getSummary(self):
+        return _("Check for problems in the rpmdb")
+
+    def doCommand(self, base, basecmd, extcmds):
+        chkcmd = 'all'
+        if extcmds:
+            chkcmd = extcmds[0]
+
+        def _out(x):
+            print x
+
+        rc = 0
+        if base._rpmdb_warn_checks(_out, False, chkcmd):
+            rc = 1
+        return rc, ['%s %s' % (basecmd, chkcmd)]
+
+    def needTs(self, base, basecmd, extcmds):
+        return False
+
commit b214471f45fba558873db9323465aa6f9927a507
Author: James Antill <james at and.org>
Date:   Wed Dec 16 15:18:46 2009 -0500

     Call rpmdb.check_*() directly, now that we can instead of asking the
    user to do it.
     Also call for rpm transaction test failures, Eg. kmods.

diff --git a/yummain.py b/yummain.py
index 92047e7..caaeaf8 100755
--- a/yummain.py
+++ b/yummain.py
@@ -169,10 +169,8 @@ def main(args):
             logger.critical(_('Error: %s'), msg)
         if not base.conf.skip_broken:
             verbose_logger.info(_(" You could try using --skip-broken to work around the problem"))
-        verbose_logger.info(_(" You could try running: package-cleanup --problems\n"
-                              "                        package-cleanup --dupes\n"
-                              "                        rpm -Va --nofiles --nodigest"))
-        base.yumUtilsMsg(verbose_logger.info, "package-cleanup")
+        if not base._rpmdb_warn_checks(out=verbose_logger.info, warn=False):
+            verbose_logger.info(_(" You could try running: rpm -Va --nofiles --nodigest"))
         if unlock(): return 200
         return 1
     elif result == 2:
@@ -199,7 +197,17 @@ def main(args):
     except IOError, e:
         return exIOError(e)
 
-    verbose_logger.log(logginglevels.INFO_2, _('Complete!'))
+    # rpm_check_debug failed.
+    if type(return_code) == type(,) and len(return_code) == 2:
+        (result, resultmsgs) = return_code
+        for msg in resultmsgs:
+            logger.critical("%s", msg)
+        if not base._rpmdb_warn_checks(out=verbose_logger.info, warn=False):
+            verbose_logger.info(_(" You could try running: rpm -Va --nofiles --nodigest"))
+        return_code = result
+    else:
+        verbose_logger.log(logginglevels.INFO_2, _('Complete!'))
+
     if unlock(): return 200
     return return_code
 


More information about the Yum-commits mailing list