All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] utils: add helper to get all non-system packages
@ 2013-04-04 16:34 Ross Burton
  0 siblings, 0 replies; only message in thread
From: Ross Burton @ 2013-04-04 16:34 UTC (permalink / raw)
  To: openembedded-core

For example if PACKAGES is "foo foo-data foo-dev foo-doc", this will return
"foo-data".

Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/lib/oe/tests/test_utils.py |   27 +++++++++++++++++++++++++++
 meta/lib/oe/utils.py            |   16 ++++++++++++++++
 2 files changed, 43 insertions(+)
 create mode 100644 meta/lib/oe/tests/test_utils.py

diff --git a/meta/lib/oe/tests/test_utils.py b/meta/lib/oe/tests/test_utils.py
new file mode 100644
index 0000000..466c47e
--- /dev/null
+++ b/meta/lib/oe/tests/test_utils.py
@@ -0,0 +1,27 @@
+import unittest
+import bb, oe.utils
+
+class TestPackagesFilterOutSystem(unittest.TestCase):
+    def test_filter(self):
+        """
+        Test that oe.utils.packages_filter_out_system works.
+        """
+
+        d = bb.data_smart.DataSmart()
+        d.setVar("PN", "foo")
+
+        d.setVar("PACKAGES", "foo foo-doc foo-dev")
+        pkgs = oe.utils.packages_filter_out_system(d)
+        self.assertEqual(pkgs, [])
+
+        d.setVar("PACKAGES", "foo foo-doc foo-data foo-dev")
+        pkgs = oe.utils.packages_filter_out_system(d)
+        self.assertEqual(pkgs, ["foo-data"])
+
+        d.setVar("PACKAGES", "foo foo-locale-en-gb")
+        pkgs = oe.utils.packages_filter_out_system(d)
+        self.assertEqual(pkgs, [])
+
+        d.setVar("PACKAGES", "foo foo-data foo-locale-en-gb")
+        pkgs = oe.utils.packages_filter_out_system(d)
+        self.assertEqual(pkgs, ["foo-data"])
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index b269f32..acd3969 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -107,3 +107,19 @@ def features_backfill(var,d):
 
     if addfeatures:
         d.appendVar(var, " " + " ".join(addfeatures))
+
+
+def packages_filter_out_system(d):
+    """
+    Return a list of packages from PACKAGES with the "system" packages such as
+    PN-dbg PN-doc PN-locale-eb-gb removed.
+    """
+    pn = d.getVar('PN', True)
+    blacklist = map(lambda suffix: pn + suffix, ('', '-dbg', '-dev', '-doc', '-locale', '-staticdev'))
+    localepkg = pn + "-locale-"
+    pkgs = []
+
+    for pkg in d.getVar('PACKAGES', True).split():
+        if pkg not in blacklist and localepkg not in pkg:
+            pkgs.append(pkg)
+    return pkgs
-- 
1.7.10.4




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-04-04 16:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-04 16:34 [PATCH] utils: add helper to get all non-system packages Ross Burton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.