xref: /openbmc/openbmc/poky/meta/lib/oe/packagegroup.py (revision 4ed12e16)
1#
2# SPDX-License-Identifier: GPL-2.0-only
3#
4
5import itertools
6
7def is_optional(feature, d):
8    return bool(d.getVarFlag("FEATURE_PACKAGES_%s" % feature, "optional"))
9
10def packages(features, d):
11    for feature in features:
12        packages = d.getVar("FEATURE_PACKAGES_%s" % feature)
13        for pkg in (packages or "").split():
14            yield pkg
15
16def required_packages(features, d):
17    req = [feature for feature in features if not is_optional(feature, d)]
18    return packages(req, d)
19
20def optional_packages(features, d):
21    opt = [feature for feature in features if is_optional(feature, d)]
22    return packages(opt, d)
23
24def active_packages(features, d):
25    return itertools.chain(required_packages(features, d),
26                           optional_packages(features, d))
27
28def active_recipes(features, d):
29    import oe.packagedata
30
31    for pkg in active_packages(features, d):
32        recipe = oe.packagedata.recipename(pkg, d)
33        if recipe:
34            yield recipe
35