From 482d1ada460737084c26c16b964e8c4fed8242fa Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 30 Sep 2011 18:44:12 +0200 Subject: [PATCH] Some smaller fixes on transaction check. --- python/pakfire/filelist.py | 9 ++++++++- python/pakfire/packages/base.py | 6 +++--- python/pakfire/packages/installed.py | 10 +++++++++- python/pakfire/transaction.py | 6 ++---- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/python/pakfire/filelist.py b/python/pakfire/filelist.py index 4f280f5ec..53ef346c4 100644 --- a/python/pakfire/filelist.py +++ b/python/pakfire/filelist.py @@ -34,7 +34,14 @@ class File(_File): self.hash1 = "" def __cmp__(self, other): - return cmp(self.pkg, other.pkg) or cmp(self.name, other.name) + ret = cmp(self.name, other.name) + + print self.pkg, other.pkg + + if not ret: + ret = cmp(self.pkg, other.pkg) + + return ret def is_dir(self): # XXX TODO diff --git a/python/pakfire/packages/base.py b/python/pakfire/packages/base.py index 4c9eff97b..9684fd125 100644 --- a/python/pakfire/packages/base.py +++ b/python/pakfire/packages/base.py @@ -433,7 +433,7 @@ class Package(object): # Sort files by the length of their name to remove all files in # a directory first and then check, if there are any files left. - files.sort(cmp=lambda x,y: cmp(len(x), len(y)), reverse=True) + files.sort(cmp=lambda x,y: cmp(len(x.name), len(y.name)), reverse=True) i = 0 for _file in files: @@ -445,10 +445,10 @@ class Package(object): logging.debug("Removing file: %s" % _file) if prefix: - file = os.path.join(prefix, _file[1:]) + file = os.path.join(prefix, _file.name[1:]) assert file.startswith("%s/" % prefix) else: - file = _file + file = _file.name # If the file was removed by the user, we can skip it. if not os.path.exists(file): diff --git a/python/pakfire/packages/installed.py b/python/pakfire/packages/installed.py index f0d8364d5..df5417459 100644 --- a/python/pakfire/packages/installed.py +++ b/python/pakfire/packages/installed.py @@ -182,7 +182,15 @@ class DatabasePackage(Package): @property def configfiles(self): - return [] # XXX to be done + ret = [] + + for file in self.filelist: + if not file.is_config(): + continue + + ret.append(file) + + return ret def _does_provide_file(self, requires): """ diff --git a/python/pakfire/transaction.py b/python/pakfire/transaction.py index e7734a850..dbc34272a 100644 --- a/python/pakfire/transaction.py +++ b/python/pakfire/transaction.py @@ -102,13 +102,11 @@ class TransactionCheck(object): else: self.filelist[file.name] = [file,] - #self.errors.append((self.ERROR_TYPE_CONFLICT, file)) - def remove(self, pkg): for file in pkg.filelist: try: self.filelist[file.name].remove(file) - except KeyError: + except (KeyError, ValueError): pass def update(self, pkg): @@ -333,7 +331,7 @@ class Transaction(object): return check.print_errors() - raise TransactionCheckError, _("Transaction test was not successful") + #raise TransactionCheckError, _("Transaction test was not successful") def run(self): # Download all packages. -- 2.39.5