[OE-core] [PATCH] devshell.bbclass/terminal.bbclass: add a shell check at devshell
Hongxu Jia
hongxu.jia at windriver.com
Mon Nov 26 01:57:00 UTC 2018
Ping, any comments?
//Hongxu
On 2018/9/3 下午3:09, Hongxu Jia wrote:
> 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>
> ---
> 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)
More information about the Openembedded-core
mailing list