Ejemplo n.º 1
0
    def _viable(self, stack, mode, atom, dbs, drop_cycles, limit_to_vdb):
        """
        internal function to discern if an atom is viable, returning
        the choicepoint/matches iterator if viable.

        :param stack: current stack
        :type stack: :obj:`resolver_stack`
        :param mode: type of dependency (depends/rdepends)
        :type mode: str
        :param atom: atom for the current package
        :type atom: :obj:`pkgcore.ebuild.atom.atom`
        :param dbs: db list to walk
        :param drop_cycles: boolean controlling whether to drop dep cycles
        :param limit_to_vdb: boolean controlling considering pkgs only from the vdb
        :return: 3 possible; None (not viable), True (presolved),
          :obj:`caching_iter` (not solved, but viable), :obj:`choice_point`
        """
        choices = ret = None
        if atom in self.insoluble:
            ret = ((False, "globally insoluble"),{})
            matches = ()
        else:
            matches = self.state.match_atom(atom)
            if matches:
                ret = ((True,), {"pre_solved":True})
            else:
                # not in the plan thus far.
                matches = caching_iter(dbs.itermatch(atom))
                if matches:
                    choices = choice_point(atom, matches)
                    # ignore what dropped out, at this juncture we don't care.
                    choices.reduce_atoms(self.insoluble)
                    if not choices:
                        # and was intractable because it has a hard dep on an
                        # unsolvable atom.
                        ret = ((False, "pruning of insoluble deps "
                            "left no choices"), {})
                else:
                    ret = ((False, "no matches"), {})

        if choices is None:
            choices = choice_point(atom, matches)

        stack.add_frame(mode, atom, choices, dbs,
            self.state.current_state, drop_cycles, vdb_limited=limit_to_vdb)

        if not limit_to_vdb and not matches:
            self.insoluble.add(atom)
        if ret is not None:
            self.notify_viable(stack, atom, *ret[0], **ret[1])
            if ret[0][0] == True:
                state.add_backref_op(choices, choices.current_pkg).apply(self.state)
                return True
            return None
        return choices, matches
Ejemplo n.º 2
0
    def _viable(self, stack, mode, atom, dbs, drop_cycles, limit_to_vdb):
        """
        internal function to discern if an atom is viable, returning
        the choicepoint/matches iter if viable.

        :return: 3 possible; None (not viable), True (presolved),
          :obj:`caching_iter` (not solved, but viable), :obj:`choice_point`
        """
        choices = ret = None
        if atom in self.insoluble:
            ret = ((False, "globally insoluble"),{})
            matches = ()
        else:
            matches = self.state.match_atom(atom)
            if matches:
                ret = ((True,), {"pre_solved":True})
            else:
                # not in the plan thus far.
                matches = caching_iter(dbs.itermatch(atom))
                if matches:
                    choices = choice_point(atom, matches)
                    # ignore what dropped out, at this juncture we don't care.
                    choices.reduce_atoms(self.insoluble)
                    if not choices:
                        # and was intractable because it has a hard dep on an
                        # unsolvable atom.
                        ret = ((False, "pruning of insoluble deps "
                            "left no choices"), {})
                else:
                    ret = ((False, "no matches"), {})

        if choices is None:
            choices = choice_point(atom, matches)

        stack.add_frame(mode, atom, choices, dbs,
            self.state.current_state, drop_cycles, vdb_limited=limit_to_vdb)

        if not limit_to_vdb and not matches:
            self.insoluble.add(atom)
        if ret is not None:
            self.notify_viable(stack, atom, *ret[0], **ret[1])
            if ret[0][0] == True:
                state.add_backref_op(choices, choices.current_pkg).apply(self.state)
                return True
            return None
        return choices, matches
Ejemplo n.º 3
0
 def _ensure_livefs_is_loaded_nonpreloaded(self, restrict):
     # do a trick to make the resolver now aware of vdb pkgs if needed
     # check for any matches; none, try and insert vdb nodes.
     l = self.state.match_atom(restrict)
     if not l:
         # hmm. ok... no conflicts, so we insert in vdb matches
         # to trigger a replace instead of an install
         for pkg in self.livefs_dbs.itermatch(restrict):
             self._dprint("inserting vdb node for %s %s", (restrict, pkg))
             c = choice_point(restrict, [pkg])
             state.add_op(c, c.current_pkg, force=True).apply(self.state)
Ejemplo n.º 4
0
 def _ensure_livefs_is_loaded_nonpreloaded(self, restrict):
     # do a trick to make the resolver now aware of vdb pkgs if needed
     # check for any matches; none, try and insert vdb nodes.
     l = self.state.match_atom(restrict)
     if not l:
         # hmm. ok... no conflicts, so we insert in vdb matches
         # to trigger a replace instead of an install
         for pkg in self.livefs_dbs.itermatch(restrict):
             self._dprint("inserting vdb node for %s %s", (restrict, pkg))
             c = choice_point(restrict, [pkg])
             state.add_op(c, c.current_pkg, force=True).apply(self.state)
Ejemplo n.º 5
0
 def gen_choice_point():
     return choice_point("asdf", [
         fake_package(marker=1, depends=OrRestriction(
                     "ordep1", "ordep2", "dependsordep"),
             rdepends=AndRestriction(
                     OrRestriction("ordep1", "andordep2"),
                     "anddep1", "anddep2", "pkg1and"),
             post_rdepends=OrRestriction("prdep1", "or3")),
         fake_package(marker=2, depends=AndRestriction(
                     "anddep1", "anddep2"),
             rdepends=OrRestriction("or1", "or2"),
             post_rdepends=OrRestriction("prdep1", "or3"))])
Ejemplo n.º 6
0
 def gen_choice_point():
     return choice_point("asdf", [
         fake_package(marker=1, depends=OrRestriction(
                     "ordep1", "ordep2", "dependsordep"),
             rdepends=AndRestriction(
                     OrRestriction("ordep1", "andordep2"),
                     "anddep1", "anddep2", "pkg1and"),
             post_rdepends=OrRestriction("prdep1", "or3")),
         fake_package(marker=2, depends=AndRestriction(
                     "anddep1", "anddep2"),
             rdepends=OrRestriction("or1", "or2"),
             post_rdepends=OrRestriction("prdep1", "or3"))])
Ejemplo n.º 7
0
    def _viable(self, stack, mode, atom, dbs, drop_cycles, limit_to_vdb):
        """
        internal function to discern if an atom is viable, returning
        the choicepoint/matches iterator if viable.

        :param stack: current stack
        :type stack: :obj:`resolver_stack`
        :param mode: type of dependency (depends/rdepends)
        :type mode: str
        :param atom: atom for the current package
        :type atom: :obj:`pkgcore.ebuild.atom.atom`
        :param dbs: db list to walk
        :param drop_cycles: boolean controlling whether to drop dep cycles
        :param limit_to_vdb: boolean controlling considering pkgs only from the vdb
        :return: 3 possible; None (not viable), True (presolved),
          :obj:`caching_iter` (not solved, but viable), :obj:`choice_point`
        """
        choices = ret = None
        if atom in self.insoluble:
            ret = ((False, "globally insoluble"), {})
            matches = ()
        else:
            matches = self.state.match_atom(atom)
            if matches:
                ret = ((True, ), {"pre_solved": True})
            else:
                # not in the plan thus far.
                matches = caching_iter(dbs.itermatch(atom))
                if matches:
                    choices = choice_point(atom, matches)
                    # ignore what dropped out, at this juncture we don't care.
                    choices.reduce_atoms(self.insoluble)
                    if not choices:
                        # and was intractable because it has a hard dep on an
                        # unsolvable atom.
                        ret = ((False, "pruning of insoluble deps "
                                "left no choices"), {})
                else:
                    ret = ((False, "no matches"), {})

        if choices is None:
            choices = choice_point(atom, matches)

        stack.add_frame(mode,
                        atom,
                        choices,
                        dbs,
                        self.state.current_state,
                        drop_cycles,
                        vdb_limited=limit_to_vdb)

        if not limit_to_vdb and not matches:
            self.insoluble.add(atom)
        if ret is not None:
            self.notify_viable(stack, atom, *ret[0], **ret[1])
            if ret[0][0] == True:
                state.add_backref_op(choices,
                                     choices.current_pkg).apply(self.state)
                return True
            return None
        return choices, matches