1*eb8dc403SDave Cobbleyimport itertools 2*eb8dc403SDave Cobbley 3*eb8dc403SDave Cobbleydef is_optional(feature, d): 4*eb8dc403SDave Cobbley packages = d.getVar("FEATURE_PACKAGES_%s" % feature) 5*eb8dc403SDave Cobbley if packages: 6*eb8dc403SDave Cobbley return bool(d.getVarFlag("FEATURE_PACKAGES_%s" % feature, "optional")) 7*eb8dc403SDave Cobbley else: 8*eb8dc403SDave Cobbley return bool(d.getVarFlag("PACKAGE_GROUP_%s" % feature, "optional")) 9*eb8dc403SDave Cobbley 10*eb8dc403SDave Cobbleydef packages(features, d): 11*eb8dc403SDave Cobbley for feature in features: 12*eb8dc403SDave Cobbley packages = d.getVar("FEATURE_PACKAGES_%s" % feature) 13*eb8dc403SDave Cobbley if not packages: 14*eb8dc403SDave Cobbley packages = d.getVar("PACKAGE_GROUP_%s" % feature) 15*eb8dc403SDave Cobbley for pkg in (packages or "").split(): 16*eb8dc403SDave Cobbley yield pkg 17*eb8dc403SDave Cobbley 18*eb8dc403SDave Cobbleydef required_packages(features, d): 19*eb8dc403SDave Cobbley req = [feature for feature in features if not is_optional(feature, d)] 20*eb8dc403SDave Cobbley return packages(req, d) 21*eb8dc403SDave Cobbley 22*eb8dc403SDave Cobbleydef optional_packages(features, d): 23*eb8dc403SDave Cobbley opt = [feature for feature in features if is_optional(feature, d)] 24*eb8dc403SDave Cobbley return packages(opt, d) 25*eb8dc403SDave Cobbley 26*eb8dc403SDave Cobbleydef active_packages(features, d): 27*eb8dc403SDave Cobbley return itertools.chain(required_packages(features, d), 28*eb8dc403SDave Cobbley optional_packages(features, d)) 29*eb8dc403SDave Cobbley 30*eb8dc403SDave Cobbleydef active_recipes(features, d): 31*eb8dc403SDave Cobbley import oe.packagedata 32*eb8dc403SDave Cobbley 33*eb8dc403SDave Cobbley for pkg in active_packages(features, d): 34*eb8dc403SDave Cobbley recipe = oe.packagedata.recipename(pkg, d) 35*eb8dc403SDave Cobbley if recipe: 36*eb8dc403SDave Cobbley yield recipe 37