[oe-commits] Corneliu Stoicescu : oeqa/utils/commands.py: add support for postconfig option

git at git.openembedded.org git at git.openembedded.org
Tue Jun 10 16:44:20 UTC 2014


Module: openembedded-core.git
Branch: master-next
Commit: 4fe771940a8f59a0d5f1541978d6d9ff73b222f4
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=4fe771940a8f59a0d5f1541978d6d9ff73b222f4

Author: Corneliu Stoicescu <corneliux.stoicescu at intel.com>
Date:   Thu Jun  5 12:29:44 2014 +0300

oeqa/utils/commands.py: add support for postconfig option

Adding support for postconfig option to the bitbake() and related methods.

This enables us to use 'bitbake -R postconfig_file <command>'.

Usage: bitbake(cmd, postconfig="some confguration")

'postconfig_file' would contain what we add in 'postconfig'

Other methods affected: get_bb_env(), get_bb_var()

Signed-off-by: Corneliu Stoicescu <corneliux.stoicescu at intel.com>
Signed-off-by: Saul Wold <sgw at linux.intel.com>

---

 meta/lib/oeqa/utils/commands.py | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index 7637b9d..802bc2f 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -15,6 +15,7 @@ import subprocess
 import threading
 import logging
 from oeqa.utils import CommandError
+from oeqa.utils import ftools
 
 class Command(object):
     def __init__(self, command, bg=False, timeout=None, data=None, **options):
@@ -106,24 +107,36 @@ def runCmd(command, ignore_status=False, timeout=None, assert_error=True, **opti
     return result
 
 
-def bitbake(command, ignore_status=False, timeout=None, **options):
+def bitbake(command, ignore_status=False, timeout=None, postconfig=None, **options):
+
+    if postconfig:
+	postconfig_file = os.path.join(os.environ.get('BUILDDIR'), 'oeqa-post.conf')
+	ftools.write_file(postconfig_file, postconfig)
+	extra_args = "-R %s" % postconfig_file
+    else:
+	extra_args = ""
+
     if isinstance(command, basestring):
-        cmd = "bitbake " + command
+        cmd = "bitbake " + extra_args + " " + command
     else:
-        cmd = [ "bitbake" ] + command
+        cmd = [ "bitbake" ] + [a for a in (command + extra_args.split(" ")) if a not in [""]]
 
-    return runCmd(cmd, ignore_status, timeout, **options)
+    try:
+	return runCmd(cmd, ignore_status, timeout, **options)
+    finally:
+        if postconfig:
+            os.remove(postconfig_file)
 
 
-def get_bb_env(target=None):
+def get_bb_env(target=None, postconfig=None):
     if target:
-        return runCmd("bitbake -e %s" % target).output
+        return bitbake("-e %s" % target, postconfig=postconfig).output
     else:
-        return runCmd("bitbake -e").output
+        return bitbake("-e", postconfig=postconfig).output
 
-def get_bb_var(var, target=None):
+def get_bb_var(var, target=None, postconfig=None):
     val = None
-    bbenv = get_bb_env(target)
+    bbenv = get_bb_env(target, postconfig=postconfig)
     for line in bbenv.splitlines():
         if line.startswith(var + "="):
             val = line.split('=')[1]



More information about the Openembedded-commits mailing list