summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2013-04-04 17:34:39 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-04-04 23:52:21 +0100
commit0e904db7da34295220841c1e96b8ddc24dfa97ee (patch)
tree66feaae496c4a96b2523dad00cb3734c1402ae67 /meta/lib
parent59e425455fb0a01a0928f366538fc8382075d85e (diff)
downloadpoky-0e904db7da34295220841c1e96b8ddc24dfa97ee.tar.gz
utils: add helper to get all non-system packages
For example if PACKAGES is "foo foo-data foo-dev foo-doc", this will return "foo-data". (From OE-Core rev: 3115187e468398a8c1edaf3e5369a2d10fb112f4) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/tests/test_utils.py27
-rw-r--r--meta/lib/oe/utils.py16
2 files changed, 43 insertions, 0 deletions
diff --git a/meta/lib/oe/tests/test_utils.py b/meta/lib/oe/tests/test_utils.py
new file mode 100644
index 0000000000..466c47eb9c
--- /dev/null
+++ b/meta/lib/oe/tests/test_utils.py
@@ -0,0 +1,27 @@
1import unittest
2import bb, oe.utils
3
4class TestPackagesFilterOutSystem(unittest.TestCase):
5 def test_filter(self):
6 """
7 Test that oe.utils.packages_filter_out_system works.
8 """
9
10 d = bb.data_smart.DataSmart()
11 d.setVar("PN", "foo")
12
13 d.setVar("PACKAGES", "foo foo-doc foo-dev")
14 pkgs = oe.utils.packages_filter_out_system(d)
15 self.assertEqual(pkgs, [])
16
17 d.setVar("PACKAGES", "foo foo-doc foo-data foo-dev")
18 pkgs = oe.utils.packages_filter_out_system(d)
19 self.assertEqual(pkgs, ["foo-data"])
20
21 d.setVar("PACKAGES", "foo foo-locale-en-gb")
22 pkgs = oe.utils.packages_filter_out_system(d)
23 self.assertEqual(pkgs, [])
24
25 d.setVar("PACKAGES", "foo foo-data foo-locale-en-gb")
26 pkgs = oe.utils.packages_filter_out_system(d)
27 self.assertEqual(pkgs, ["foo-data"])
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index b269f32277..acd39693b5 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -107,3 +107,19 @@ def features_backfill(var,d):
107 107
108 if addfeatures: 108 if addfeatures:
109 d.appendVar(var, " " + " ".join(addfeatures)) 109 d.appendVar(var, " " + " ".join(addfeatures))
110
111
112def packages_filter_out_system(d):
113 """
114 Return a list of packages from PACKAGES with the "system" packages such as
115 PN-dbg PN-doc PN-locale-eb-gb removed.
116 """
117 pn = d.getVar('PN', True)
118 blacklist = map(lambda suffix: pn + suffix, ('', '-dbg', '-dev', '-doc', '-locale', '-staticdev'))
119 localepkg = pn + "-locale-"
120 pkgs = []
121
122 for pkg in d.getVar('PACKAGES', True).split():
123 if pkg not in blacklist and localepkg not in pkg:
124 pkgs.append(pkg)
125 return pkgs