summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/_emerge/Blocker.py2
-rw-r--r--pym/_emerge/FakeVartree.py3
-rw-r--r--pym/_emerge/actions.py3
-rw-r--r--pym/_emerge/depgraph.py26
-rw-r--r--pym/portage/__init__.py95
-rw-r--r--pym/portage/dbapi/porttree.py3
-rw-r--r--pym/portage/dep.py10
-rw-r--r--pym/portage/sets/base.py5
8 files changed, 79 insertions, 68 deletions
diff --git a/pym/_emerge/Blocker.py b/pym/_emerge/Blocker.py
index 85462812f..5e34e5249 100644
--- a/pym/_emerge/Blocker.py
+++ b/pym/_emerge/Blocker.py
@@ -17,7 +17,7 @@ class Blocker(Task):
def __init__(self, **kwargs):
Task.__init__(self, **kwargs)
- self.cp = portage.dep_getkey(self.atom)
+ self.cp = self.atom.cp
def _get_hash_key(self):
hash_key = getattr(self, "_hash_key", None)
diff --git a/pym/_emerge/FakeVartree.py b/pym/_emerge/FakeVartree.py
index 25bed2905..e895cc86b 100644
--- a/pym/_emerge/FakeVartree.py
+++ b/pym/_emerge/FakeVartree.py
@@ -76,8 +76,7 @@ class FakeVartree(portage.vartree):
portage.locks.unlockdir(vdb_lock)
# Populate the old-style virtuals using the cached values.
if not self.settings.treeVirtuals:
- self.settings.treeVirtuals = portage.util.map_dictlist_vals(
- portage.getCPFromCPV, self.get_all_provides())
+ self.settings._populate_treeVirtuals(self)
# Intialize variables needed for lazy cache pulls of the live ebuild
# metadata. This ensures that the vardb lock is released ASAP, without
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index f8c511a66..e1f7ffe19 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -2629,8 +2629,7 @@ def display_news_notification(root_config, myopts):
if not settings.treeVirtuals:
# Populate these using our existing vartree, to avoid
# having a temporary one instantiated.
- settings.treeVirtuals = portage.util.map_dictlist_vals(
- portage.getCPFromCPV, trees["vartree"].get_all_provides())
+ settings._populate_treeVirtuals(trees["vartree"])
for repo in portdb.getRepositories():
unreadItems = checkUpdatedNewsItems(
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index d52d5ac6a..5b03dc3a2 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -1149,9 +1149,6 @@ class depgraph(object):
for atom in selected_atoms[pkg]:
try:
-
- atom = portage.dep.Atom(atom)
-
mypriority = dep_priority.copy()
if not atom.blocker and vardb.match(atom):
mypriority.satisfied = True
@@ -1306,16 +1303,15 @@ class depgraph(object):
atom_arg_map = self._dynamic_config._atom_arg_map
root_config = self._frozen_config.roots[pkg.root]
for atom in self._dynamic_config._set_atoms.iterAtomsForPackage(pkg):
- atom_cp = portage.dep_getkey(atom)
- if atom_cp != pkg.cp and \
- self._have_new_virt(pkg.root, atom_cp):
+ if atom.cp != pkg.cp and \
+ self._have_new_virt(pkg.root, atom.cp):
continue
visible_pkgs = \
self._dynamic_config._visible_pkgs[pkg.root].match_pkgs(atom)
visible_pkgs.reverse() # descending order
higher_slot = None
for visible_pkg in visible_pkgs:
- if visible_pkg.cp != atom_cp:
+ if visible_pkg.cp != atom.cp:
continue
if pkg >= visible_pkg:
# This is descending order, and we're not
@@ -1606,9 +1602,8 @@ class depgraph(object):
self._spinner_update()
dep = Dependency(atom=atom, onlydeps=onlydeps,
root=myroot, parent=arg)
- atom_cp = portage.dep_getkey(atom)
try:
- pprovided = pprovideddict.get(portage.dep_getkey(atom))
+ pprovided = pprovideddict.get(atom.cp)
if pprovided and portage.match_from_list(atom, pprovided):
# A provided package has been specified on the command line.
self._dynamic_config._pprovided_args.append((arg, atom))
@@ -1651,10 +1646,10 @@ class depgraph(object):
return 0, myfavorites
self._dynamic_config._missing_args.append((arg, atom))
continue
- if atom_cp != pkg.cp:
+ if atom.cp != pkg.cp:
# For old-style virtuals, we need to repeat the
# package.provided check against the selected package.
- expanded_atom = atom.replace(atom_cp, pkg.cp)
+ expanded_atom = atom.replace(atom.cp, pkg.cp)
pprovided = pprovideddict.get(pkg.cp)
if pprovided and \
portage.match_from_list(expanded_atom, pprovided):
@@ -2396,7 +2391,7 @@ class depgraph(object):
# Filter out any old-style virtual matches if they are
# mixed with new-style virtual matches.
- cp = portage.dep_getkey(atom)
+ cp = atom.cp
if len(matched_packages) > 1 and \
"virtual" == portage.catsplit(cp)[0]:
for pkg in matched_packages:
@@ -2737,8 +2732,8 @@ class depgraph(object):
for provider_entry in virtuals[blocker.cp]:
provider_cp = \
portage.dep_getkey(provider_entry)
- atoms.append(blocker.atom.replace(
- blocker.cp, provider_cp))
+ atoms.append(Atom(blocker.atom.replace(
+ blocker.cp, provider_cp)))
else:
atoms = [blocker.atom]
@@ -4896,7 +4891,6 @@ class _dep_check_composite_db(portage.dbapi):
# any matching slots in the graph db.
slots = set()
slots.add(pkg.metadata["SLOT"])
- atom_cp = portage.dep_getkey(atom)
if pkg.cp.startswith("virtual/"):
# For new-style virtual lookahead that occurs inside
# dep_check(), examine all slots. This is needed
@@ -4917,7 +4911,7 @@ class _dep_check_composite_db(portage.dbapi):
ret.append(pkg.cpv)
slots.remove(pkg.metadata["SLOT"])
while slots:
- slot_atom = "%s:%s" % (atom_cp, slots.pop())
+ slot_atom = Atom("%s:%s" % (atom.cp, slots.pop()))
pkg, existing = self._depgraph._select_package(
self._root, slot_atom)
if not pkg:
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 562ba10e3..3ea8b3b72 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -3249,7 +3249,6 @@ class config(object):
# an incremental!
myincrementals.remove("USE")
-
mydbs = self.configlist[:-1]
mydbs.append(self.backupenv)
@@ -3496,12 +3495,21 @@ class config(object):
if self.local_config and not self.treeVirtuals:
temp_vartree = vartree(myroot, None,
categories=self.categories, settings=self)
- # Reduce the provides into a list by CP.
- self.treeVirtuals = map_dictlist_vals(getCPFromCPV,temp_vartree.get_all_provides())
+ self._populate_treeVirtuals(temp_vartree)
self.virtuals = self.__getvirtuals_compile()
return self.virtuals
+ def _populate_treeVirtuals(self, vartree):
+ """Reduce the provides into a list by CP."""
+ for provide, cpv_list in vartree.get_all_provides().iteritems():
+ try:
+ provide = dep.Atom(provide)
+ except exception.InvalidAtom:
+ continue
+ self.treeVirtuals[provide.cp] = \
+ [dep.Atom(cpv_getkey(cpv)) for cpv in cpv_list]
+
def __getvirtuals_compile(self):
"""Stack installed and profile virtuals. Preference for virtuals
decreases from left to right.
@@ -6903,7 +6911,6 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
# so do not check them again.
checkme = []
-
if not emerge_skip_distfiles and \
need_distfiles and not fetch(
fetchme, mysettings, listonly=listonly, fetchonly=fetchonly):
@@ -7386,10 +7393,6 @@ def unmerge(cat, pkg, myroot, mysettings, mytrimworld=1, vartree=None,
vartree.dbapi.linkmap._clear_cache()
mylink.unlockdb()
-def getCPFromCPV(mycpv):
- """Calls pkgsplit on a cpv and returns only the cp."""
- return pkgsplit(mycpv)[0]
-
def dep_virtual(mysplit, mysettings):
"Does virtual dependency conversion"
newsplit=[]
@@ -7494,15 +7497,14 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
evaluated_atom += str(x.use.evaluate_conditionals(myuse))
x = portage.dep.Atom(evaluated_atom)
- mykey = dep_getkey(x)
+ mykey = x.cp
if not mykey.startswith("virtual/"):
newsplit.append(x)
if atom_graph is not None:
atom_graph.add(x, graph_parent)
continue
mychoices = myvirtuals.get(mykey, [])
- isblocker = x.startswith("!")
- if isblocker:
+ if x.blocker:
# Virtual blockers are no longer expanded here since
# the un-expanded virtual atom is more useful for
# maintaining a cache of blocker atoms.
@@ -7518,7 +7520,7 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
# TODO: Add PROVIDE check for repoman.
a = []
for y in mychoices:
- a.append(portage.dep.Atom(x.replace(mykey, str(y.cp), 1)))
+ a.append(dep.Atom(x.replace(x.cp, y.cp, 1)))
if not a:
newsplit.append(x)
elif len(a) == 1:
@@ -7592,8 +7594,7 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
# Plain old-style virtuals. New-style virtuals are preferred.
if not pkgs:
for y in mychoices:
- new_atom = portage.dep.Atom(
- x.replace(mykey, dep_getkey(y), 1))
+ new_atom = dep.Atom(x.replace(x.cp, y.cp, 1))
matches = portdb.match(new_atom)
# portdb is an instance of depgraph._dep_check_composite_db, so
# USE conditionals are already evaluated.
@@ -7606,7 +7607,7 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
if not a and mychoices:
# Check for a virtual package.provided match.
for y in mychoices:
- new_atom = portage.dep.Atom(x.replace(mykey, dep_getkey(y), 1))
+ new_atom = dep.Atom(x.replace(x.cp, y.cp, 1))
if match_from_list(new_atom,
pprovideddict.get(new_atom.cp, [])):
a.append(new_atom)
@@ -7662,12 +7663,12 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
if unreduced[0] != "||":
unresolved = []
- for dep, satisfied in izip(unreduced, reduced):
- if isinstance(dep, list):
- unresolved += dep_zapdeps(dep, satisfied, myroot,
+ for x, satisfied in izip(unreduced, reduced):
+ if isinstance(x, list):
+ unresolved += dep_zapdeps(x, satisfied, myroot,
use_binaries=use_binaries, trees=trees)
elif not satisfied:
- unresolved.append(dep)
+ unresolved.append(x)
return unresolved
# We're at a ( || atom ... ) type level and need to make a choice
@@ -7704,12 +7705,12 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
# Sort the deps into installed, not installed but already
# in the graph and other, not installed and not in the graph
# and other, with values of [[required_atom], availablility]
- for dep, satisfied in izip(deps, satisfieds):
- if isinstance(dep, list):
- atoms = dep_zapdeps(dep, satisfied, myroot,
+ for x, satisfied in izip(deps, satisfieds):
+ if isinstance(x, list):
+ atoms = dep_zapdeps(x, satisfied, myroot,
use_binaries=use_binaries, trees=trees)
else:
- atoms = [dep]
+ atoms = [x]
if not vardb:
# called by repoman
other.append((atoms, None, False))
@@ -7719,15 +7720,15 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
all_use_satisfied = True
versions = {}
for atom in atoms:
- if atom[:1] == "!":
+ if atom.blocker:
continue
# Ignore USE dependencies here since we don't want USE
# settings to adversely affect || preference evaluation.
avail_pkg = mydbapi.match(atom.without_use)
if avail_pkg:
avail_pkg = avail_pkg[-1] # highest (ascending order)
- avail_slot = "%s:%s" % (dep_getkey(atom),
- mydbapi.aux_get(avail_pkg, ["SLOT"])[0])
+ avail_slot = dep.Atom("%s:%s" % (atom.cp,
+ mydbapi.aux_get(avail_pkg, ["SLOT"])[0]))
if not avail_pkg:
all_available = False
all_use_satisfied = False
@@ -7742,8 +7743,8 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
avail_pkg_use = avail_pkg_use[-1]
if avail_pkg_use != avail_pkg:
avail_pkg = avail_pkg_use
- avail_slot = "%s:%s" % (dep_getkey(atom),
- mydbapi.aux_get(avail_pkg, ["SLOT"])[0])
+ avail_slot = dep.Atom("%s:%s" % (atom.cp,
+ mydbapi.aux_get(avail_pkg, ["SLOT"])[0]))
versions[avail_slot] = avail_pkg
@@ -7753,8 +7754,8 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
# If any version of a package is already in the graph then we
# assume that it is preferred over other possible packages choices.
all_installed = True
- for atom in set([dep_getkey(atom) for atom in atoms \
- if atom[:1] != "!"]):
+ for atom in set(dep.Atom(atom.cp) for atom in atoms \
+ if not atom.blocker):
# New-style virtuals have zero cost to install.
if not vardb.match(atom) and not atom.startswith("virtual/"):
all_installed = False
@@ -7802,13 +7803,13 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
# installed package.
cpv_slot_list = [parent]
for atom in atoms:
- if "!" == atom[:1]:
+ if atom.blocker:
continue
if vardb.match(atom):
# If the atom is satisfied by an installed
# version then it's not a circular dep.
continue
- if dep_getkey(atom) != parent.cp:
+ if atom.cp != parent.cp:
continue
if match_from_list(atom, cpv_slot_list):
circular_atom = atom
@@ -7850,14 +7851,19 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
assert(False) # This point should not be reachable
-
def dep_expand(mydep, mydb=None, use_cache=1, settings=None):
+ '''
+ @rtype: Atom
+ '''
if not len(mydep):
return mydep
if mydep[0]=="*":
mydep=mydep[1:]
orig_dep = mydep
- mydep = dep_getcpv(orig_dep)
+ if isinstance(orig_dep, dep.Atom):
+ mydep = orig_dep.cpv
+ else:
+ mydep = dep_getcpv(orig_dep)
myindex = orig_dep.index(mydep)
prefix = orig_dep[:myindex]
postfix = orig_dep[myindex+len(mydep):]
@@ -7974,7 +7980,7 @@ def dep_wordreduce(mydeplist,mysettings,mydbapi,mode,use_cache=1):
elif token[:1] == "!":
deplist[mypos] = False
else:
- mykey = dep_getkey(deplist[mypos])
+ mykey = deplist[mypos].cp
if mysettings and mykey in mysettings.pprovideddict and \
match_from_list(deplist[mypos], mysettings.pprovideddict[mykey]):
deplist[mypos]=True
@@ -8004,8 +8010,23 @@ def dep_wordreduce(mydeplist,mysettings,mydbapi,mode,use_cache=1):
return None
return deplist
+_cpv_key_re = re.compile('^' + dep._cpv + '$', re.VERBOSE)
def cpv_getkey(mycpv):
- return dep.dep_getkey('=' + mycpv)
+ """Calls pkgsplit on a cpv and returns only the cp."""
+ m = _cpv_key_re.match(mycpv)
+ if m is not None:
+ return m.group(2)
+ myslash = mycpv.split("/", 1)
+ mysplit=pkgsplit(myslash[-1])
+ if mysplit is None:
+ return None
+ mylen=len(myslash)
+ if mylen==2:
+ return myslash[0]+"/"+mysplit[0]
+ else:
+ return mysplit[0]
+
+getCPFromCPV = cpv_getkey
def key_expand(mykey, mydb=None, use_cache=1, settings=None):
mysplit=mykey.split("/")
@@ -8326,7 +8347,6 @@ def getmaskingstatus(mycpv, settings=None, portdb=None):
return rValue
-
auxdbkeys=[
'DEPEND', 'RDEPEND', 'SLOT', 'SRC_URI',
'RESTRICT', 'HOMEPAGE', 'LICENSE', 'DESCRIPTION',
@@ -8894,7 +8914,6 @@ def init_legacy_globals():
root = settings["ROOT"]
output._init(config_root=settings['PORTAGE_CONFIGROOT'])
-
# ========================================================================
# COMPATIBILITY
# These attributes should not be used
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
index 10baa4b9c..4cc07362a 100644
--- a/pym/portage/dbapi/porttree.py
+++ b/pym/portage/dbapi/porttree.py
@@ -949,7 +949,7 @@ class portdbapi(dbapi):
#this stuff only runs on first call of xmatch()
#create mydep, mykey from origdep
mydep = dep_expand(origdep, mydb=self, settings=self.mysettings)
- mykey = dep_getkey(mydep)
+ mykey = mydep.cp
if level == "list-visible":
#a list of all visible packages, not called directly (just by xmatch())
@@ -1133,7 +1133,6 @@ def close_portdbapi_caches():
for i in portdbapi.portdbapi_instances:
i.close_caches()
-
class portagetree(object):
def __init__(self, root="/", virtual=None, clone=None, settings=None):
"""
diff --git a/pym/portage/dep.py b/pym/portage/dep.py
index fd41f8fd4..bd576b768 100644
--- a/pym/portage/dep.py
+++ b/pym/portage/dep.py
@@ -990,6 +990,8 @@ def match_to_list(mypkg, mylist):
"""
matches = []
for x in mylist:
+ if not isinstance(x, Atom):
+ x = Atom(x)
if match_from_list(x, [mypkg]):
if x not in matches:
matches.append(x)
@@ -1024,7 +1026,7 @@ def best_match_to_list(mypkg, mylist):
if maxvalue < 3:
maxvalue = 3
bestm = x
- op_val = operator_values[get_operator(x)]
+ op_val = operator_values[x.operator]
if op_val > maxvalue:
maxvalue = op_val
bestm = x
@@ -1051,9 +1053,9 @@ def match_from_list(mydep, candidate_list):
if not isinstance(mydep, Atom):
mydep = Atom(mydep)
- mycpv = dep_getcpv(mydep)
+ mycpv = mydep.cpv
mycpv_cps = catpkgsplit(mycpv) # Can be None if not specific
- slot = dep_getslot(mydep)
+ slot = mydep.slot
if not mycpv_cps:
cat, pkg = catsplit(mycpv)
@@ -1066,7 +1068,7 @@ def match_from_list(mydep, candidate_list):
" (%s) (try adding an '=')") % (mydep))
if ver and rev:
- operator = get_operator(mydep)
+ operator = mydep.operator
if not operator:
writemsg(_("!!! Invalid atom: %s\n") % mydep, noiselevel=-1)
return []
diff --git a/pym/portage/sets/base.py b/pym/portage/sets/base.py
index 87a0d1db7..adf05fbf8 100644
--- a/pym/portage/sets/base.py
+++ b/pym/portage/sets/base.py
@@ -104,9 +104,8 @@ class PackageSet(object):
self._atommap.clear()
atoms = self._atoms
for a in atoms:
- cp = dep_getkey(a)
- self._atommap.setdefault(cp, set())
- self._atommap[cp].add(a)
+ self._atommap.setdefault(a.cp, set())
+ self._atommap[a.cp].add(a)
# Not sure if this one should really be in PackageSet
def findAtomForPackage(self, pkg):