Skip to contentSkip to conversation

wic: Fix PATH used to find commands and error if not found

PATCH New Tom Zanussi 1 participant 3 messages Feb 19, 2014

lore
Share & tools
lore
#0 lore raw

cover wic: Fix PATH used to find commands and error if not found

This fixes a problem noticed when building images in that a non-bootable image can silently be produced if a command used to build the image isn't found. The first problem is that the only the first element of the PATH was being used to look for commands, and the second is that no error is produced even if the command isn't found.

The following changes since commit 54562006c1327c5b99daa4cc05a3ba7e38412da1:

image_types.bbclass: Fix tar IMAGE_CMD to not change directories (2014-02-18 08:38:52 +0000)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib.git tzanussi/wic-native-fix
http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=tzanussi/wic-native-fix

Tom Zanussi (2):
wic: Fix exec_native_cmd() path
wic: Make exec_native_command() fail if a command isn't found

 scripts/lib/mic/utils/oe/misc.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/2 wic: Fix exec_native_cmd() path

The path exported in exec_native_cmd() includes bogus 'PATH=' which means the native paths for all but the first will be ignored.

---
 scripts/lib/mic/utils/oe/misc.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/lib/mic/utils/oe/misc.py +1 -1
index 6b01955..d65b77a 100644
@@ -74,7 +74,7 @@ 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:PATH=%s/usr/sbin:PATH=%s/usr/bin:$PATH" % \
+        "export PATH=%s/sbin:%s/usr/sbin:%s/usr/bin:$PATH" % \
         (native_sysroot, native_sysroot, native_sysroot)
     native_cmd_and_args = "%s;%s" % (native_paths, cmd_and_args)
     msger.debug("exec_native_cmd: %s" % cmd_and_args)
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/2 wic: Make exec_native_command() fail if a command isn't found

Because exec_cmd() return values can in certain cases be non-zero yet non-fatal, we don't want to automatically make them fatal (though there should at least be a warning in such cases, which this patch also does); non-zero return values are definitely fatal however if they mean that a native command wasn't found, so have exec_native_cmd() check the return value of exec_cmd() for that case, and bail out if so.

[YOCTO #5835]

---
 scripts/lib/mic/utils/oe/misc.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
scripts/lib/mic/utils/oe/misc.py +9 -2
index d65b77a..7ad3aa9 100644
@@ -51,7 +51,7 @@ def exec_cmd(cmd_and_args, as_shell = False, catch = 3):
         # parted always fails to reload part table with loop devices. This
         # prevents us from distinguishing real errors based on return
         # code.
-        msger.debug("WARNING: %s returned '%s' instead of 0" % (args[0], rc))
+        msger.warning("WARNING: %s returned '%s' instead of 0" % (cmd_and_args, rc))
 
     return (rc, out)
 
@@ -82,7 +82,14 @@ def exec_native_cmd(cmd_and_args, native_sysroot, catch = 3):
     args = cmd_and_args.split()
     msger.debug(args)
 
-    return exec_cmd(native_cmd_and_args, True, catch)
+    rc, out = exec_cmd(native_cmd_and_args, True, catch)
+
+    if rc == 127: # shell command-not-found
+        msger.error("A native (host) program required to build the image "
+                    "was not found (see details above). Please make sure "
+                    "it's installed and try again.")
+
+    return (rc, out)
 
 
 def exec_native_cmd_quiet(cmd_and_args, native_sysroot):
Signature · 1 line
1.8.3.1