quickpkg: Support extended atoms
authorSebastian Luther <SebastianLuther@gmx.de>
Thu, 13 Oct 2011 13:03:34 +0000 (15:03 +0200)
committerZac Medico <zmedico@gentoo.org>
Thu, 13 Oct 2011 15:07:39 +0000 (08:07 -0700)
bin/quickpkg

index 09723f5c8a1f6b438b3a7e1d500d24584121c1b5..c95a58423f6d36357cfe1f43feb95d65cbaa8c4a 100755 (executable)
@@ -21,7 +21,7 @@ except ImportError:
 from portage import os
 from portage import xpak
 from portage.dbapi.dep_expand import dep_expand
-from portage.dep import use_reduce
+from portage.dep import Atom, extended_cp_match, use_reduce
 from portage.exception import InvalidAtom, InvalidData, InvalidDependString, \
        PackageSetNotFound, PermissionDenied
 from portage.util import ConfigProtect, ensure_dirs, shlex_split
@@ -187,6 +187,42 @@ def quickpkg_set(options, infos, arg, eout):
        for atom in atoms:
                quickpkg_atom(options, infos, atom, eout)
 
+
+def quickpkg_extended_atom(options, infos, arg, eout):
+       root = portage.settings["ROOT"]
+       trees = portage.db[root]
+       vartree = trees["vartree"]
+       vardb = vartree.dbapi
+
+       try:
+               atom = Atom(arg, allow_wildcard=True, allow_repo=True)
+       except (InvalidAtom, InvalidData):
+               eout.eerror("Invalid atom: %s" % (arg,))
+               infos["missing"].append(arg)
+               return
+
+       require_metadata = atom.slot or atom.repo
+       atoms = []
+       for cpv in vardb.cpv_all():
+               cpv_atom = Atom("=%s" % cpv)
+               if not extended_cp_match(atom.cp, cpv_atom.cp):
+                       continue
+
+               if require_metadata:
+                       slot, repo = vardb.aux_get(cpv, ["SLOT", "repository"])
+
+                       if atom.slot and atom.slot != slot:
+                               continue
+
+                       if atom.repo and atom.repo != repo:
+                               continue
+
+               atoms.append(cpv_atom)
+
+       for atom in atoms:
+               quickpkg_atom(options, infos, atom, eout)
+
+
 def quickpkg_main(options, args, eout):
        root = portage.settings["ROOT"]
        trees = portage.db[root]
@@ -207,6 +243,8 @@ def quickpkg_main(options, args, eout):
        for arg in args:
                if arg[0] == SETPREFIX:
                        quickpkg_set(options, infos, arg, eout)
+               elif '*' in arg:
+                       quickpkg_extended_atom(options, infos, arg, eout)
                else:
                        quickpkg_atom(options, infos, arg, eout)