diff options
| author | Martin Sivak <msivak@redhat.com> | 2008-04-08 14:07:10 +0200 |
|---|---|---|
| committer | Martin Sivak <msivak@redhat.com> | 2008-04-08 14:07:10 +0200 |
| commit | 8883825c01c2ae127f0be45c71a451e121821bad (patch) | |
| tree | 98a4e29a07d70d6b041b349fad88e06001b5f011 /plugins | |
| parent | c5f8ba7c9d6eae21a63d24241e07bf19b75cce99 (diff) | |
| download | firstaidkit-8883825c01c2ae127f0be45c71a451e121821bad.tar.gz firstaidkit-8883825c01c2ae127f0be45c71a451e121821bad.tar.xz firstaidkit-8883825c01c2ae127f0be45c71a451e121821bad.zip | |
Make the lowlevel rpm plugin work better
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/plugin_rpm_lowlevel/__init__.py | 3 | ||||
| -rw-r--r-- | plugins/plugin_rpm_lowlevel/issue_locks.py | 2 | ||||
| -rw-r--r-- | plugins/plugin_rpm_lowlevel/issue_packages.py | 35 |
3 files changed, 34 insertions, 6 deletions
diff --git a/plugins/plugin_rpm_lowlevel/__init__.py b/plugins/plugin_rpm_lowlevel/__init__.py index 0dcad57..3d003b5 100644 --- a/plugins/plugin_rpm_lowlevel/__init__.py +++ b/plugins/plugin_rpm_lowlevel/__init__.py @@ -51,15 +51,18 @@ class RPMLowlevelPlugin(IssuesPlugin): IssuesPlugin.prepare(self) def backup(self): + IssuesPlugin.backup(self) self.backup.backupPath(path = Config.system.root+"/var/lib/rpm", name="rpm") self._result=ReturnSuccess def restore(self): self.backup.restorePath(path = Config.system.root+"/var/lib/rpm", name="rpm") + IssuesPlugin.restore(self) self._result=ReturnSuccess def clean(self): self._backups.closeBackup(self.backup._id) + IssuesPlugin.clean(self) self._result=ReturnSuccess def get_plugin(): diff --git a/plugins/plugin_rpm_lowlevel/issue_locks.py b/plugins/plugin_rpm_lowlevel/issue_locks.py index b0a652d..fcc4ec3 100644 --- a/plugins/plugin_rpm_lowlevel/issue_locks.py +++ b/plugins/plugin_rpm_lowlevel/issue_locks.py @@ -28,7 +28,7 @@ import re class Locks(Issue): name = "Staled RPM locks" - description = "The database is still lockes, but it shouldn't be. Probably a result of some unexpectedly aborted rpm operation." + description = "The database is still locked, but it shouldn't be. Probably a result of some unexpectedly aborted rpm operation." def __init__(self, *args, **kwargs): Issue.__init__(self, *args, **kwargs) diff --git a/plugins/plugin_rpm_lowlevel/issue_packages.py b/plugins/plugin_rpm_lowlevel/issue_packages.py index 533e812..bd07402 100644 --- a/plugins/plugin_rpm_lowlevel/issue_packages.py +++ b/plugins/plugin_rpm_lowlevel/issue_packages.py @@ -23,12 +23,12 @@ from pyfirstaidkit.issue import Issue from pyfirstaidkit.reporting import TASK from pyfirstaidkit.utils import spawnvch from pyfirstaidkit.configuration import Config -import os.path +import os class Packages(Issue): name = "Required Packages database" - description = "The file containing the rpm database of packages is missing" + description = "The file containing the rpm database of packages is missing or corrupted" def detect(self): result = Issue.detect(self) @@ -36,10 +36,23 @@ class Packages(Issue): return result dbname = Config.system.root+"/var/lib/rpm/Packages" + self._happened = False - if os.path.isfile(os.path.realpath(dbname)): - self._happened = False - else: + if not os.path.isfile(os.path.realpath(dbname)): + self._db_missing = True + self._happened = True + self._detected = True + return True + + #verify the Package database + rpm_verify = spawnvch(executable = "/usr/lib/rpm/rpmdb_verify", args = ["/usr/lib/rpm/rpmdb_verify", dbname], chroot = Config.system.root) + err = rpm_verify.wait() + if err!=0: + return False + + if len(rpm_verify.stdout.read())>0: + self._happened = True + if len(rpm_verify.stderr.read())>0: self._happened = True self._detected = True @@ -50,7 +63,19 @@ class Packages(Issue): if result is not None: return result + dbname = Config.system.root+"/var/lib/rpm/Packages" + + if not self._db_missing: + #dump&load the database + os.rename(dbname, dbname+".orig") + err = spawnvch(executable = "/bin/sh", args = ["sh", "-c", "/usr/lib/rpm/rpmdb_dump /var/lib/rpm/Packages.orig | /usr/lib/rpm/rpmdb_load /var/lib/rpm/Packages"], chroot = Config.system.root).wait() + if rpm.returncode!=0: + os.rename(dbname+".orig", dbname) + return False + + #rebuild the indexes rpm = spawnvch(executable = "/bin/rpm", args = ["rpm", "--rebuilddb"], chroot = Config.system.root).wait() if rpm.returncode==0: self._fixed = True return True + |
