Bug 7614 - devtool within extensible SDK does not work with dash as /bin/sh
Summary: devtool within extensible SDK does not work with dash as /bin/sh
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: devtools / tool chain (show other bugs)
Version: 1.8
Hardware: All Multiple
: Undecided normal
Target Milestone: 1.9 M1
Assignee: Paul Eggleton
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2015-04-15 18:07 UTC by Paul Eggleton
Modified: 2015-04-26 12:41 UTC (History)
4 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Eggleton 2015-04-15 18:07:14 UTC
If you have dash as /bin/sh (as you do by default on Ubuntu), running devtool within the SDK does not work, because apparently oe-init-build-env does not work the same way under dash as it does under bash. 

"devtool add" fails because oe-init-build-env looks in the wrong place for oe-buildenv-internal; this is because oe-init-build-env falls back to the current directory as OEROOT when not under bash/zsh.

If we work around that by setting the current directory to the actual OE root, when we run "devtool build", bitbake claims that the specified recipe doesn't exist because a new build directory is being created instead of the one we've already set up, and that new one doesn't have the workspace layer in its bblayers.conf. This is apparently because any argument you pass to a sourced script (in this case, the build directory) doesn't actually get passed to the script.
Comment 1 Chen Qi 2015-04-17 07:18:33 UTC
Hi Paul,

How about setting executable to bash like below?

Regards,
Chen Qi

diff --git a/scripts/lib/devtool/__init__.py b/scripts/lib/devtool/__init__.py
index 3f8158e..7e7908d 100644
--- a/scripts/lib/devtool/__init__.py
+++ b/scripts/lib/devtool/__init__.py
@@ -27,6 +27,10 @@ logger = logging.getLogger('devtool')
 
 def exec_build_env_command(init_path, builddir, cmd, watch=False, **options):
     import bb
+    # As the init script makes use of BASH_SOURCE to determine OEROOT, we need to set
+    # executable to bash to correctly set things up
+    if not 'executable' in options:
+        options["executable"] = 'bash'
     if not 'cwd' in options:
         options["cwd"] = builddir
     if init_path:
Comment 2 Paul Eggleton 2015-04-17 08:41:35 UTC
I asked Richard about this and his suggestion was to set BDIR instead (having ensured that the current directory is set to avoid the first issue).
Comment 3 Richard Purdie 2015-04-18 09:14:13 UTC
To be honest I'm flexible with either approach...
Comment 4 Paul Eggleton 2015-04-20 16:49:38 UTC
OK, on reflection I've taken Qi's fix as it's simpler (thanks Qi!).