summaryrefslogtreecommitdiff
path: root/scripts/lib/wic/utils
diff options
context:
space:
mode:
authorRandy Witt <randy.e.witt@linux.intel.com>2015-10-22 19:53:56 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-10-24 12:21:28 +0100
commitba127370e621b5b683d6f454596c3d0c60c13df7 (patch)
tree5187037cf4f4e7e0f40b64459ba063be62a78cc1 /scripts/lib/wic/utils
parentba3493c434ced719135082607e5f2e1d87559952 (diff)
downloadopenembedded-core-ba127370e621b5b683d6f454596c3d0c60c13df7.tar.gz
openembedded-core-ba127370e621b5b683d6f454596c3d0c60c13df7.tar.bz2
openembedded-core-ba127370e621b5b683d6f454596c3d0c60c13df7.zip
wic/utils/oe/misc.py: Preserve PATH when running native tools
Previously exec_native_cmd() would remove all items from PATH except for the native sysroot. This can cause issues for the tools that are created using create_wrapper(). Now instead of wiping out the PATH, run a sanity check to check if the command is in the native sysroot. Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'scripts/lib/wic/utils')
-rw-r--r--scripts/lib/wic/utils/oe/misc.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/scripts/lib/wic/utils/oe/misc.py b/scripts/lib/wic/utils/oe/misc.py
index 7370d93136..c6d2e5f204 100644
--- a/scripts/lib/wic/utils/oe/misc.py
+++ b/scripts/lib/wic/utils/oe/misc.py
@@ -82,6 +82,12 @@ def exec_cmd(cmd_and_args, as_shell=False, catch=3):
return out
+def cmd_in_path(cmd, path):
+ import scriptpath
+
+ scriptpath.add_bitbake_lib_path()
+
+ return bb.utils.which(path, cmd) != "" or False
def exec_native_cmd(cmd_and_args, native_sysroot, catch=3):
"""
@@ -92,15 +98,21 @@ def exec_native_cmd(cmd_and_args, native_sysroot, catch=3):
Always need to execute native commands as_shell
"""
native_paths = \
- "export PATH=%s/sbin:%s/usr/sbin:%s/usr/bin" % \
+ "%s/sbin:%s/usr/sbin:%s/usr/bin" % \
(native_sysroot, native_sysroot, native_sysroot)
- native_cmd_and_args = "%s;%s" % (native_paths, cmd_and_args)
+ native_cmd_and_args = "export PATH=%s:$PATH;%s" % \
+ (native_paths, cmd_and_args)
msger.debug("exec_native_cmd: %s" % cmd_and_args)
- args = cmd_and_args.split()
+ # The reason -1 is used is because there may be "export" commands.
+ args = cmd_and_args.split(';')[-1].split()
msger.debug(args)
- ret, out = _exec_cmd(native_cmd_and_args, True, catch)
+ # If the command isn't in the native sysroot say we failed.
+ if cmd_in_path(args[0], native_paths):
+ ret, out = _exec_cmd(native_cmd_and_args, True, catch)
+ else:
+ ret = 127
if ret == 127: # shell command-not-found
prog = args[0]