示例#1
0
    def process_depset(self, pkg, attr, depset, profiles, reporter):
        get_cached_query = self.query_cache.get

        csolutions = []
        blockers = []
        for required in depset.iter_cnf_solutions():
            for node in required:
                if node.blocks:
                    blockers.extend(required)
                    break
            else:
                csolutions.append(required)

        for profile in profiles:
            blocked = OrRestriction(*(self.restrict_use(x, profile)
                                      for x in blockers))
            failures = set()
            # is it visible?  ie, is it masked?
            # if so, skip it.
            # long term, probably should do testing in the same respect we do
            # for other visibility tiers
            cache = profile.cache
            provided = profile.provides_has_match
            insoluble = profile.insoluble
            visible = lambda x: profile.visible(x) and not blocked.match(x)
            for required in csolutions:
                # scan all of the quickies, the caches...
                for node in required:
                    if node in cache:
                        break
                    elif provided(node):
                        break
                else:
                    for node in required:
                        if node in insoluble:
                            pass

                        # get is required since there is an intermix between old style
                        # virtuals and new style- thus the cache priming doesn't get
                        # all of it.
                        src = get_cached_query(strip_atom_use(node), ())
                        if node.use:
                            src = (FakeConfigurable(pkg, profile)
                                   for pkg in src)
                            src = (pkg for pkg in src if node.force_True(pkg))
                        if any(True for pkg in src if visible(pkg)):
                            cache.add(node)
                            break
                        else:
                            insoluble.add(node)
                    else:
                        # no matches.  not great, should collect them all
                        failures.update(required)
            if failures:
                reporter.add_report(
                    NonsolvableDeps(pkg, attr, profile.key, profile.name,
                                    list(failures)))
示例#2
0
 def __getattr__(self, key):
     val = None
     if key == "rdepends":
         val = self.provider
     elif key in ("depends", "post_rdepends", "provides"):
         val = OrRestriction()
     elif key == "slot":
         val = "%s-%s" % (self.provider.category, self.version)
     else:
         return super(package, self).__getattr__(key)
     self.__dict__[key] = val
     return val
示例#3
0
 def __getattr__(self, key):
     val = None
     if key == "rdepend":
         val = self.provider
     elif key in ("bdepend", "depend", "pdepend"):
         val = OrRestriction()
     elif key == "slot":
         val = f"{self.provider.category}-{self.version}"
     else:
         return super().__getattr__(key)
     self.__dict__[key] = val
     return val
示例#4
0
    def check_range(self, vuln_range, ver_matches, ver_nonmatches):
        self.mk_glsa([("dev-util/diffball", ([], [vuln_range]))])
        restrict = list(OrRestriction(*tuple(glsa.GlsaDirSet(self.dir))))
        self.assertEqual(len(restrict), 1)
        restrict = restrict[0]
        for ver in ver_matches:
            pkg = cpv.versioned_CPV("dev-util/diffball-%s" % ver)
            self.assertTrue(restrict.match(pkg),
                            msg="pkg %s must match for %r: %s" %
                            (pkg, vuln_range, restrict))

        for ver in ver_nonmatches:
            pkg = cpv.versioned_CPV("dev-util/diffball-%s" % ver)
            self.assertFalse(restrict.match(pkg),
                             msg="pkg %s must not match for %r: %s" %
                             (pkg, vuln_range, restrict))
示例#5
0
 def test_slots(self):
     slotted_pkgs_set = pkgs_set + (("dev-util/pkgcheck", '1',
                                     ([">=2"], [">1"]), '*'), )
     self.mk_glsa(slotted_pkgs_set)
     g = glsa.GlsaDirSet(self.dir)
     l = list(g)
     self.assertEqual(
         set(x.key for x in l),
         set(['dev-util/diffball', 'dev-util/bsdiff', 'dev-util/pkgcheck']))
     restrict = OrRestriction(*tuple(glsa.GlsaDirSet(self.dir)))
     self.assertTrue(restrict.match(atom.atom('=dev-util/pkgcheck-1-r1:1')))
     self.assertFalse(restrict.match(atom.atom('=dev-util/pkgcheck-1:1')))
     self.assertFalse(restrict.match(atom.atom('=dev-util/pkgcheck-2:1')))
     self.assertFalse(restrict.match(atom.atom('=dev-util/pkgcheck-1:0')))
     self.assertFalse(restrict.match(atom.atom('dev-util/pkgcheck:0')))
     self.assertFalse(restrict.match(atom.atom('dev-util/pkgcheck')))
示例#6
0
    def check_range(self, vuln_range, ver_matches, ver_nonmatches):
        self.mk_glsa([("dev-util/diffball", ([], [vuln_range]))])
        restrict = list(OrRestriction(*tuple(glsa.GlsaDirSet(self.dir))))
        if len(restrict) == 0:  # exception thrown
            restrict.append(AlwaysBool(negate=False))
        self.assertEqual(len(restrict), 1)
        restrict = restrict[0]
        for ver in ver_matches:
            pkg = cpv.VersionedCPV(f"dev-util/diffball-{ver}")
            self.assertTrue(
                restrict.match(pkg),
                msg=f"pkg {pkg} must match for {vuln_range!r}: {restrict}")

        for ver in ver_nonmatches:
            pkg = cpv.VersionedCPV(f"dev-util/diffball-{ver}")
            self.assertFalse(
                restrict.match(pkg),
                msg="pkg {pkg} must not match for {vuln_range!r}: {restrict}")
示例#7
0
 def test_slots(self):
     slotted_pkgs_set = pkgs_set + (
         ("dev-util/pkgcheck", '1', ([">=2"], [">1"]), '*'),
     )
     self.mk_glsa(slotted_pkgs_set)
     g = glsa.GlsaDirSet(self.dir)
     l = list(g)
     self.assertEqual(set(x.key for x in l),
         set(['dev-util/diffball', 'dev-util/bsdiff', 'dev-util/pkgcheck']))
     restrict = OrRestriction(*tuple(glsa.GlsaDirSet(self.dir)))
     self.assertTrue(restrict.match(atom.atom('=dev-util/pkgcheck-1-r1:1')))
     self.assertFalse(restrict.match(atom.atom('=dev-util/pkgcheck-1:1')))
     self.assertFalse(restrict.match(atom.atom('=dev-util/pkgcheck-2:1')))
     self.assertFalse(restrict.match(atom.atom('=dev-util/pkgcheck-1:0')))
     self.assertFalse(restrict.match(atom.atom('dev-util/pkgcheck:0')))
     self.assertFalse(restrict.match(atom.atom('dev-util/pkgcheck')))