summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-05-25 08:45:34 +0000
committerZac Medico <zmedico@gentoo.org>2008-05-25 08:45:34 +0000
commite6065abf1b1c07f78cf93cb6cde7fd7d4ec15dad (patch)
tree143de7df4616bf00a083866ac30634cebdcfc00d
parentdbc01eb720e8fcddf5fb38cde54ca4fc41790a92 (diff)
downloadportage-e6065abf1b1c07f78cf93cb6cde7fd7d4ec15dad.tar.gz
portage-e6065abf1b1c07f78cf93cb6cde7fd7d4ec15dad.tar.bz2
portage-e6065abf1b1c07f78cf93cb6cde7fd7d4ec15dad.zip
* Fix PackageSet.findAtomForPackage() to take a Package instance as
an argument. * Simplify PackageSet.findAtomForPackage() by implementing it on top of iterAtomsForPackage(). svn path=/main/trunk/; revision=10415
-rw-r--r--pym/_emerge/__init__.py27
-rw-r--r--pym/portage/sets/base.py26
2 files changed, 17 insertions, 36 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index 155f5ea6d..2616c1be7 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -741,7 +741,8 @@ def create_world_atom(pkg_key, metadata, args_set, root_config):
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)
@@ -797,13 +798,13 @@ def create_world_atom(pkg_key, metadata, args_set, root_config):
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
@@ -4788,11 +4789,11 @@ class depgraph(object):
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):
@@ -5843,7 +5844,7 @@ class MergeTask(object):
#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:
@@ -6048,7 +6049,7 @@ class MergeTask(object):
#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,
@@ -7864,11 +7865,10 @@ def action_depclean(settings, trees, ldpath_mtimes,
# 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")
@@ -7977,11 +7977,10 @@ def action_depclean(settings, trees, ldpath_mtimes,
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
diff --git a/pym/portage/sets/base.py b/pym/portage/sets/base.py
index e88aca26e..ac77e95c3 100644
--- a/pym/portage/sets/base.py
+++ b/pym/portage/sets/base.py
@@ -100,33 +100,15 @@ class PackageSet(object):
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):
"""