Fix to find all packages including installed but no longer in tree. #71737
authorfuzzyray <fuzzyray@gentoo.org>
Thu, 13 Oct 2005 05:03:29 +0000 (05:03 -0000)
committerfuzzyray <fuzzyray@gentoo.org>
Thu, 13 Oct 2005 05:03:29 +0000 (05:03 -0000)
svn path=/; revision=243

trunk/src/gentoolkit/helpers.py

index 98c9b3703882b0913a15b58197752f53d5a900c3..12ab96fb57ac2a3fe7c6550b467250e3db8a1944 100644 (file)
 import portage
 from gentoolkit import *
 from gentoolkit.package import *
+from portage_util import unique_array
 
 def find_packages(search_key, masked=False):
        """Returns a list of Package objects that matched the search key."""
        try:
                if masked:
-                       t = portage.portdb.xmatch("match-all", search_key)
+                       t = portage.db["/"]["porttree"].dbapi.xmatch("match-all", search_key)
+                       t += portage.db["/"]["vartree"].dbapi.match(search_key)
                else:
-                       t = portage.portdb.match(search_key)
+                       t = portage.db["/"]["porttree"].dbapi.match(search_key)
+                       t += portage.db["/"]["vartree"].dbapi.match(search_key)
        # catch the "amgigous package" Exception
        except ValueError, e:
                if type(e[0]) == types.ListType:
                        t = []
                        for cp in e[0]:
                                if masked:
-                                       t += portage.portdb.xmatch("match-all", cp)
+                                       t += portage.db["/"]["porttree"].dbapi.xmatch("match-all", cp)
+                                       t += portage.db["/"]["vartree"].dbapi.match(cp)
                                else:
-                                       t += portage.portdb.match(cp)
+                                       t += portage.db["/"]["porttree"].dbapi.match(cp)
+                                       t += portage.db["/"]["vartree"].dbapi.match(cp)
                else:
                        raise ValueError(e)
+       # Make the list of packages unique
+       t = unique_array(t)
+       t.sort()
        return [Package(x) for x in t]
 
 def find_installed_packages(search_key, masked=False):
@@ -108,12 +116,16 @@ def find_all_uninstalled_packages(prefilter=None):
 def find_all_packages(prefilter=None):
        """Returns a list of all known packages, installed or not, after applying
        the prefilter function"""
-       t = portage.portdb.cp_all()
+       t = porttree.dbapi.cp_all()
+       t += vartree.dbapi.cp_all()
        if prefilter:
                t = filter(prefilter,t)
+       t = unique_array(t)
        t2 = []
        for x in t:
-               t2 += portage.portdb.cp_list(x)
+               t2 += porttree.dbapi.cp_list(x)
+               t2 += vartree.dbapi.cp_list(x)
+               t2 = unique_array(t2)
        return [Package(x) for x in t2]
 
 def split_package_name(name):