summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/packagegroup.py
blob: 8fcaecde822d6b1a4160c410cf9c98115ed694b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#
# SPDX-License-Identifier: GPL-2.0-only
#

import itertools

def is_optional(feature, d):
    return bool(d.getVarFlag("FEATURE_PACKAGES_%s" % feature, "optional"))

def packages(features, d):
    for feature in features:
        packages = d.getVar("FEATURE_PACKAGES_%s" % feature)
        for pkg in (packages or "").split():
            yield pkg

def required_packages(features, d):
    req = [feature for feature in features if not is_optional(feature, d)]
    return packages(req, d)

def optional_packages(features, d):
    opt = [feature for feature in features if is_optional(feature, d)]
    return packages(opt, d)

def active_packages(features, d):
    return itertools.chain(required_packages(features, d),
                           optional_packages(features, d))

def active_recipes(features, d):
    import oe.packagedata

    for pkg in active_packages(features, d):
        recipe = oe.packagedata.recipename(pkg, d)
        if recipe:
            yield recipe