All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] wic: Fix PATH used to find commands and error if not found
@ 2014-02-19 20:53 Tom Zanussi
  2014-02-19 20:53 ` [PATCH 1/2] wic: Fix exec_native_cmd() path Tom Zanussi
  2014-02-19 20:53 ` [PATCH 2/2] wic: Make exec_native_command() fail if a command isn't found Tom Zanussi
  0 siblings, 2 replies; 3+ messages in thread
From: Tom Zanussi @ 2014-02-19 20:53 UTC (permalink / raw)
  To: openembedded-core; +Cc: Tom Zanussi

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(-)

-- 
1.8.3.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] wic: Fix exec_native_cmd() path
  2014-02-19 20:53 [PATCH 0/2] wic: Fix PATH used to find commands and error if not found Tom Zanussi
@ 2014-02-19 20:53 ` Tom Zanussi
  2014-02-19 20:53 ` [PATCH 2/2] wic: Make exec_native_command() fail if a command isn't found Tom Zanussi
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Zanussi @ 2014-02-19 20:53 UTC (permalink / raw)
  To: openembedded-core; +Cc: Tom Zanussi

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

Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
---
 scripts/lib/mic/utils/oe/misc.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/lib/mic/utils/oe/misc.py b/scripts/lib/mic/utils/oe/misc.py
index 6b01955..d65b77a 100644
--- a/scripts/lib/mic/utils/oe/misc.py
+++ b/scripts/lib/mic/utils/oe/misc.py
@@ -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)
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] wic: Make exec_native_command() fail if a command isn't found
  2014-02-19 20:53 [PATCH 0/2] wic: Fix PATH used to find commands and error if not found Tom Zanussi
  2014-02-19 20:53 ` [PATCH 1/2] wic: Fix exec_native_cmd() path Tom Zanussi
@ 2014-02-19 20:53 ` Tom Zanussi
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Zanussi @ 2014-02-19 20:53 UTC (permalink / raw)
  To: openembedded-core; +Cc: Tom Zanussi

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]

Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
---
 scripts/lib/mic/utils/oe/misc.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/scripts/lib/mic/utils/oe/misc.py b/scripts/lib/mic/utils/oe/misc.py
index d65b77a..7ad3aa9 100644
--- a/scripts/lib/mic/utils/oe/misc.py
+++ b/scripts/lib/mic/utils/oe/misc.py
@@ -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):
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-02-19 20:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-19 20:53 [PATCH 0/2] wic: Fix PATH used to find commands and error if not found Tom Zanussi
2014-02-19 20:53 ` [PATCH 1/2] wic: Fix exec_native_cmd() path Tom Zanussi
2014-02-19 20:53 ` [PATCH 2/2] wic: Make exec_native_command() fail if a command isn't found Tom Zanussi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.