Rework how the devshell functions
In the new implementation, each known terminal is defined as a class in
oe.terminal, as a subclass of bb.process.Popen. terminal.bbclass wraps this
functionality, providing the metadata pieces. It obeys the OE_TERMINAL
variable, which is a 'choice' typed variable. This variable may be 'auto',
'none', or any of the names of the defined terminals.
When using 'auto', or requesting an unsupported terminal, we attempt to spawn
them in priority order until we get one that's available on this system (and
in the case of the X terminals, has DISPLAY defined). The 'none' value is
used when we're doing things like automated builds, and want to ensure that no
terminal is *ever* spawned, under any circumstances.
Current available terminals:
gnome
konsole
xterm
rxvt
screen
(From OE-Core rev: 69f77f80965fa06a057837f8f49eda06855c4086)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-03-29 19:53:19 +00:00
|
|
|
OE_TERMINAL ?= 'auto'
|
|
|
|
OE_TERMINAL[type] = 'choice'
|
|
|
|
OE_TERMINAL[choices] = 'auto none \
|
|
|
|
${@" ".join(o.name \
|
|
|
|
for o in oe.terminal.prioritized())}'
|
|
|
|
|
2013-02-05 16:01:20 +00:00
|
|
|
OE_TERMINAL_EXPORTS += 'EXTRA_OEMAKE'
|
Rework how the devshell functions
In the new implementation, each known terminal is defined as a class in
oe.terminal, as a subclass of bb.process.Popen. terminal.bbclass wraps this
functionality, providing the metadata pieces. It obeys the OE_TERMINAL
variable, which is a 'choice' typed variable. This variable may be 'auto',
'none', or any of the names of the defined terminals.
When using 'auto', or requesting an unsupported terminal, we attempt to spawn
them in priority order until we get one that's available on this system (and
in the case of the X terminals, has DISPLAY defined). The 'none' value is
used when we're doing things like automated builds, and want to ensure that no
terminal is *ever* spawned, under any circumstances.
Current available terminals:
gnome
konsole
xterm
rxvt
screen
(From OE-Core rev: 69f77f80965fa06a057837f8f49eda06855c4086)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-03-29 19:53:19 +00:00
|
|
|
OE_TERMINAL_EXPORTS[type] = 'list'
|
|
|
|
|
|
|
|
XAUTHORITY ?= "${HOME}/.Xauthority"
|
|
|
|
SHELL ?= "bash"
|
|
|
|
|
|
|
|
|
2013-06-30 20:16:19 +00:00
|
|
|
def emit_terminal_func(command, envdata, d):
|
|
|
|
cmd_func = 'do_terminal'
|
|
|
|
|
|
|
|
envdata.setVar(cmd_func, 'exec ' + command)
|
|
|
|
envdata.setVarFlag(cmd_func, 'func', 1)
|
|
|
|
|
|
|
|
runfmt = d.getVar('BB_RUNFMT', True) or "run.{func}.{pid}"
|
2013-07-15 20:10:27 +00:00
|
|
|
runfile = runfmt.format(func=cmd_func, task=cmd_func, taskfunc=cmd_func, pid=os.getpid())
|
2013-06-30 20:16:19 +00:00
|
|
|
runfile = os.path.join(d.getVar('T', True), runfile)
|
2013-07-15 20:10:27 +00:00
|
|
|
bb.mkdirhier(os.path.dirname(runfile))
|
|
|
|
|
2013-06-30 20:16:19 +00:00
|
|
|
with open(runfile, 'w') as script:
|
|
|
|
script.write('#!/bin/sh -e\n')
|
|
|
|
bb.data.emit_func(cmd_func, script, envdata)
|
|
|
|
script.write(cmd_func)
|
|
|
|
script.write("\n")
|
|
|
|
os.chmod(runfile, 0755)
|
|
|
|
|
|
|
|
return runfile
|
|
|
|
|
Rework how the devshell functions
In the new implementation, each known terminal is defined as a class in
oe.terminal, as a subclass of bb.process.Popen. terminal.bbclass wraps this
functionality, providing the metadata pieces. It obeys the OE_TERMINAL
variable, which is a 'choice' typed variable. This variable may be 'auto',
'none', or any of the names of the defined terminals.
When using 'auto', or requesting an unsupported terminal, we attempt to spawn
them in priority order until we get one that's available on this system (and
in the case of the X terminals, has DISPLAY defined). The 'none' value is
used when we're doing things like automated builds, and want to ensure that no
terminal is *ever* spawned, under any circumstances.
Current available terminals:
gnome
konsole
xterm
rxvt
screen
(From OE-Core rev: 69f77f80965fa06a057837f8f49eda06855c4086)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-03-29 19:53:19 +00:00
|
|
|
def oe_terminal(command, title, d):
|
|
|
|
import oe.data
|
|
|
|
import oe.terminal
|
|
|
|
|
2013-06-30 20:16:19 +00:00
|
|
|
envdata = bb.data.init()
|
2012-10-19 10:37:07 +00:00
|
|
|
|
2012-11-02 11:23:33 +00:00
|
|
|
for v in os.environ:
|
2013-06-30 20:16:19 +00:00
|
|
|
envdata.setVar(v, os.environ[v])
|
|
|
|
envdata.setVarFlag(v, 'export', 1)
|
2012-11-02 11:23:33 +00:00
|
|
|
|
2011-09-07 17:39:54 +00:00
|
|
|
for export in oe.data.typed_value('OE_TERMINAL_EXPORTS', d):
|
|
|
|
value = d.getVar(export, True)
|
|
|
|
if value is not None:
|
2012-10-30 16:36:50 +00:00
|
|
|
os.environ[export] = str(value)
|
2013-06-30 20:16:19 +00:00
|
|
|
envdata.setVar(export, str(value))
|
|
|
|
envdata.setVarFlag(export, 'export', 1)
|
2013-02-18 13:19:50 +00:00
|
|
|
if export == "PSEUDO_DISABLED":
|
|
|
|
if "PSEUDO_UNLOAD" in os.environ:
|
|
|
|
del os.environ["PSEUDO_UNLOAD"]
|
2013-06-30 20:16:19 +00:00
|
|
|
envdata.delVar("PSEUDO_UNLOAD")
|
2011-09-07 17:39:54 +00:00
|
|
|
|
2013-02-05 16:01:20 +00:00
|
|
|
# Add in all variables from the user's original environment which
|
|
|
|
# haven't subsequntly been set/changed
|
|
|
|
origbbenv = d.getVar("BB_ORIGENV", False) or {}
|
|
|
|
for key in origbbenv:
|
2013-06-30 20:16:19 +00:00
|
|
|
if key in envdata:
|
2013-02-05 16:01:20 +00:00
|
|
|
continue
|
|
|
|
value = origbbenv.getVar(key, True)
|
|
|
|
if value is not None:
|
|
|
|
os.environ[key] = str(value)
|
2013-06-30 20:16:19 +00:00
|
|
|
envdata.setVar(key, str(value))
|
|
|
|
envdata.setVarFlag(key, 'export', 1)
|
|
|
|
|
|
|
|
# Replace command with an executable wrapper script
|
|
|
|
command = emit_terminal_func(command, envdata, d)
|
2013-02-05 16:01:20 +00:00
|
|
|
|
Rework how the devshell functions
In the new implementation, each known terminal is defined as a class in
oe.terminal, as a subclass of bb.process.Popen. terminal.bbclass wraps this
functionality, providing the metadata pieces. It obeys the OE_TERMINAL
variable, which is a 'choice' typed variable. This variable may be 'auto',
'none', or any of the names of the defined terminals.
When using 'auto', or requesting an unsupported terminal, we attempt to spawn
them in priority order until we get one that's available on this system (and
in the case of the X terminals, has DISPLAY defined). The 'none' value is
used when we're doing things like automated builds, and want to ensure that no
terminal is *ever* spawned, under any circumstances.
Current available terminals:
gnome
konsole
xterm
rxvt
screen
(From OE-Core rev: 69f77f80965fa06a057837f8f49eda06855c4086)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-03-29 19:53:19 +00:00
|
|
|
terminal = oe.data.typed_value('OE_TERMINAL', d).lower()
|
|
|
|
if terminal == 'none':
|
|
|
|
bb.fatal('Devshell usage disabled with OE_TERMINAL')
|
|
|
|
elif terminal != 'auto':
|
|
|
|
try:
|
2013-06-30 20:16:19 +00:00
|
|
|
oe.terminal.spawn(terminal, command, title, None, d)
|
Rework how the devshell functions
In the new implementation, each known terminal is defined as a class in
oe.terminal, as a subclass of bb.process.Popen. terminal.bbclass wraps this
functionality, providing the metadata pieces. It obeys the OE_TERMINAL
variable, which is a 'choice' typed variable. This variable may be 'auto',
'none', or any of the names of the defined terminals.
When using 'auto', or requesting an unsupported terminal, we attempt to spawn
them in priority order until we get one that's available on this system (and
in the case of the X terminals, has DISPLAY defined). The 'none' value is
used when we're doing things like automated builds, and want to ensure that no
terminal is *ever* spawned, under any circumstances.
Current available terminals:
gnome
konsole
xterm
rxvt
screen
(From OE-Core rev: 69f77f80965fa06a057837f8f49eda06855c4086)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-03-29 19:53:19 +00:00
|
|
|
return
|
|
|
|
except oe.terminal.UnsupportedTerminal:
|
|
|
|
bb.warn('Unsupported terminal "%s", defaulting to "auto"' %
|
|
|
|
terminal)
|
|
|
|
except oe.terminal.ExecutionError as exc:
|
|
|
|
bb.fatal('Unable to spawn terminal %s: %s' % (terminal, exc))
|
|
|
|
|
|
|
|
try:
|
2013-06-30 20:16:19 +00:00
|
|
|
oe.terminal.spawn_preferred(command, title, None, d)
|
Rework how the devshell functions
In the new implementation, each known terminal is defined as a class in
oe.terminal, as a subclass of bb.process.Popen. terminal.bbclass wraps this
functionality, providing the metadata pieces. It obeys the OE_TERMINAL
variable, which is a 'choice' typed variable. This variable may be 'auto',
'none', or any of the names of the defined terminals.
When using 'auto', or requesting an unsupported terminal, we attempt to spawn
them in priority order until we get one that's available on this system (and
in the case of the X terminals, has DISPLAY defined). The 'none' value is
used when we're doing things like automated builds, and want to ensure that no
terminal is *ever* spawned, under any circumstances.
Current available terminals:
gnome
konsole
xterm
rxvt
screen
(From OE-Core rev: 69f77f80965fa06a057837f8f49eda06855c4086)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-03-29 19:53:19 +00:00
|
|
|
except oe.terminal.NoSupportedTerminals:
|
|
|
|
bb.fatal('No valid terminal found, unable to open devshell')
|
|
|
|
except oe.terminal.ExecutionError as exc:
|
|
|
|
bb.fatal('Unable to spawn terminal %s: %s' % (terminal, exc))
|