oe.packagegroup: add code for package groups (sync from OE)

This includes some utility functions for dealing with groups of packages
defined in the metadata.  Metadata syntax:

    PACKAGE_GROUP_<group> = "<list of packages>"

If the packages in the group are optional:

    PACKAGE_GROUP_<group>[optional] = "1"

(From OE-Core rev: 4df212e9c2a1dd7c80d180fd13b67e9f2799d3e1)

Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Chris Larson 2010-10-08 20:05:06 -07:00 committed by Richard Purdie
parent fc55b224ca
commit 2a05bd9be0
2 changed files with 30 additions and 1 deletions

View File

@ -10,7 +10,7 @@ inherit metadata_scm
inherit buildstats
inherit logging
OE_IMPORTS += "os sys time oe.path oe.utils oe.data"
OE_IMPORTS += "os sys time oe.path oe.utils oe.data oe.packagegroup"
OE_IMPORTS[type] = "list"
def oe_import(d):

View File

@ -0,0 +1,29 @@
import itertools
def is_optional(group, d):
return bool(d.getVarFlag("PACKAGE_GROUP_%s" % group, "optional"))
def packages(groups, d):
for group in groups:
for pkg in (d.getVar("PACKAGE_GROUP_%s" % group, True) or "").split():
yield pkg
def required_packages(groups, d):
req = filter(lambda group: not is_optional(group, d), groups)
return packages(req, d)
def optional_packages(groups, d):
opt = filter(lambda group: is_optional(group, d), groups)
return packages(opt, d)
def active_packages(features, d):
return itertools.chain(required_packages(features, d),
optional_packages(features, d))
def active_recipes(features, d):
import oe.packagedata
for pkg in active_packages(features, d):
recipe = oe.packagedata.recipename(pkg, d)
if recipe:
yield recipe