[OE-core] [PATCH] devshell.bbclass/terminal.bbclass: add a shell check at devshell

Peter Kjellerstedt peter.kjellerstedt at axis.com
Tue Nov 27 19:37:53 UTC 2018


> -----Original Message-----
> From: openembedded-core-bounces at lists.openembedded.org <openembedded-
> core-bounces at lists.openembedded.org> On Behalf Of Hongxu Jia
> Sent: den 26 november 2018 02:57
> To: openembedded-core at lists.openembedded.org; Richard Purdie
> <richard.purdie at linuxfoundation.org>
> Subject: Re: [OE-core] [PATCH] devshell.bbclass/terminal.bbclass: add a
> shell check at devshell
> 
> 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'

I simply fail to understand why all this messing around is needed. 
Why use ${SHELL} at all? Why not always use /bin/sh? We know it 
is either /bin/bash or /bin/dash, and either should be fine to use 
to run the wrapper script.

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

//Peter



More information about the Openembedded-core mailing list