From 859cb562ed505409e01eb9efd3593a3db171e732 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Mon, 4 Jun 2012 12:09:13 +0200 Subject: [PATCH] [entropy.spm] PortagePlugin: rewrite _bump_vartree_mtime(), fix Portage cache corruption It has been found that pkg vdb entry mtime was not properly updated, which resulted in the following Portage cache corruption: >>> Auto-cleaning packages... portage: COUNTER for net-libs/gnutls-2.12.18 was corrupted; resetting to value of 0 --- .../interfaces/portage_plugin/__init__.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/entropy/spm/plugins/interfaces/portage_plugin/__init__.py b/lib/entropy/spm/plugins/interfaces/portage_plugin/__init__.py index c3044264a..b6b8ba995 100644 --- a/lib/entropy/spm/plugins/interfaces/portage_plugin/__init__.py +++ b/lib/entropy/spm/plugins/interfaces/portage_plugin/__init__.py @@ -2785,10 +2785,23 @@ class PortagePlugin(SpmPlugin): package_metadata) def _bump_vartree_mtime(self, portage_cpv): + """ + Properly bump pkg vdb entry mtime. As oppsed to + vartree.dbapi._bump_mtime() this method also bumps + mtime of the pkg directory, which is vital as well. + """ root = etpConst['systemroot'] + os.path.sep - vartree = self._get_portage_vartree(root = root) - if hasattr(vartree.dbapi, '_bump_mtime'): - vartree.dbapi._bump_mtime(portage_cpv) + base = self._get_vdb_path(root = root) + pkg_path = os.path.join(base, portage_cpv) + catdir = os.path.dirname(pkg_path) + t = time.time() + t = (t, t) + for x in (pkg_path, catdir, base): + try: + os.utime(x, t) + except OSError as err: + sys.stderr.write("Cannot update %s mtime, %s\n" % ( + x, repr(err),)) def __splitdebug_update_contents_file(self, contents_path, splitdebug_dirs):