[oe] [PATCH] terminal: use bash for do_terminal script execution

Richard Tollerton rich.tollerton at ni.com
Fri Dec 19 20:25:55 UTC 2014


Users may set certain environment variables such as SHELLOPTS and
BASHOPTS that the shell will mark as read-only and exported on startup.
Under `bitbake -c devshell`, these eventually make their way into
do_terminal through BB_ORIGENV. POSIX-compliant shells (including bash
when run as /bin/sh, at least as of bash 4.3) must exit immediately when
trying to set these variables, which breaks devshell.

To work around this, force execution of do_terminal with bash. The
SHELL itself called by pseudo is unchanged.

The reproducing case for this was `env BASHOPTS=checkhash bitbake ...`.
Setting BASHOPTS=checkhash protects against underspecified package
DEPENDS against packages which may get temporarily purged from the
sysroot; otherwise, if bash cached a command at a sysroot path that got
deleted, calling the command again will fail.

Signed-off-by: Richard Tollerton <rich.tollerton at ni.com>
---
 meta/classes/terminal.bbclass | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/meta/classes/terminal.bbclass b/meta/classes/terminal.bbclass
index e577c6d..86d4220 100644
--- a/meta/classes/terminal.bbclass
+++ b/meta/classes/terminal.bbclass
@@ -23,7 +23,11 @@ def emit_terminal_func(command, envdata, d):
     bb.utils.mkdirhier(os.path.dirname(runfile))
 
     with open(runfile, 'w') as script:
-        script.write('#!/bin/sh -e\n')
+        # bash is strongly recommended, because the current implementation of
+        # oe_terminal() may attempt to set readonly variables. Under bash, this
+        # is a warning; under dash and other POSIX shells (including bash in
+        # POSIX mode, ie when run as /bin/sh), the shell is required to exit.
+        script.write('#!/usr/bin/env bash -e\n')
         bb.data.emit_func(cmd_func, script, envdata)
         script.write(cmd_func)
         script.write("\n")
-- 
2.2.1




More information about the Openembedded-devel mailing list