diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-12-21 11:51:27 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-12-21 11:51:27 +0000 |
commit | 52f24ac493579463399f836f464c530495f1650f (patch) | |
tree | 7a6927c2f401a195299d0f3c586c24092a1bc08a /bin | |
parent | 4cd6d27a197e66193fc81f4952b6df6a081fc513 (diff) | |
download | portage-52f24ac493579463399f836f464c530495f1650f.tar.gz portage-52f24ac493579463399f836f464c530495f1650f.tar.bz2 portage-52f24ac493579463399f836f464c530495f1650f.zip |
Enhance the portageq match command to list all installed packages
when given an empty string. (trunk r9032:9034)
svn path=/main/branches/2.1.2/; revision=9036
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/portageq | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/bin/portageq b/bin/portageq index b097889ae..8ffac0b75 100755 --- a/bin/portageq +++ b/bin/portageq @@ -239,17 +239,22 @@ all_best_visible.uses_root = True def match(argv): - """<root> <category/package> - Returns \n seperated list of category/package-version + """<root> <atom> + Returns a \\n separated list of category/package-version. + When given an empty string, all installed packages will + be listed. """ - if (len(argv) < 2): - print "ERROR: insufficient parameters!" + if len(argv) != 2: + print "ERROR: expected 2 parameters, got %d!" % len(argv) sys.exit(2) - try: - print "\n".join(portage.db[argv[0]]["vartree"].dbapi.match(argv[1])) - except KeyError, e: - portage.writemsg("%s\n" % str(e), noiselevel=-1) - sys.exit(1) + root, atom = argv + if atom: + results = portage.db[root]["vartree"].dbapi.match(atom) + else: + results = portage.db[root]["vartree"].dbapi.cpv_all() + results.sort() + for cpv in results: + print cpv match.uses_root = True |