summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils
diff options
context:
space:
mode:
authorCorneliu Stoicescu <corneliux.stoicescu@intel.com>2014-06-05 12:29:44 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-06-10 17:24:17 +0100
commita934aebcb84d5a5694a8b69c6d4a299831bf93a2 (patch)
treedfd2f16cebf50e66cc9d74ed269ee9ba86f6b912 /meta/lib/oeqa/utils
parentaed4216e86d1b3223234c15445a348e1dd04f7be (diff)
downloadpoky-a934aebcb84d5a5694a8b69c6d4a299831bf93a2.tar.gz
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() (From OE-Core rev: 4fe771940a8f59a0d5f1541978d6d9ff73b222f4) Signed-off-by: Corneliu Stoicescu <corneliux.stoicescu@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r--meta/lib/oeqa/utils/commands.py31
1 files changed, 22 insertions, 9 deletions
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index 7637b9def8..802bc2f208 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -15,6 +15,7 @@ import subprocess
15import threading 15import threading
16import logging 16import logging
17from oeqa.utils import CommandError 17from oeqa.utils import CommandError
18from oeqa.utils import ftools
18 19
19class Command(object): 20class Command(object):
20 def __init__(self, command, bg=False, timeout=None, data=None, **options): 21 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
106 return result 107 return result
107 108
108 109
109def bitbake(command, ignore_status=False, timeout=None, **options): 110def bitbake(command, ignore_status=False, timeout=None, postconfig=None, **options):
111
112 if postconfig:
113 postconfig_file = os.path.join(os.environ.get('BUILDDIR'), 'oeqa-post.conf')
114 ftools.write_file(postconfig_file, postconfig)
115 extra_args = "-R %s" % postconfig_file
116 else:
117 extra_args = ""
118
110 if isinstance(command, basestring): 119 if isinstance(command, basestring):
111 cmd = "bitbake " + command 120 cmd = "bitbake " + extra_args + " " + command
112 else: 121 else:
113 cmd = [ "bitbake" ] + command 122 cmd = [ "bitbake" ] + [a for a in (command + extra_args.split(" ")) if a not in [""]]
114 123
115 return runCmd(cmd, ignore_status, timeout, **options) 124 try:
125 return runCmd(cmd, ignore_status, timeout, **options)
126 finally:
127 if postconfig:
128 os.remove(postconfig_file)
116 129
117 130
118def get_bb_env(target=None): 131def get_bb_env(target=None, postconfig=None):
119 if target: 132 if target:
120 return runCmd("bitbake -e %s" % target).output 133 return bitbake("-e %s" % target, postconfig=postconfig).output
121 else: 134 else:
122 return runCmd("bitbake -e").output 135 return bitbake("-e", postconfig=postconfig).output
123 136
124def get_bb_var(var, target=None): 137def get_bb_var(var, target=None, postconfig=None):
125 val = None 138 val = None
126 bbenv = get_bb_env(target) 139 bbenv = get_bb_env(target, postconfig=postconfig)
127 for line in bbenv.splitlines(): 140 for line in bbenv.splitlines():
128 if line.startswith(var + "="): 141 if line.startswith(var + "="):
129 val = line.split('=')[1] 142 val = line.split('=')[1]