diff options
Diffstat (limited to 'scripts/lib')
| -rw-r--r-- | scripts/lib/wic/utils/oe/misc.py | 20 |
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 | ||
| 85 | def 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 | ||
| 86 | def exec_native_cmd(cmd_and_args, native_sysroot, catch=3): | 92 | def 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] |
