masked_pkg_instances.add(pkg)
if atom.unevaluated_atom.use:
if not pkg.iuse.is_valid_flag(atom.unevaluated_atom.use.required) \
- or atom.violated_conditionals(self._pkg_use_enabled(pkg), pkg.iuse.all).use:
+ or atom.violated_conditionals(self._pkg_use_enabled(pkg), pkg.iuse.is_valid_flag).use:
missing_use.append(pkg)
if not mreasons:
continue
# Lets see if the violated use deps are conditional.
# If so, suggest to change them on the parent.
mreasons = []
- violated_atom = atom.unevaluated_atom.violated_conditionals(self._pkg_use_enabled(pkg), pkg.iuse.all, myparent.use.enabled)
+ violated_atom = atom.unevaluated_atom.violated_conditionals(self._pkg_use_enabled(pkg), \
+ pkg.iuse.is_valid_flag, myparent.use.enabled)
if not (violated_atom.use.enabled or violated_atom.use.disabled):
#all violated use deps are conditional
changes = []
elif not atom_set.findAtomForPackage(other_pkg):
#Use conditionals not met.
violated_atom = atom.violated_conditionals(other_pkg.use.enabled, \
- other_pkg.iuse.all, ppkg.use.enabled)
+ other_pkg.iuse.is_valid_flag, ppkg.use.enabled)
for flag in violated_atom.use.enabled.union(violated_atom.use.disabled):
atoms = collision_reasons.get(("use", flag), set())
atoms.add((ppkg, atom, other_pkg))
conditional_matches = set()
for ppkg, atom, other_pkg in parents:
violated_atom = atom.unevaluated_atom.violated_conditionals( \
- other_pkg.use.enabled, other_pkg.iuse.all, ppkg.use.enabled)
+ other_pkg.use.enabled, other_pkg.iuse.is_valid_flag, ppkg.use.enabled)
if use in violated_atom.use.enabled.union(violated_atom.use.disabled):
hard_matches.add((ppkg, atom))
else:
if ppkg.installed:
#We cannot assume that it's possible to reinstall the package. Do not
#check if some of its atom has use.conditional
- violated_atom = atom.violated_conditionals(pkg.use.enabled, pkg.iuse.all, ppkg.use.enabled)
+ violated_atom = atom.violated_conditionals(pkg.use.enabled, \
+ pkg.iuse.is_valid_flag, ppkg.use.enabled)
else:
violated_atom = atom.unevaluated_atom.violated_conditionals(pkg.use.enabled, \
- pkg.iuse.all, ppkg.use.enabled)
+ pkg.iuse.is_valid_flag, ppkg.use.enabled)
if pkg.installed and (violated_atom.use.enabled or violated_atom.use.disabled):
#We can't change USE of an installed package (only of an ebuild, but that is already
return _use_dep(tokens)
- def violated_conditionals(self, other_use, iuse, parent_use=None):
+ def violated_conditionals(self, other_use, is_valid_flag, parent_use=None):
"""
Create a new instance with satisfied use deps removed.
"""
for x in self.enabled:
if x not in other_use:
- if x in iuse:
+ if is_valid_flag(x):
tokens.append(self._append_use_default(x, x))
else:
if x in self.missing_disabled:
for x in self.disabled:
if x not in other_use:
- if x not in iuse:
+ if not is_valid_flag(x):
if x in self.missing_enabled:
tokens.append(self._append_use_default("-" + x, x))
else:
continue
if x not in other_use:
- if x in iuse:
+ if is_valid_flag(x):
tokens.append(self._append_use_default(x + "?", x))
else:
if x in self.missing_disabled:
continue
if x not in other_use:
- if x not in iuse:
+ if not is_valid_flag(x):
if x in self.missing_enabled:
tokens.append(self._append_use_default("!" + x + "?", x))
else:
continue
if x not in other_use:
- if x in iuse:
+ if is_valid_flag(x):
tokens.append(self._append_use_default(x + "=", x))
else:
if x in self.missing_disabled:
continue
if x not in other_use:
- if x not in iuse:
+ if not is_valid_flag(x):
if x in self.missing_enabled:
tokens.append(self._append_use_default(x + "=", x))
else:
continue
if x not in other_use:
- if x in iuse:
+ if is_valid_flag(x):
tokens.append(self._append_use_default("!" + x + "=", x))
else:
if x in self.missing_disabled:
continue
if x not in other_use:
- if x not in iuse:
+ if not is_valid_flag(x):
if x in self.missing_enabled:
tokens.append(self._append_use_default("!" + x + "=", x))
else:
atom += str(self.use.evaluate_conditionals(use))
return Atom(atom, unevaluated_atom=self)
- def violated_conditionals(self, other_use, iuse, parent_use=None):
+ def violated_conditionals(self, other_use, is_valid_flag, parent_use=None):
"""
Create an atom instance with any USE conditional removed, that is
satisfied by other_use.
- @param use: The set of enabled USE flags
- @type use: set
- @param use: The set of enabled USE flags to check against
- @type use: set
+ @param other_use: The set of enabled USE flags
+ @type other_use: set
+ @param is_valid_flag: Function that decides if a use flag is referenceable in use deps
+ @type is_valid_flag: function
+ @param parent_use: Set of enabled use flags of the package requiring this atom
+ @type parent_use: set
@rtype: Atom
@return: an atom instance with any satisfied USE conditionals removed
"""
atom = remove_slot(self)
if self.slot:
atom += ":%s" % self.slot
- atom += str(self.use.violated_conditionals(other_use, iuse, parent_use))
+ atom += str(self.use.violated_conditionals(other_use, is_valid_flag, parent_use))
return Atom(atom, unevaluated_atom=self)
def _eval_qa_conditionals(self, use_mask, use_force):
test_cases_xfail = (
("dev-libs/A[a,b=,!c=,d?,!e?,-f]", [], ["a", "b", "c", "d", "e", "f"], None),
)
-
+
+ class use_flag_validator(object):
+ def __init__(self, iuse):
+ self.iuse = iuse
+
+ def is_valid_flag(self, flag):
+ return flag in iuse
+
for atom, other_use, iuse, parent_use, expected_violated_atom in test_cases:
a = Atom(atom)
- violated_atom = a.violated_conditionals(other_use, iuse, parent_use)
+ validator = use_flag_validator(iuse)
+ violated_atom = a.violated_conditionals(other_use, validator.is_valid_flag, parent_use)
if parent_use is None:
fail_msg = "Atom: %s, other_use: %s, iuse: %s, parent_use: %s, got: %s, expected: %s" % \
(atom, " ".join(other_use), " ".join(iuse), "None", str(violated_atom), expected_violated_atom)
for atom, other_use, iuse, parent_use in test_cases_xfail:
a = Atom(atom)
+ validator = use_flag_validator(iuse)
self.assertRaisesMsg(atom, InvalidAtom, \
- a.violated_conditionals, other_use, iuse, parent_use)
+ a.violated_conditionals, other_use, validator.is_valid_flag, parent_use)
def test_evaluate_conditionals(self):
test_cases = (