diff options
Diffstat (limited to 'scripts/lib/wic/misc.py')
-rw-r--r-- | scripts/lib/wic/misc.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/scripts/lib/wic/misc.py b/scripts/lib/wic/misc.py index e4b5a0d519..3e11822996 100644 --- a/scripts/lib/wic/misc.py +++ b/scripts/lib/wic/misc.py | |||
@@ -16,9 +16,9 @@ import logging | |||
16 | import os | 16 | import os |
17 | import re | 17 | import re |
18 | import subprocess | 18 | import subprocess |
19 | import shutil | ||
19 | 20 | ||
20 | from collections import defaultdict | 21 | from collections import defaultdict |
21 | from distutils import spawn | ||
22 | 22 | ||
23 | from wic import WicError | 23 | from wic import WicError |
24 | 24 | ||
@@ -26,6 +26,7 @@ logger = logging.getLogger('wic') | |||
26 | 26 | ||
27 | # executable -> recipe pairs for exec_native_cmd | 27 | # executable -> recipe pairs for exec_native_cmd |
28 | NATIVE_RECIPES = {"bmaptool": "bmap-tools", | 28 | NATIVE_RECIPES = {"bmaptool": "bmap-tools", |
29 | "dumpe2fs": "e2fsprogs", | ||
29 | "grub-mkimage": "grub-efi", | 30 | "grub-mkimage": "grub-efi", |
30 | "isohybrid": "syslinux", | 31 | "isohybrid": "syslinux", |
31 | "mcopy": "mtools", | 32 | "mcopy": "mtools", |
@@ -45,7 +46,8 @@ NATIVE_RECIPES = {"bmaptool": "bmap-tools", | |||
45 | "parted": "parted", | 46 | "parted": "parted", |
46 | "sfdisk": "util-linux", | 47 | "sfdisk": "util-linux", |
47 | "sgdisk": "gptfdisk", | 48 | "sgdisk": "gptfdisk", |
48 | "syslinux": "syslinux" | 49 | "syslinux": "syslinux", |
50 | "tar": "tar" | ||
49 | } | 51 | } |
50 | 52 | ||
51 | def runtool(cmdln_or_args): | 53 | def runtool(cmdln_or_args): |
@@ -112,6 +114,15 @@ def exec_cmd(cmd_and_args, as_shell=False): | |||
112 | """ | 114 | """ |
113 | return _exec_cmd(cmd_and_args, as_shell)[1] | 115 | return _exec_cmd(cmd_and_args, as_shell)[1] |
114 | 116 | ||
117 | def find_executable(cmd, paths): | ||
118 | recipe = cmd | ||
119 | if recipe in NATIVE_RECIPES: | ||
120 | recipe = NATIVE_RECIPES[recipe] | ||
121 | provided = get_bitbake_var("ASSUME_PROVIDED") | ||
122 | if provided and "%s-native" % recipe in provided: | ||
123 | return True | ||
124 | |||
125 | return shutil.which(cmd, path=paths) | ||
115 | 126 | ||
116 | def exec_native_cmd(cmd_and_args, native_sysroot, pseudo=""): | 127 | def exec_native_cmd(cmd_and_args, native_sysroot, pseudo=""): |
117 | """ | 128 | """ |
@@ -140,7 +151,7 @@ def exec_native_cmd(cmd_and_args, native_sysroot, pseudo=""): | |||
140 | logger.debug("exec_native_cmd: %s", native_cmd_and_args) | 151 | logger.debug("exec_native_cmd: %s", native_cmd_and_args) |
141 | 152 | ||
142 | # If the command isn't in the native sysroot say we failed. | 153 | # If the command isn't in the native sysroot say we failed. |
143 | if spawn.find_executable(args[0], native_paths): | 154 | if find_executable(args[0], native_paths): |
144 | ret, out = _exec_cmd(native_cmd_and_args, True) | 155 | ret, out = _exec_cmd(native_cmd_and_args, True) |
145 | else: | 156 | else: |
146 | ret = 127 | 157 | ret = 127 |