示例#1
0
文件: domain.py 项目: ulm/pkgcore
    def _make_keywords_filter(self, default_keys, accept_keywords, incremental=False):
        """Generates a restrict that matches iff the keywords are allowed."""
        if not accept_keywords and not self.profile.keywords:
            return packages.PackageRestriction(
                "keywords", values.ContainmentMatch2(frozenset(default_keys)))

        if self.unstable_arch not in default_keys:
            # stable; thus empty entries == ~arch
            def f(r, v):
                if not v:
                    return r, self.unstable_arch
                return r, v
            data = collapsed_restrict_to_data(
                ((packages.AlwaysTrue, default_keys),),
                (f(*i) for i in accept_keywords))
        else:
            if incremental:
                f = collapsed_restrict_to_data
            else:
                f = non_incremental_collapsed_restrict_to_data
            data = f(((packages.AlwaysTrue, default_keys),), accept_keywords)

        if incremental:
            raise NotImplementedError(self._incremental_apply_keywords_filter)
            #f = self._incremental_apply_keywords_filter
        else:
            f = self._apply_keywords_filter
        return delegate(partial(f, data))
示例#2
0
文件: domain.py 项目: den4ix/pkgcore
    def make_keywords_filter(self, arch, default_keys, accept_keywords,
                             profile_keywords, incremental=False):
        """Generates a restrict that matches iff the keywords are allowed."""
        if not accept_keywords and not profile_keywords:
            return packages.PackageRestriction(
                "keywords", values.ContainmentMatch(*default_keys))

        if "~" + arch.lstrip("~") not in default_keys:
            # stable; thus empty entries == ~arch
            unstable = "~" + arch
            def f(r, v):
                if not v:
                    return r, unstable
                return r, v
            data = collapsed_restrict_to_data(
                ((packages.AlwaysTrue, default_keys),),
                (f(*i) for i in accept_keywords))
        else:
            if incremental:
                f = collapsed_restrict_to_data
            else:
                f = non_incremental_collapsed_restrict_to_data
            data = f(((packages.AlwaysTrue, default_keys),), accept_keywords)

        if incremental:
            raise NotImplementedError(self.incremental_apply_keywords_filter)
            #f = self.incremental_apply_keywords_filter
        else:
            f = self.apply_keywords_filter
        return delegate(partial(f, data, profile_keywords))
示例#3
0
    def test_forced_use(self):
        self.formatter.forced_use = collapsed_restrict_to_data(([(atom('=app-arch/bzip2-1.0.3-r6'),('static'))]))

        # new pkg: static use flag forced on
        self.formatter.format(
            FakeOp(FakeEbuildSrc('app-arch/bzip2-1.0.3-r6', iuse=['static'], use=['static'])))
        self.assertOut('[', Color('fg', 'green'), 'ebuild', Reset(),
            '  ', Color('fg', 'green'), Bold(), 'N', Reset(), '     ] ',
            Color('fg', 'green'), 'app-arch/bzip2-1.0.3-r6', Reset(),
            ' USE="(', Color('fg', 'red'), Bold(), 'static', Reset(), ')"')

        # rebuilt pkg: toggled static use flag forced on
        self.formatter.format(
            FakeOp(FakeEbuildSrc('app-arch/bzip2-1.0.3-r6', iuse=['static'], use=['static']),
            FakeMutatedPkg('app-arch/bzip2-1.0.3-r6', iuse=['static'])))
        self.assertOut('[', Color('fg', 'green'), 'ebuild', Reset(),
            '   ', Color('fg', 'yellow'), Bold(), 'R', Reset(), '    ] ',
            Color('fg', 'green'), 'app-arch/bzip2-1.0.3-r6', Reset(),
            ' USE="(', Color('fg', 'green'), Bold(), 'static', Reset(), '*)"')

        # rebuilt pkg: new static use flag forced on
        self.formatter.format(
            FakeOp(FakeEbuildSrc('app-arch/bzip2-1.0.3-r6', iuse=['static'], use=['static']),
            FakeMutatedPkg('app-arch/bzip2-1.0.3-r6')))
        self.assertOut('[', Color('fg', 'green'), 'ebuild', Reset(),
            '   ', Color('fg', 'yellow'), Bold(), 'R', Reset(), '    ] ',
            Color('fg', 'green'), 'app-arch/bzip2-1.0.3-r6', Reset(),
            ' USE="(', Color('fg', 'yellow'), Bold(), 'static', Reset(), '%*)"')
示例#4
0
    def __init__(self, masked_use={}, forced_use={},
        provides={}, masks=[], virtuals={}, arch='x86', name='none'):
        self.provides_repo = SimpleTree(provides)
        self.masked_use = {atom(k): v for k,v in masked_use.iteritems()}
        self.forced_use = {atom(k): v for k,v in forced_use.iteritems()}
        self.masks = tuple(map(atom, masks))
        self.virtuals = SimpleTree(virtuals)
        self.arch = arch
        self.name = name

        self.forced_data = collapsed_restrict_to_data(
            [(AlwaysTrue, (self.arch,))],
            self.forced_use.iteritems())

        self.masked_data = collapsed_restrict_to_data(
            [(AlwaysTrue, default_arches)],
            self.masked_use.iteritems())
示例#5
0
 def test_disabled_use(self):
     self.formatter.disabled_use = collapsed_restrict_to_data(([(atom('=app-arch/bzip2-1.0.3-r6'),('static'))]))
     self.formatter.format(
         FakeOp(FakeEbuildSrc('app-arch/bzip2-1.0.3-r6', iuse=['static', 'bootstrap'])))
     self.assertOut('[', Color('fg', 'green'), 'ebuild', Reset(),
         '  ', Color('fg', 'green'), Bold(), 'N', Reset(), '     ] ',
         Color('fg', 'green'), 'app-arch/bzip2-1.0.3-r6', Reset(),
         ' USE="',
         Color('fg', 'blue'), Bold(), '-bootstrap', Reset(), ' ',
         '(', Color('fg', 'blue'), Bold(), '-static', Reset(), ')"')
示例#6
0
 def test_disabled_use(self):
     self.formatter.disabled_use = collapsed_restrict_to_data(
         ([(atom('=app-arch/bzip2-1.0.3-r6'), ('static'))]))
     self.formatter.format(
         FakeOp(
             FakeEbuildSrc('app-arch/bzip2-1.0.3-r6',
                           iuse=['static', 'bootstrap'])))
     self.assertOut('[', Color('fg', 'green'), 'ebuild', Reset(), '  ',
                    Color('fg', 'green'), Bold(), 'N', Reset(), '     ] ',
                    Color('fg', 'green'),
                    'app-arch/bzip2-1.0.3-r6', Reset(), ' USE="',
                    Color('fg',
                          'blue'), Bold(), '-bootstrap', Reset(), ' ', '(',
                    Color('fg', 'blue'), Bold(), '-static', Reset(), ')"')
示例#7
0
    def test_forced_use_verbose(self):
        self.formatter.forced_use = collapsed_restrict_to_data(
            ([(atom('=app-arch/bzip2-1.0.3-r6'), ('static'))]))

        # rebuilt pkg: unchanged static use flag forced on
        self.formatter.format(
            FakeOp(
                FakeEbuildSrc('app-arch/bzip2-1.0.3-r6',
                              iuse=['static'],
                              use=['static']),
                FakeMutatedPkg('app-arch/bzip2-1.0.3-r6',
                               iuse=['static'],
                               use=['static'])))
        self.assertOut('[', Color('fg', 'green'), 'ebuild', Reset(), '   ',
                       Color('fg', 'yellow'), Bold(), 'R', Reset(), '    ] ',
                       Color('fg', 'green'),
                       'app-arch/bzip2-1.0.3-r6', Reset(), ' USE="(',
                       Color('fg', 'red'), Bold(), 'static', Reset(), ')"')