blob: 4bc5d3e4bb226adc46f21ae7db0e34582d2cdf6c [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001import itertools
2
3def is_optional(feature, d):
Brad Bishop6e60e8b2018-02-01 10:27:11 -05004 packages = d.getVar("FEATURE_PACKAGES_%s" % feature)
Patrick Williamsc124f4f2015-09-15 14:41:29 -05005 if packages:
Brad Bishop6e60e8b2018-02-01 10:27:11 -05006 return bool(d.getVarFlag("FEATURE_PACKAGES_%s" % feature, "optional"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007 else:
Brad Bishop6e60e8b2018-02-01 10:27:11 -05008 return bool(d.getVarFlag("PACKAGE_GROUP_%s" % feature, "optional"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009
10def packages(features, d):
11 for feature in features:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050012 packages = d.getVar("FEATURE_PACKAGES_%s" % feature)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050013 if not packages:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050014 packages = d.getVar("PACKAGE_GROUP_%s" % feature)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050015 for pkg in (packages or "").split():
16 yield pkg
17
18def required_packages(features, d):
Patrick Williamsc0f7c042017-02-23 20:41:17 -060019 req = [feature for feature in features if not is_optional(feature, d)]
Patrick Williamsc124f4f2015-09-15 14:41:29 -050020 return packages(req, d)
21
22def optional_packages(features, d):
Patrick Williamsc0f7c042017-02-23 20:41:17 -060023 opt = [feature for feature in features if is_optional(feature, d)]
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024 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