* implement a command to check packages
This commit is contained in:
+14
@@ -253,6 +253,20 @@ def search_package(terms, lang = None):
|
|||||||
r = r1.union(r2)
|
r = r1.union(r2)
|
||||||
return r
|
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'):
|
def index(dirs, output = 'pisi-index.xml'):
|
||||||
index = Index()
|
index = Index()
|
||||||
if not dirs:
|
if not dirs:
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ class Remove(AtomicOperation):
|
|||||||
# usage. Currently we'are doing it like rpm does, saving
|
# usage. Currently we'are doing it like rpm does, saving
|
||||||
# with a prefix and leaving the user to edit it. In the future
|
# with a prefix and leaving the user to edit it. In the future
|
||||||
# we'll have a plan for these configuration files.
|
# we'll have a plan for these configuration files.
|
||||||
if fileinfo.type == ctx.const.conf:
|
if fileinfo.type == "config":
|
||||||
if os.path.isfile(fpath):
|
if os.path.isfile(fpath):
|
||||||
os.rename(fpath, fpath + ".oldconfig")
|
os.rename(fpath, fpath + ".oldconfig")
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -559,6 +559,29 @@ Usage: info <package1> <package2> ... <packagen>
|
|||||||
ctx.ui.warning(_('File information not available'))
|
ctx.ui.warning(_('File information not available'))
|
||||||
|
|
||||||
|
|
||||||
|
class Check(Command):
|
||||||
|
"""Verify installation
|
||||||
|
|
||||||
|
Usage: check <package1> <package2> ... <packagen>
|
||||||
|
"""
|
||||||
|
__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):
|
class Index(Command):
|
||||||
"""Index PISI files in a given directory
|
"""Index PISI files in a given directory
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ class Constants:
|
|||||||
self.__c.install_func = "install"
|
self.__c.install_func = "install"
|
||||||
|
|
||||||
# file types
|
# file types
|
||||||
|
# FIXME: these are redundant
|
||||||
self.__c.doc = "doc"
|
self.__c.doc = "doc"
|
||||||
self.__c.man = "man"
|
self.__c.man = "man"
|
||||||
self.__c.info = "info"
|
self.__c.info = "info"
|
||||||
|
|||||||
Reference in New Issue
Block a user