Пример #1
0
 def __iter__(self):
     for glsa, matches in find_vulnerable_repo_pkgs(self.glsa_src,
                                                    self.vdb,
                                                    grouped=True,
                                                    arch=self.arch):
         yield packages.KeyedAndRestriction(glsa[0],
                                            restriction.Negate(glsa[1]))
Пример #2
0
    def insert_blockers(self, stack, choices, blocks):
        # level blockers.
        was_livefs = choices.current_pkg.repo.livefs
        for x in blocks:
            if not was_livefs:
                self._ensure_livefs_is_loaded(x)

            rewrote_blocker = self.generate_mangled_blocker(choices, x)
            l = self.state.add_blocker(choices, rewrote_blocker, key=x.key)
            if l:
                # blocker caught something. yay.
                self._dprint("%s blocker %s hit %s for atom %s pkg %s",
                             (stack[-1].mode, x, l, stack[-1].atom,
                              choices.current_pkg))
                if x.weak_blocker:
                    # note that we use the top frame of the stacks' dbs; this
                    # is to allow us to upgrade as needed.
                    # For this to match, it's *only* possible if the blocker is resolved
                    # since the limiter is already in place.
                    result = self._rec_add_atom(
                        packages.KeyedAndRestriction(restriction.Negate(x),
                                                     _atom.atom(x.key),
                                                     key=x.key), stack,
                        stack[0].dbs)
                    if not result:
                        # ok, inserted a new version.  did it take care of the conflict?
                        # it /may/ not have, via filling a different slot...
                        result = self.state.match_atom(x)
                        if not result:
                            # ignore the blocker, we resolved past it.
                            continue
                return x, l
        return None
Пример #3
0
    def iter_dnf_solutions(self, full_solution_expansion=False):
        """
        generater yielding DNF (disjunctive normalized form) of this instance.

        :param full_solution_expansion: controls whether to expand everything
            (break apart atoms for example); this isn't likely what you want
        """
        if self.negate:
            #           raise NotImplementedError("negation for dnf_solutions on "
            #                 "AndRestriction isn't implemented yet")
            # hack- this is an experiment
            for r in OrRestriction(
                    node_type=self.type,
                    *[restriction.Negate(x)
                      for x in self.restrictions]).iter_dnf_solutions():
                yield r
            return
        if not self.restrictions:
            yield []
            return
        hardreqs = []
        optionals = []
        for x in self.restrictions:
            method = getattr(x, 'dnf_solutions', None)
            if method is None:
                hardreqs.append(x)
            else:
                s2 = method(full_solution_expansion)
                assert s2
                if len(s2) == 1:
                    hardreqs.extend(s2[0])
                else:
                    optionals.append(s2)

        def f(arg, *others):
            if others:
                for node in arg:
                    for node2 in f(*others):
                        yield node + node2
            else:
                for node in arg:
                    yield node

        for solution in f([hardreqs], *optionals):
            assert isinstance(solution, (tuple, list))
            yield solution
Пример #4
0
    def iter_dnf_solutions(self, full_solution_expansion=False):
        """returns a list in DNF (disjunctive normalized form) for of this instance

        :param full_solution_expansion: controls whether to expand everything
            (break apart atoms for example); this isn't likely what you want
        """
        if self.negate:
            # hack- this is an experiment
            for x in AndRestriction(
                node_type=self.type,
                *[restriction.Negate(x)
                  for x in self.restrictions]).iter_dnf_solutions():
                yield x
        if not self.restrictions:
            yield []
            return
        for x in self.restrictions:
            method = getattr(x, 'iter_dnf_solutions', None)
            if method is None:
                yield [x]
            else:
                for y in method(full_solution_expansion):
                    yield y