All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Revert "terminal.bbclass: use var-SHELL as the shebang of wrapper script"
@ 2018-11-25  1:11 Peter Kjellerstedt
  2018-11-26  1:51 ` Hongxu Jia
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Kjellerstedt @ 2018-11-25  1:11 UTC (permalink / raw)
  To: openembedded-core, Hongxu Jia

The $SHELL environment variable is used for the user's preferred
interactive shell. This shall not be used when executing shell scripts
that expect POSIX shell syntax as there is no guarantee that it is a
POSIX compatible shell.

This reverts commit 27e2ede65f1193e49f9483b08a55495d88740a65.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---

In my case, $SHELL is set to /bin/zsh, with the result that devshell
fails to start. If there is some problem with devshell related to
/bin/sh being linked to dash rather than bash (which the original
commit indicates), then that should be adressed instead.

Hongxu: Do you have any additional information related to why you made
the change in the first place?

 meta/classes/terminal.bbclass | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/meta/classes/terminal.bbclass b/meta/classes/terminal.bbclass
index 73e765d57a..a27e10c6ec 100644
--- a/meta/classes/terminal.bbclass
+++ b/meta/classes/terminal.bbclass
@@ -25,8 +25,7 @@ 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'))
-        script.write('set -e\n')
+        script.write('#!/bin/sh -e\n')
         bb.data.emit_func(cmd_func, script, envdata)
         script.write(cmd_func)
         script.write("\n")
-- 
2.12.0



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

* Re: [PATCH] Revert "terminal.bbclass: use var-SHELL as the shebang of wrapper script"
  2018-11-25  1:11 [PATCH] Revert "terminal.bbclass: use var-SHELL as the shebang of wrapper script" Peter Kjellerstedt
@ 2018-11-26  1:51 ` Hongxu Jia
  0 siblings, 0 replies; 2+ messages in thread
From: Hongxu Jia @ 2018-11-26  1:51 UTC (permalink / raw)
  To: Peter Kjellerstedt, openembedded-core

On 2018/11/25 上午9:11, Peter Kjellerstedt wrote:
> The $SHELL environment variable is used for the user's preferred
> interactive shell. This shall not be used when executing shell scripts
> that expect POSIX shell syntax as there is no guarantee that it is a
> POSIX compatible shell.

There is a sanity check to `/bin/sh' to dash or bash

`eaa0dc2 sanity.bbclass: Only verify /bin/sh link if it's a link'

`ecdfdd7 sanity.bbclass: check /bin/sh is dash or bash'


> This reverts commit 27e2ede65f1193e49f9483b08a55495d88740a65.
>
> Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> ---
>
> In my case, $SHELL is set to /bin/zsh, with the result that devshell
> fails to start. If there is some problem with devshell related to
> /bin/sh being linked to dash rather than bash (which the original
> commit indicates), then that should be adressed instead.
>
> Hongxu: Do you have any additional information related to why you made
> the change in the first place?

If revert this patch, we will have the issue which this patch have fixed.

There is another patch in mailing list that fix the issue you report

[OE-core] [PATCH] 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@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)

//Hongxu


>   meta/classes/terminal.bbclass | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/meta/classes/terminal.bbclass b/meta/classes/terminal.bbclass
> index 73e765d57a..a27e10c6ec 100644
> --- a/meta/classes/terminal.bbclass
> +++ b/meta/classes/terminal.bbclass
> @@ -25,8 +25,7 @@ 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'))
> -        script.write('set -e\n')
> +        script.write('#!/bin/sh -e\n')
>           bb.data.emit_func(cmd_func, script, envdata)
>           script.write(cmd_func)
>           script.write("\n")




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

end of thread, other threads:[~2018-11-26  1:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-25  1:11 [PATCH] Revert "terminal.bbclass: use var-SHELL as the shebang of wrapper script" Peter Kjellerstedt
2018-11-26  1:51 ` Hongxu Jia

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.