From: Fabian Groffen Date: Sat, 22 Dec 2007 13:31:17 +0000 (-0000) Subject: Merged from trunk 9029:9038 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=266c47ebf71b8b8cbf5f7d977a40a5cf798f60bf;p=portage.git Merged from trunk 9029:9038 | 9031 | Make vardbapi cache DESCRIPTION and HOMEPAGE in order to | | zmedico | optimize emerge --searchdesc. | | 9033 | Enhance the portageq match command to list all installed | | zmedico | packages when given an empty string. | | 9034 | Typo: remove bogus argument. | | zmedico | | | 9035 | Implement a `portageq contents ` command that lists all the | | zmedico | files that are installed for a given package, with one file | | | listed on each line. | | 9038 | Add support for --usepkg and --usepkgonly options together | | zmedico | with emerge --search. | svn path=/main/branches/prefix/; revision=9042 --- diff --git a/bin/portageq b/bin/portageq index eec63a504..a0e8f11de 100755 --- a/bin/portageq +++ b/bin/portageq @@ -123,6 +123,31 @@ def metadata(argv): metadata.uses_root = True +def contents(argv): + """ + List the files that are installed for a given package, with + one file listed on each line. All file names will begin with + . + """ + if len(argv) != 2: + print "ERROR: expected 2 parameters, got %d!" % len(argv) + return 2 + + root, cpv = argv + vartree = portage.db[root]["vartree"] + if not vartree.dbapi.cpv_exists(cpv): + sys.stderr.write("Package not found: '%s'\n" % cpv) + return 1 + cat, pkg = portage.catsplit(cpv) + db = portage.dblink(cat, pkg, root, vartree.settings, + treetype="vartree", vartree=vartree) + file_list = db.getcontents().keys() + file_list.sort() + for f in file_list: + sys.stdout.write("%s\n" % f) + sys.stdout.flush() +contents.uses_root = True + def owners(argv): """ []+ Given a list of files, print the packages that own the files and which @@ -238,17 +263,22 @@ all_best_visible.uses_root = True def match(argv): - """ - Returns \n seperated list of category/package-version + """ + 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 diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index b53a0764f..4b8e43967 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -399,7 +399,7 @@ class search(object): # public interface # def __init__(self, root_config, spinner, searchdesc, - verbose): + verbose, usepkg, usepkgonly): """Searches the available and installed packages for the supplied search key. The list of available and installed packages is created at object instantiation. This makes successive searches faster.""" @@ -423,10 +423,10 @@ class search(object): bindb = root_config.trees["bintree"].dbapi vardb = root_config.trees["vartree"].dbapi - if portdb._have_root_eclass_dir: + if not usepkgonly and portdb._have_root_eclass_dir: self._dbs.append(portdb) - if bindb.cp_all(): + if (usepkg or usepkgonly) and bindb.cp_all(): self._dbs.append(bindb) self._dbs.append(vardb) @@ -6192,7 +6192,8 @@ def action_search(root_config, myopts, myfiles, spinner): else: searchinstance = search(root_config, spinner, "--searchdesc" in myopts, - "--quiet" not in myopts) + "--quiet" not in myopts, "--usepkg" in myopts, + "--usepkgonly" in myopts) for mysearch in myfiles: try: searchinstance.execute(mysearch) diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index b2610b327..5bd1bbf7e 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -189,7 +189,8 @@ class vardbapi(dbapi): vartree = db[root]["vartree"] self.vartree = vartree self._aux_cache_keys = set( - ["CHOST", "COUNTER", "DEPEND", "EAPI", "IUSE", "KEYWORDS", + ["CHOST", "COUNTER", "DEPEND", "DESCRIPTION", + "EAPI", "HOMEPAGE", "IUSE", "KEYWORDS", "LICENSE", "PDEPEND", "PROVIDE", "RDEPEND", "NEEDED", "repository", "RESTRICT" , "SLOT", "USE"]) self._aux_cache = None