summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic
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-27 07:24:29 +0000
commit0f75740830488f6dbca57ec434d1c444d175e304 (patch)
tree2dbb7cf00d9fe30d4263f20d5714e2841850d34d /scripts/lib/wic
parent273bcb430c103de9cd3dbfd88955343593f7ed67 (diff)
downloadpoky-0f75740830488f6dbca57ec434d1c444d175e304.tar.gz
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. (From OE-Core rev: ba127370e621b5b683d6f454596c3d0c60c13df7) Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic')
-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):
82 82
83 return out 83 return out
84 84
85def cmd_in_path(cmd, path):
86 import scriptpath
87
88 scriptpath.add_bitbake_lib_path()
89
90 return bb.utils.which(path, cmd) != "" or False
85 91
86def exec_native_cmd(cmd_and_args, native_sysroot, catch=3): 92def exec_native_cmd(cmd_and_args, native_sysroot, catch=3):
87 """ 93 """
@@ -92,15 +98,21 @@ def exec_native_cmd(cmd_and_args, native_sysroot, catch=3):
92 Always need to execute native commands as_shell 98 Always need to execute native commands as_shell
93 """ 99 """
94 native_paths = \ 100 native_paths = \
95 "export PATH=%s/sbin:%s/usr/sbin:%s/usr/bin" % \ 101 "%s/sbin:%s/usr/sbin:%s/usr/bin" % \
96 (native_sysroot, native_sysroot, native_sysroot) 102 (native_sysroot, native_sysroot, native_sysroot)
97 native_cmd_and_args = "%s;%s" % (native_paths, cmd_and_args) 103 native_cmd_and_args = "export PATH=%s:$PATH;%s" % \
104 (native_paths, cmd_and_args)
98 msger.debug("exec_native_cmd: %s" % cmd_and_args) 105 msger.debug("exec_native_cmd: %s" % cmd_and_args)
99 106
100 args = cmd_and_args.split() 107 # The reason -1 is used is because there may be "export" commands.
108 args = cmd_and_args.split(';')[-1].split()
101 msger.debug(args) 109 msger.debug(args)
102 110
103 ret, out = _exec_cmd(native_cmd_and_args, True, catch) 111 # If the command isn't in the native sysroot say we failed.
112 if cmd_in_path(args[0], native_paths):
113 ret, out = _exec_cmd(native_cmd_and_args, True, catch)
114 else:
115 ret = 127
104 116
105 if ret == 127: # shell command-not-found 117 if ret == 127: # shell command-not-found
106 prog = args[0] 118 prog = args[0]