def detect(self): result = Issue.detect(self) if result is not None: return result dbname = os.path.join(Config.system.root, "/var/lib/rpm/Packages") self._happened = False if not os.path.isfile(os.path.realpath(dbname)): self._db_missing = True self._happened = True self._checked = 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._checked = True return True
def fix(self): result = Issue.fix(self) if result is not None: return result for f in self.locks: os.unlink(f) self._fixed = True return True
def fix(self): result = Issue.fix(self) if result is not None: return result yum = spawnvch(executable="/usr/bin/yum", args=["yum", "install"] + packages_list, chroot=Config.system.root).communicate("y\ny\n") if yum.returncode == 0: self._fixed = True return True
def fix(self): result = Issue.fix(self) if result is not None: return result dbname = os.path.join(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
def detect(self): result = Issue.detect(self) if result is not None: return result path = os.path.join(Config.system.root,"/var/lib/rpm/") self.locks = [] def walkfunc(arg, dirname, fnames): for f in fnames: if f[:4]=="__db" and os.path.isfile(os.path.join(dirname, f)): arg.append(os.path.join(dirname, f)) os.path.walk(path, walkfunc, self.locks) if len(self.locks)==0: self._happened = False else: self._happened = True self._checked = True return True
def detect(self): result = Issue.detect(self) if result is not None: return result architectures = {} for p in self.packages_list: architectures[p] = set() mi = self._plugin.rpm.dbMatch("name", p) for hdr in mi: self._plugin._reporting.debug( level=TASK, origin=self, message="Found package %s with architecture %s" % (p, hdr["arch"])) architectures[p].add(hdr["arch"]) #is there a common architecture for all the packages? all = reduce(lambda acc, x: acc.union(x), architectures.values(), set()) common = reduce(lambda acc, x: acc.intersection(x), architectures.values(), all) self._plugin._reporting.debug( level=TASK, origin=self, message="Common architecture for all packages is %s" % ("+".join(common), )) if len(common) == 0: self._happened = True else: self._happened = False self._checked = True return True
def reset(self): Issue.reset(self) self.locks = []
def __init__(self, *args, **kwargs): Issue.__init__(self, *args, **kwargs)