summaryrefslogtreecommitdiffstats
path: root/pym/portage/dbapi/vartree.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-03-02 10:51:41 -0800
committerZac Medico <zmedico@gentoo.org>2011-03-14 09:03:31 -0700
commitefd2f0cc74a743fcc15f95ff5edae817c341cc49 (patch)
tree6e5636e619bb93466daa02bd9df0c78161443851 /pym/portage/dbapi/vartree.py
parentb0115fb837bf197c64bb686ba6cf94aa52465379 (diff)
downloadportage-efd2f0cc74a743fcc15f95ff5edae817c341cc49.tar.gz
portage-efd2f0cc74a743fcc15f95ff5edae817c341cc49.tar.bz2
portage-efd2f0cc74a743fcc15f95ff5edae817c341cc49.zip
dblink.getcontents(): generate parent directories
We can't necessarily assume that they are explicitly listed in CONTENTS, and they are crucial for callers such as dblink.isowner().
Diffstat (limited to 'pym/portage/dbapi/vartree.py')
-rw-r--r--pym/portage/dbapi/vartree.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 3bc30affd..52f0fbaa2 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -1403,6 +1403,9 @@ class dblink(object):
myroot = self.settings['ROOT']
if myroot == os.path.sep:
myroot = None
+ # used to generate parent dir entries
+ dir_entry = (_unicode_decode("dir"),)
+ eroot_split_len = len(self.settings["EROOT"].split(os.sep)) - 1
pos = 0
errors = []
for pos, line in enumerate(mylines):
@@ -1447,6 +1450,19 @@ class dblink(object):
if myroot is not None:
path = os.path.join(myroot, path.lstrip(os.path.sep))
+ # Implicitly add parent directories, since we can't necessarily
+ # assume that they are explicitly listed in CONTENTS, and it's
+ # useful for callers if they can rely on parent directory entries
+ # being generated here (crucial for things like dblink.isowner()).
+ path_split = path.split(os.sep)
+ path_split.pop()
+ while len(path_split) > eroot_split_len:
+ parent = os.sep.join(path_split)
+ if parent in pkgfiles:
+ break
+ pkgfiles[parent] = dir_entry
+ path_split.pop()
+
pkgfiles[path] = data
if errors: