[Yum-devel] [PATCH] Add check command, like smart/apt

James Antill james at and.org
Wed Dec 16 20:21:35 UTC 2009


---
 cli.py         |    1 +
 docs/yum.8     |    5 +++++
 yumcommands.py |   28 ++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/cli.py b/cli.py
index 2c6c9a4..891922f 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 00814c5..1fac767 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,9 @@ 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.
+.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 c7f6d40..aa7be12 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -1294,3 +1294,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
+
-- 
1.6.5.2



More information about the Yum-devel mailing list