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