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