[oe-commits] [openembedded-core] 12/13: devshell.bbclass/terminal.bbclass: add a shell check at devshell

git at git.openembedded.org git at git.openembedded.org
Tue Sep 4 12:17:35 UTC 2018


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit fea72bdcf4691f78672f1e3038e3665c05fe4efe
Author: Hongxu Jia <hongxu.jia at windriver.com>
AuthorDate: Mon Sep 3 15:09:56 2018 +0800

    devshell.bbclass/terminal.bbclass: add a shell check at devshell
    
    While var-SHELL is neither `bash' or `dash', such as
    `csh', loading the wrapper script will fail at devshell,
    because csh does not support syntax `export'.
    
    Add a shell check at devshell, and use `/bin/sh' to replace
    if shell is neither `bash' or `dash'. `/bin/sh' is safe to
    use since `ecdfdd7 sanity.bbclass: check /bin/sh is dash
    or bash'
    
    Signed-off-by: Hongxu Jia <hongxu.jia at windriver.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/classes/devshell.bbclass | 4 ++++
 meta/classes/terminal.bbclass | 4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/meta/classes/devshell.bbclass b/meta/classes/devshell.bbclass
index fdf7dc1..c4765db 100644
--- a/meta/classes/devshell.bbclass
+++ b/meta/classes/devshell.bbclass
@@ -3,6 +3,10 @@ inherit terminal
 DEVSHELL = "${SHELL}"
 
 python do_devshell () {
+    devshell = d.getVar('DEVSHELL')
+    devshell = devshell if devshell.endswith("bash") or devshell.endswith("dash") else '/bin/sh'
+    d.setVar('DEVSHELL', devshell)
+
     if d.getVarFlag("do_devshell", "manualfakeroot"):
        d.prependVar("DEVSHELL", "pseudo ")
        fakeenv = d.getVar("FAKEROOTENV").split()
diff --git a/meta/classes/terminal.bbclass b/meta/classes/terminal.bbclass
index 73e765d..f427538 100644
--- a/meta/classes/terminal.bbclass
+++ b/meta/classes/terminal.bbclass
@@ -25,7 +25,9 @@ def emit_terminal_func(command, envdata, d):
     bb.utils.mkdirhier(os.path.dirname(runfile))
 
     with open(runfile, 'w') as script:
-        script.write('#!/usr/bin/env %s\n' % d.getVar('SHELL'))
+        shell = d.getVar('SHELL')
+        shell = shell if shell.endswith("bash") or shell.endswith("dash") else '/bin/sh'
+        script.write('#!/usr/bin/env %s\n' % shell)
         script.write('set -e\n')
         bb.data.emit_func(cmd_func, script, envdata)
         script.write(cmd_func)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list