summaryrefslogtreecommitdiffstats
path: root/bin/portageq
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-06-24 07:12:40 +0000
committerZac Medico <zmedico@gentoo.org>2009-06-24 07:12:40 +0000
commit22eaa08ddeaf387d1b742af3b05cc39624f593c6 (patch)
tree81f0c391e319956627b2cac5ff5ae6a1ad5a0179 /bin/portageq
parent463b82e15e317cd210b78886a319fbdee8981a63 (diff)
downloadportage-22eaa08ddeaf387d1b742af3b05cc39624f593c6.tar.gz
portage-22eaa08ddeaf387d1b742af3b05cc39624f593c6.tar.bz2
portage-22eaa08ddeaf387d1b742af3b05cc39624f593c6.zip
Add support to `portageq owners` for querying paths matching a given basename.
It is natural to support this since the vartree already maintains a basename -> owner index anyway. There are plans for the packagekit backend is to support this type of search. svn path=/main/trunk/; revision=13681
Diffstat (limited to 'bin/portageq')
-rwxr-xr-xbin/portageq14
1 files changed, 9 insertions, 5 deletions
diff --git a/bin/portageq b/bin/portageq
index 89d5b6444..c21c783c1 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -161,8 +161,8 @@ def owners(argv):
Given a list of files, print the packages that own the files and which
files belong to each package. Files owned by a package are listed on
the lines below it, indented by a single tab character (\\t). All file
- paths must start with <root>. Returns 1 if no owners could be found,
- and 0 otherwise.
+ paths must either start with <root> or be a basename alone.
+ Returns 1 if no owners could be found, and 0 otherwise.
"""
if len(argv) < 2:
sys.stderr.write("ERROR: insufficient parameters!\n")
@@ -183,18 +183,22 @@ def owners(argv):
files = []
for f in argv[1:]:
f = portage.normalize_path(f)
- if not f.startswith(os.path.sep):
+ is_basename = os.sep not in f
+ if not is_basename and f[:1] != os.sep:
if cwd is None:
sys.stderr.write("ERROR: cwd does not exist!\n")
sys.stderr.flush()
return 2
f = os.path.join(cwd, f)
f = portage.normalize_path(f)
- if not f.startswith(root):
+ if not is_basename and not f.startswith(root):
sys.stderr.write("ERROR: file paths must begin with <root>!\n")
sys.stderr.flush()
return 2
- files.append(f[len(root):])
+ if is_basename:
+ files.append(f)
+ else:
+ files.append(f[len(root):])
owners = vardb._owners.get_owners(files)