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