summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-06-09 13:55:06 +0000
committerZac Medico <zmedico@gentoo.org>2008-06-09 13:55:06 +0000
commit0c8fc90cb2f0101f60a78953668b391e44d3cdca (patch)
treee1420607f8c3ac05f28f7bb05714aa825566658f /bin
parentWhen inside fakeroot, directories with portage's gid appear (diff)
downloadportage-multirepo-0c8fc90cb2f0101f60a78953668b391e44d3cdca.tar.gz
portage-multirepo-0c8fc90cb2f0101f60a78953668b391e44d3cdca.tar.bz2
portage-multirepo-0c8fc90cb2f0101f60a78953668b391e44d3cdca.zip
Add CONTENTS indexing support for optimization of owner lookups. The
vardbapi cache maintains a hash table (inside vdb_metadata.pickle) that serves to index package contents by mapping the basename of file to a list of possible packages that own it. This is used to optimize owner lookups by narrowing the search down to a smaller number of packages. It increases the size of vdb_metadata.pickle by approximately 30% and it's used in the following cases: * When an unexpected file collision occurs (whether or not collision-protect is enabled) * `emerge <filename>` * `portageq owners` The svn path=/main/trunk/; revision=10609
Diffstat (limited to 'bin')
-rwxr-xr-xbin/portageq35
1 files changed, 15 insertions, 20 deletions
diff --git a/bin/portageq b/bin/portageq
index c3fe8b37..fe5260bc 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -188,26 +188,21 @@ def owners(argv):
return 2
files.append(f[len(root):])
- found_owner = False
- for cpv in vardb.cpv_all():
- cat, pkg = catsplit(cpv)
- mylink = dblink(cat, pkg, root, settings, vartree=vardb.vartree)
- myfiles = []
- for f in files:
- if mylink.isowner(f, root):
- myfiles.append(f)
- if myfiles:
- found_owner = True
- sys.stdout.write("%s\n" % cpv)
- for f in myfiles:
- sys.stdout.write("\t%s\n" % \
- os.path.join(root, f.lstrip(os.path.sep)))
- sys.stdout.flush()
- if not found_owner:
- sys.stderr.write("None of the installed packages claim the file(s).\n")
- sys.stderr.flush()
- return 1
- return 0
+ owners = vardb._owners.get_owners(files)
+
+ for pkg, owned_files in owners.iteritems():
+ cpv = pkg.mycpv
+ sys.stdout.write("%s\n" % cpv)
+ for f in sorted(owned_files):
+ sys.stdout.write("\t%s\n" % \
+ os.path.join(root, f.lstrip(os.path.sep)))
+ if owners:
+ sys.stdout.flush()
+ return 0
+
+ sys.stderr.write("None of the installed packages claim the file(s).\n")
+ sys.stderr.flush()
+ return 1
owners.uses_root = True