in world since system atoms can only match one slot while world atoms can
be greedy with respect to slots. Unslotted system packages will not be
stored in world."""
- arg_atom = args_set.findAtomForPackage(pkg_key, metadata)
+ pkg = Package(cpv=pkg_key, metadata=metadata)
+ arg_atom = args_set.findAtomForPackage(pkg)
if not arg_atom:
return None
cp = portage.dep_getkey(arg_atom)
if len(matched_slots) == 1:
new_world_atom = slot_atom
- if new_world_atom == sets["world"].findAtomForPackage(pkg_key, metadata):
+ if new_world_atom == sets["world"].findAtomForPackage(pkg):
# Both atoms would be identical, so there's nothing to add.
return None
if not slotted:
# Unlike world atoms, system atoms are not greedy for slots, so they
# can't be safely excluded from world if they are slotted.
- system_atom = sets["system"].findAtomForPackage(pkg_key, metadata)
+ system_atom = sets["system"].findAtomForPackage(pkg)
if system_atom:
if not portage.dep_getkey(system_atom).startswith("virtual/"):
return None
pkg_system = False
pkg_world = False
try:
- pkg_system = system_set.findAtomForPackage(pkg_key, metadata)
- pkg_world = world_set.findAtomForPackage(pkg_key, metadata)
+ pkg_system = system_set.findAtomForPackage(pkg)
+ pkg_world = world_set.findAtomForPackage(pkg)
if not (oneshot or pkg_world) and \
myroot == self.target_root and \
- favorites_set.findAtomForPackage(pkg_key, metadata):
+ favorites_set.findAtomForPackage(pkg):
# Maybe it will be added to world now.
if create_world_atom(pkg_key, metadata,
favorites_set, root_config):
#buildsyspkg: Check if we need to _force_ binary package creation
issyspkg = ("buildsyspkg" in myfeat) \
and x[0] != "blocks" \
- and system_set.findAtomForPackage(pkg_key, metadata) \
+ and system_set.findAtomForPackage(pkg) \
and "--buildpkg" not in self.myopts
if x[0] in ["ebuild","blocks"]:
if x[0] == "blocks" and "--fetchonly" not in self.myopts:
#need to check for errors
if not buildpkgonly:
if not (fetchonly or oneshot or pretend) and \
- args_set.findAtomForPackage(pkg_key, metadata):
+ args_set.findAtomForPackage(pkg):
world_set.lock()
world_set.load() # maybe it's changed on disk
myfavkey = create_world_atom(pkg_key, metadata,
# to remove those.
filtered_pkgs = []
for pkg in pkgs:
- metadata = dict(izip(metadata_keys,
- vardb.aux_get(pkg, metadata_keys)))
arg_atom = None
try:
- arg_atom = args_set.findAtomForPackage(pkg, metadata)
+ arg_atom = args_set.findAtomForPackage(
+ pkg_cache[("installed", myroot, pkg, "nomerge")])
except portage.exception.InvalidDependString, e:
file_path = os.path.join(
myroot, portage.VDB_PATH, pkg, "PROVIDE")
if action == "depclean":
if myfiles:
for pkg in vardb.cpv_all():
- metadata = dict(izip(metadata_keys,
- vardb.aux_get(pkg, metadata_keys)))
arg_atom = None
try:
- arg_atom = args_set.findAtomForPackage(pkg, metadata)
+ arg_atom = args_set.findAtomForPackage(
+ pkg_cache[("installed", myroot, pkg, "nomerge")])
except portage.exception.InvalidDependString:
# this error has already been displayed by now
continue
self._atommap[cp].add(a)
# Not sure if this one should really be in PackageSet
- def findAtomForPackage(self, cpv, metadata):
+ def findAtomForPackage(self, pkg):
"""Return the best match for a given package from the arguments, or
None if there are no matches. This matches virtual arguments against
the PROVIDE metadata. This can raise an InvalidDependString exception
if an error occurs while parsing PROVIDE."""
- cpv_slot = "%s:%s" % (cpv, metadata["SLOT"])
- cp = dep_getkey(cpv)
- self._load() # make sure the atoms are loaded
- atoms = self._atommap.get(cp)
- if atoms:
- best_match = best_match_to_list(cpv_slot, atoms)
- if best_match:
- return best_match
- if not metadata["PROVIDE"]:
+ atoms = list(self.iterAtomsForPackage(pkg))
+ if not atoms:
return None
- provides = flatten(use_reduce(paren_reduce(metadata["PROVIDE"]),
- uselist=metadata["USE"].split()))
- for provide in provides:
- provided_cp = dep_getkey(provide)
- atoms = self._atommap.get(provided_cp)
- if atoms:
- atoms = list(atoms)
- transformed_atoms = [atom.replace(provided_cp, cp) for atom in atoms]
- best_match = best_match_to_list(cpv_slot, transformed_atoms)
- if best_match:
- return atoms[transformed_atoms.index(best_match)]
- return None
+ return best_match_to_list(pkg.cpv_slot, atoms)
def iterAtomsForPackage(self, pkg):
"""