Merged from trunk 9029:9038
authorFabian Groffen <grobian@gentoo.org>
Sat, 22 Dec 2007 13:31:17 +0000 (13:31 -0000)
committerFabian Groffen <grobian@gentoo.org>
Sat, 22 Dec 2007 13:31:17 +0000 (13:31 -0000)
   | 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

bin/portageq
pym/_emerge/__init__.py
pym/portage/dbapi/vartree.py

index eec63a50463d61c24ee73ce8934ddc32527337a6..a0e8f11dea8bb690ede39a04901f3b262402cea9 100755 (executable)
@@ -123,6 +123,31 @@ def metadata(argv):
 
 metadata.uses_root = True
 
+def contents(argv):
+       """<root> <category/package>
+       List the files that are installed for a given package, with
+       one file listed on each line. All file names will begin with
+       <root>.
+       """
+       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):
        """<root> [<filename>]+
        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):
-       """<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
 
 
index b53a0764f13210f1d199a0d60768874560fc0ce7..4b8e4396782f61f6c4a5dead03434ac585528113 100644 (file)
@@ -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)
index b2610b327007c0a3953f1e7b80ed887c8580a806..5bd1bbf7efcc1152bdb735cf10b8079ae47e1f43 100644 (file)
@@ -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