diff --git a/pisi/api.py b/pisi/api.py index 6ee9d2e8..b4dcc5fc 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -253,6 +253,20 @@ def search_package(terms, lang = None): r = r1.union(r2) return r +def check(package): + md, files = info(package) + corrupt = [] + for file in files.list: + if file.hash and file.type != "config" \ + and not os.path.islink('/' + file.path): + ctx.ui.info(_("Checking %s...") % file.path, True, True) + if file.hash != util.sha1_file('/' + file.path): + corrupt.append(file) + ctx.ui.info("Corrupt file: %s" % file) + else: + ctx.ui.info("OK", True) + return corrupt + def index(dirs, output = 'pisi-index.xml'): index = Index() if not dirs: diff --git a/pisi/atomicoperations.py b/pisi/atomicoperations.py index 2f220889..67b21cc1 100644 --- a/pisi/atomicoperations.py +++ b/pisi/atomicoperations.py @@ -355,7 +355,7 @@ class Remove(AtomicOperation): # usage. Currently we'are doing it like rpm does, saving # with a prefix and leaving the user to edit it. In the future # we'll have a plan for these configuration files. - if fileinfo.type == ctx.const.conf: + if fileinfo.type == "config": if os.path.isfile(fpath): os.rename(fpath, fpath + ".oldconfig") else: diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index f1849007..cea9e535 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -559,6 +559,29 @@ Usage: info ... ctx.ui.warning(_('File information not available')) +class Check(Command): + """Verify installation + +Usage: check ... +""" + __metaclass__ = autocommand + + def __init__(self): + super(Check, self).__init__() + + name = ("check", "c") + + def run(self): + if not self.args: + self.help() + return + + self.init(True) + for arg in self.args: + pisi.api.check(arg) + self.finalize() + + class Index(Command): """Index PISI files in a given directory diff --git a/pisi/constants.py b/pisi/constants.py index dfb4d9d8..95e06748 100644 --- a/pisi/constants.py +++ b/pisi/constants.py @@ -67,6 +67,7 @@ class Constants: self.__c.install_func = "install" # file types + # FIXME: these are redundant self.__c.doc = "doc" self.__c.man = "man" self.__c.info = "info"