All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] devshell.bbclass/terminal.bbclass: add a shell check at devshell
@ 2018-09-03  7:09 Hongxu Jia
  2018-11-26  1:57 ` Hongxu Jia
  0 siblings, 1 reply; 3+ messages in thread
From: Hongxu Jia @ 2018-09-03  7:09 UTC (permalink / raw)
  To: openembedded-core, ross.burton

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



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

* Re: [PATCH] devshell.bbclass/terminal.bbclass: add a shell check at devshell
  2018-09-03  7:09 [PATCH] devshell.bbclass/terminal.bbclass: add a shell check at devshell Hongxu Jia
@ 2018-11-26  1:57 ` Hongxu Jia
  2018-11-27 19:37   ` Peter Kjellerstedt
  0 siblings, 1 reply; 3+ messages in thread
From: Hongxu Jia @ 2018-11-26  1:57 UTC (permalink / raw)
  To: openembedded-core, Richard Purdie

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




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

* Re: [PATCH] devshell.bbclass/terminal.bbclass: add a shell check at devshell
  2018-11-26  1:57 ` Hongxu Jia
@ 2018-11-27 19:37   ` Peter Kjellerstedt
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Kjellerstedt @ 2018-11-27 19:37 UTC (permalink / raw)
  To: Hongxu Jia, openembedded-core, Richard Purdie

> -----Original Message-----
> From: openembedded-core-bounces@lists.openembedded.org <openembedded-
> core-bounces@lists.openembedded.org> On Behalf Of Hongxu Jia
> Sent: den 26 november 2018 02:57
> To: openembedded-core@lists.openembedded.org; Richard Purdie
> <richard.purdie@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@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


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

end of thread, other threads:[~2018-11-27 19:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-03  7:09 [PATCH] devshell.bbclass/terminal.bbclass: add a shell check at devshell Hongxu Jia
2018-11-26  1:57 ` Hongxu Jia
2018-11-27 19:37   ` Peter Kjellerstedt

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.