diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-10-08 20:05:06 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-05-20 19:07:51 +0100 |
commit | 2a05bd9be0cb3961f394035bf0f4561283248a83 (patch) | |
tree | 50efb2015b26617277a6986aa5306da6ebf60d36 | |
parent | fc55b224caa3eeac4abda099ec9ed505db59fb28 (diff) | |
download | poky-2a05bd9be0cb3961f394035bf0f4561283248a83.tar.gz |
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>
-rw-r--r-- | meta/classes/base.bbclass | 2 | ||||
-rw-r--r-- | meta/lib/oe/packagegroup.py | 29 |
2 files changed, 30 insertions, 1 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass index f357dceefd..358b501e57 100644 --- a/meta/classes/base.bbclass +++ b/meta/classes/base.bbclass | |||
@@ -10,7 +10,7 @@ inherit metadata_scm | |||
10 | inherit buildstats | 10 | inherit buildstats |
11 | inherit logging | 11 | inherit logging |
12 | 12 | ||
13 | OE_IMPORTS += "os sys time oe.path oe.utils oe.data" | 13 | OE_IMPORTS += "os sys time oe.path oe.utils oe.data oe.packagegroup" |
14 | OE_IMPORTS[type] = "list" | 14 | OE_IMPORTS[type] = "list" |
15 | 15 | ||
16 | def oe_import(d): | 16 | def oe_import(d): |
diff --git a/meta/lib/oe/packagegroup.py b/meta/lib/oe/packagegroup.py new file mode 100644 index 0000000000..b04c45a1af --- /dev/null +++ b/meta/lib/oe/packagegroup.py | |||
@@ -0,0 +1,29 @@ | |||
1 | import itertools | ||
2 | |||
3 | def is_optional(group, d): | ||
4 | return bool(d.getVarFlag("PACKAGE_GROUP_%s" % group, "optional")) | ||
5 | |||
6 | def packages(groups, d): | ||
7 | for group in groups: | ||
8 | for pkg in (d.getVar("PACKAGE_GROUP_%s" % group, True) or "").split(): | ||
9 | yield pkg | ||
10 | |||
11 | def required_packages(groups, d): | ||
12 | req = filter(lambda group: not is_optional(group, d), groups) | ||
13 | return packages(req, d) | ||
14 | |||
15 | def optional_packages(groups, d): | ||
16 | opt = filter(lambda group: is_optional(group, d), groups) | ||
17 | return packages(opt, d) | ||
18 | |||
19 | def active_packages(features, d): | ||
20 | return itertools.chain(required_packages(features, d), | ||
21 | optional_packages(features, d)) | ||
22 | |||
23 | def active_recipes(features, d): | ||
24 | import oe.packagedata | ||
25 | |||
26 | for pkg in active_packages(features, d): | ||
27 | recipe = oe.packagedata.recipename(pkg, d) | ||
28 | if recipe: | ||
29 | yield recipe | ||