diff options
author | Jason Stubbs <jstubbs@gentoo.org> | 2005-05-03 13:49:35 +0000 |
---|---|---|
committer | Jason Stubbs <jstubbs@gentoo.org> | 2005-05-03 13:49:35 +0000 |
commit | 0e4679618386a565d6827d43aad5ad66bc31e970 (patch) | |
tree | a2505cb2f01e87721f26a76154ee91fa6978ef4d | |
parent | Added methods for modifying DependSpec externally. (diff) | |
download | portage-cvs-0e4679618386a565d6827d43aad5ad66bc31e970.tar.gz portage-cvs-0e4679618386a565d6827d43aad5ad66bc31e970.tar.bz2 portage-cvs-0e4679618386a565d6827d43aad5ad66bc31e970.zip |
Fixed some bugs in the new intersects() and encapsulates() methods. Created
a transform_dependspec() function that reorders DependSpec elements based
on supplied preferences.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | pym/portage_dep.py | 47 | ||||
-rw-r--r-- | pym/portage_syntax.py | 16 |
3 files changed, 59 insertions, 11 deletions
@@ -1,12 +1,17 @@ # ChangeLog for Portage; the Gentoo Linux ports system # Copyright 1999-2005 Gentoo Foundation; Distributed under the GPL v2 -# $Id: ChangeLog,v 1.961 2005/05/03 11:04:34 jstubbs Exp $ +# $Id: ChangeLog,v 1.962 2005/05/03 13:49:35 jstubbs Exp $ MAJOR CHANGES in 2.0.51: 1. /var/cache/edb/virtuals is no longer used at all. It's calculated now. 2. /var/cache/edb/world is now /var/lib/portage/world. 3. /etc/portage/profile/virtuals is _USER_ configs only. + 03 May 2005; Jason Stubbs <jstubbs@gentoo.org> pym/portage_syntax.py + pym/portage_dep.py: Fixed some bugs in the new intersects() and + encapsulates() methods. Created a transform_dependspec() function that + reorders DependSpec elements based on supplied preferences. + 03 May 2005; Jason Stubbs <jstubbs@gentoo.org> pym/portage_syntax.py: Added methods for modifying DependSpec externally. diff --git a/pym/portage_dep.py b/pym/portage_dep.py index 1fedb40..4b0e2cc 100644 --- a/pym/portage_dep.py +++ b/pym/portage_dep.py @@ -1,8 +1,8 @@ # deps.py -- Portage dependency resolution functions # Copyright 2003-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/pym/portage_dep.py,v 1.29 2005/05/03 10:20:01 jstubbs Exp $ -cvs_id_string="$Id: portage_dep.py,v 1.29 2005/05/03 10:20:01 jstubbs Exp $"[5:-2] +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/pym/portage_dep.py,v 1.30 2005/05/03 13:49:35 jstubbs Exp $ +cvs_id_string="$Id: portage_dep.py,v 1.30 2005/05/03 13:49:35 jstubbs Exp $"[5:-2] # DEPEND SYNTAX: # @@ -669,6 +669,49 @@ class GluePkg(portage_syntax.CPV): self.rdeps = portage_syntax.DependSpec(rdeps).resolve_conditions(self.use) +def transform_dependspec(dependspec, preferences): + def dotransform(dependspec, preferences): + dependspec = copy.copy(dependspec) + elements = dependspec.elements + dependspec.elements = [] + neworder = [] + prio = len(preferences)+1 + idx = -1 + for element in elements[:]: + if isinstance(element, portage_syntax.DependSpec): + neworder.append(dotransform(element, preferences)) + elements.remove(element) + for pref in preferences: + idx += 1 + for element in elements[:]: + if pref.intersects(element): + if idx < prio: + prio = idx + if pref.encapsulates(element): + neworder.append((idx, element)) + elements.remove(element) + else: + subdependspec = portage_syntax.DependSpec(element_class=portage_syntax.Atom) + if element.encapsulates(pref): + subsubdependspec = portage_syntax.DependSpec(element_class=portage_syntax.Atom) + subsubdependspec.add_element(pref) + subsubdependspec.add_element(element) + subdependspec.add_element(subsubdependspec) + else: + subdependspec.add_element(pref) + subdependspec.add_element(element) + subdependspec.preferential = True + neworder.append((idx, subdependspec)) + elements.remove(element) + neworder.sort() + for element in neworder: + dependspec.add_element(element[1]) + for element in elements: + dependspec.add_element(element) + return (prio, dependspec) + return dotransform(dependspec, preferences)[1] + + class TargetGraph(object): def __init__(self): diff --git a/pym/portage_syntax.py b/pym/portage_syntax.py index f18ccb3..a6bb27b 100644 --- a/pym/portage_syntax.py +++ b/pym/portage_syntax.py @@ -325,19 +325,19 @@ class Atom(object): return False def intersects(self, atom): - if self == other: + if self == atom: return True - if self.key != atom.key: + if self.cpv.key != atom.cpv.key: return False - if self.blocks != other.blocks: + if self.blocks != atom.blocks: return False - if not self.operator or not other.operator: + if not self.operator or not atom.operator: return True if self.cpv == other.cpv: - if self.operator == other.operator: + if self.operator == atom.operator: return True if self.operator == "<": - return (other.operator[0] == "<") + return (atom.operator[0] == "<") if self.operator == ">": return (other.operator[0] == ">" or other.operator == "~") if self.operator == "=": @@ -369,12 +369,12 @@ class Atom(object): if not self.intersects(atom): return False - if self.operator and not other.operator: + if self.operator and not atom.operator: return False if not self.operator: return True - if self.cpv == other.cpv: + if self.cpv == atom.cpv: if self.operator == other.operator: return True if other.operator == "=": |