summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
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