summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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]