summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMartin Sivak <msivak@redhat.com>2008-03-18 15:20:34 +0100
committerMartin Sivak <msivak@redhat.com>2008-03-18 15:21:23 +0100
commit7fd1581d3cf8c593fcf59587be0a792a2272c5a4 (patch)
tree220abc831ce25c2df09820d151c490c5e22b3532 /plugins
parentf12d5d6ac67cab511d1f15f41385afd10b8198da (diff)
downloadfirstaidkit-7fd1581d3cf8c593fcf59587be0a792a2272c5a4.tar.gz
firstaidkit-7fd1581d3cf8c593fcf59587be0a792a2272c5a4.tar.xz
firstaidkit-7fd1581d3cf8c593fcf59587be0a792a2272c5a4.zip
Split the RPM plugin into the consistency and lowlevel parts and use dependency flags
Diffstat (limited to 'plugins')
-rw-r--r--plugins/plugin_rpm/__init__.py3
-rw-r--r--plugins/plugin_rpm_lowlevel/__init__.py61
-rw-r--r--plugins/plugin_rpm_lowlevel/issue_packages.py56
3 files changed, 119 insertions, 1 deletions
diff --git a/plugins/plugin_rpm/__init__.py b/plugins/plugin_rpm/__init__.py
index 71fea97..f5409a1 100644
--- a/plugins/plugin_rpm/__init__.py
+++ b/plugins/plugin_rpm/__init__.py
@@ -36,10 +36,11 @@ class RPMPlugin(IssuesPlugin):
author = "Martin Sivak"
issue_tests = [RequiredPackages]
+ set_flags = ["rpm_consistent"]
@classmethod
def getDeps(cls):
- return set(["root", "experimental", "filesystem"])
+ return set(["root", "experimental", "filesystem", "rpm_lowlevel"])
def __init__(self, *args, **kwargs):
IssuesPlugin.__init__(self, *args, **kwargs)
diff --git a/plugins/plugin_rpm_lowlevel/__init__.py b/plugins/plugin_rpm_lowlevel/__init__.py
new file mode 100644
index 0000000..a7f80ea
--- /dev/null
+++ b/plugins/plugin_rpm_lowlevel/__init__.py
@@ -0,0 +1,61 @@
+# First Aid Kit - diagnostic and repair tool for Linux
+# Copyright (C) 2007 Martin Sivak <msivak@redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+from pyfirstaidkit.plugins import IssuesPlugin,Flow
+from pyfirstaidkit.returns import *
+from pyfirstaidkit.utils import *
+from pyfirstaidkit.reporting import PLUGIN,TASK
+from pyfirstaidkit import Config
+
+from issue_packages import Packages
+
+class RPMLowlevelPlugin(IssuesPlugin):
+ """This plugin provides lowlevel checks for RPM database."""
+ #
+ # Additional flow defprepareion.
+ #
+ flows = Flow.init(IssuesPlugin)
+
+ name = "RPM lowlevel structure plugin"
+ version = "0.0.1"
+ author = "Martin Sivak"
+
+ issue_tests = [Packages]
+ set_flags = ["rpm_lowlevel"]
+
+ @classmethod
+ def getDeps(cls):
+ return set(["root", "experimental", "filesystem"])
+
+ def __init__(self, *args, **kwargs):
+ IssuesPlugin.__init__(self, *args, **kwargs)
+ self.rpm = None
+
+ def prepare(self):
+ IssuesPlugin.prepare(self)
+
+ def backup(self):
+ self._result=ReturnSuccess
+
+ def restore(self):
+ self._result=ReturnSuccess
+
+ def clean(self):
+ self._result=ReturnSuccess
+
+def get_plugin():
+ return RPMLowlevelPlugin
diff --git a/plugins/plugin_rpm_lowlevel/issue_packages.py b/plugins/plugin_rpm_lowlevel/issue_packages.py
new file mode 100644
index 0000000..697412b
--- /dev/null
+++ b/plugins/plugin_rpm_lowlevel/issue_packages.py
@@ -0,0 +1,56 @@
+# File name: issue_filesystem.py
+# Date: 2008/03/14
+# Author: Martin Sivak <msivak at redhat dot com>
+#
+# Copyright (C) Red Hat 2008
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# in a file called COPYING along with this program; if not, write to
+# the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
+# 02139, USA.
+
+from pyfirstaidkit.issue import Issue
+from pyfirstaidkit.reporting import TASK
+from pyfirstaidkit.utils import spawnvch
+from pyfirstaidkit.configuration import Config
+import os.path
+
+
+class Packages(Issue):
+ name = "Required Packages database"
+ description = "The file containing the rpm database of packages is missing"
+
+ def detect(self):
+ result = Issue.detect(self)
+ if result is not None:
+ return result
+
+ dbname = Config.system.root+"/var/lib/rpm/Packages"
+
+ if os.path.isfile(os.path.realpath(dbname)):
+ self._happened = False
+ else:
+ self._happened = True
+
+ self._detected = True
+ return True
+
+ def fix(self):
+ result = Issue.fix(self)
+ if result is not None:
+ return result
+
+ rpm = spawnvch(executable = "/usr/bin/rpm", args = ["rpm", "--rebuilddb"], chroot = Config.system.root).wait()
+ if rpm.returncode==0:
+ self._fixed = True
+ return True