From patchwork Thu Mar 17 16:19:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [08/12] oe.packagegroup: add code for package groups (sync from OE) Date: Thu, 17 Mar 2011 16:19:06 -0000 From: Christopher Larson X-Patchwork-Id: 1539 Message-Id: <773e020cdee73dcff4a2c487e26fe817c22e1fa5.1300378596.git.chris_larson@mentor.com> To: openembedded-core@lists.openembedded.org Cc: Chris Larson From: Chris Larson This includes some utility functions for dealing with groups of packages defined in the metadata. Metadata syntax: PACKAGE_GROUP_ = "" If the packages in the group are optional: PACKAGE_GROUP_[optional] = "1" Signed-off-by: Chris Larson --- meta/classes/base.bbclass | 2 +- meta/lib/oe/packagegroup.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletions(-) create mode 100644 meta/lib/oe/packagegroup.py diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass index 27a68de..8e8d572 100644 --- a/meta/classes/base.bbclass +++ b/meta/classes/base.bbclass @@ -9,7 +9,7 @@ inherit utility-tasks inherit metadata_scm inherit buildstats -OE_IMPORTS += "sys os time oe.path oe.utils oe.data" +OE_IMPORTS += "sys os time oe.path oe.utils oe.data oe.packagegroup" def oe_import(d): import os, sys diff --git a/meta/lib/oe/packagegroup.py b/meta/lib/oe/packagegroup.py new file mode 100644 index 0000000..b04c45a --- /dev/null +++ b/meta/lib/oe/packagegroup.py @@ -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