summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/terminal.bbclass41
1 files changed, 32 insertions, 9 deletions
diff --git a/meta/classes/terminal.bbclass b/meta/classes/terminal.bbclass
index 8cebad4162..ae338e9f57 100644
--- a/meta/classes/terminal.bbclass
+++ b/meta/classes/terminal.bbclass
@@ -11,43 +11,66 @@ XAUTHORITY ?= "${HOME}/.Xauthority"
11SHELL ?= "bash" 11SHELL ?= "bash"
12 12
13 13
14def emit_terminal_func(command, envdata, d):
15 cmd_func = 'do_terminal'
16
17 envdata.setVar(cmd_func, 'exec ' + command)
18 envdata.setVarFlag(cmd_func, 'func', 1)
19
20 runfmt = d.getVar('BB_RUNFMT', True) or "run.{func}.{pid}"
21 runfile = runfmt.format(func=cmd_func, pid=os.getpid())
22 runfile = os.path.join(d.getVar('T', True), runfile)
23 with open(runfile, 'w') as script:
24 script.write('#!/bin/sh -e\n')
25 bb.data.emit_func(cmd_func, script, envdata)
26 script.write(cmd_func)
27 script.write("\n")
28 os.chmod(runfile, 0755)
29
30 return runfile
31
14def oe_terminal(command, title, d): 32def oe_terminal(command, title, d):
15 import oe.data 33 import oe.data
16 import oe.terminal 34 import oe.terminal
17 35
18 env = dict() 36 envdata = bb.data.init()
19 37
20 for v in os.environ: 38 for v in os.environ:
21 env[v] = os.environ[v] 39 envdata.setVar(v, os.environ[v])
40 envdata.setVarFlag(v, 'export', 1)
22 41
23 for export in oe.data.typed_value('OE_TERMINAL_EXPORTS', d): 42 for export in oe.data.typed_value('OE_TERMINAL_EXPORTS', d):
24 value = d.getVar(export, True) 43 value = d.getVar(export, True)
25 if value is not None: 44 if value is not None:
26 os.environ[export] = str(value) 45 os.environ[export] = str(value)
27 env[export] = str(value) 46 envdata.setVar(export, str(value))
47 envdata.setVarFlag(export, 'export', 1)
28 if export == "PSEUDO_DISABLED": 48 if export == "PSEUDO_DISABLED":
29 if "PSEUDO_UNLOAD" in os.environ: 49 if "PSEUDO_UNLOAD" in os.environ:
30 del os.environ["PSEUDO_UNLOAD"] 50 del os.environ["PSEUDO_UNLOAD"]
31 if "PSEUDO_UNLOAD" in env: 51 envdata.delVar("PSEUDO_UNLOAD")
32 del env["PSEUDO_UNLOAD"]
33 52
34 # Add in all variables from the user's original environment which 53 # Add in all variables from the user's original environment which
35 # haven't subsequntly been set/changed 54 # haven't subsequntly been set/changed
36 origbbenv = d.getVar("BB_ORIGENV", False) or {} 55 origbbenv = d.getVar("BB_ORIGENV", False) or {}
37 for key in origbbenv: 56 for key in origbbenv:
38 if key in env: 57 if key in envdata:
39 continue 58 continue
40 value = origbbenv.getVar(key, True) 59 value = origbbenv.getVar(key, True)
41 if value is not None: 60 if value is not None:
42 os.environ[key] = str(value) 61 os.environ[key] = str(value)
43 env[key] = str(value) 62 envdata.setVar(key, str(value))
63 envdata.setVarFlag(key, 'export', 1)
64
65 # Replace command with an executable wrapper script
66 command = emit_terminal_func(command, envdata, d)
44 67
45 terminal = oe.data.typed_value('OE_TERMINAL', d).lower() 68 terminal = oe.data.typed_value('OE_TERMINAL', d).lower()
46 if terminal == 'none': 69 if terminal == 'none':
47 bb.fatal('Devshell usage disabled with OE_TERMINAL') 70 bb.fatal('Devshell usage disabled with OE_TERMINAL')
48 elif terminal != 'auto': 71 elif terminal != 'auto':
49 try: 72 try:
50 oe.terminal.spawn(terminal, command, title, env, d) 73 oe.terminal.spawn(terminal, command, title, None, d)
51 return 74 return
52 except oe.terminal.UnsupportedTerminal: 75 except oe.terminal.UnsupportedTerminal:
53 bb.warn('Unsupported terminal "%s", defaulting to "auto"' % 76 bb.warn('Unsupported terminal "%s", defaulting to "auto"' %
@@ -56,7 +79,7 @@ def oe_terminal(command, title, d):
56 bb.fatal('Unable to spawn terminal %s: %s' % (terminal, exc)) 79 bb.fatal('Unable to spawn terminal %s: %s' % (terminal, exc))
57 80
58 try: 81 try:
59 oe.terminal.spawn_preferred(command, title, env, d) 82 oe.terminal.spawn_preferred(command, title, None, d)
60 except oe.terminal.NoSupportedTerminals: 83 except oe.terminal.NoSupportedTerminals:
61 bb.fatal('No valid terminal found, unable to open devshell') 84 bb.fatal('No valid terminal found, unable to open devshell')
62 except oe.terminal.ExecutionError as exc: 85 except oe.terminal.ExecutionError as exc: