Skip to contentSkip to conversation

Rework the devshell

PATCH Applied Christopher Larson 2 participants 4 messages Aug 9, 2011 – Aug 10, 2011

lore
Share & tools
lore
#0 lore raw

cover Rework the devshell

This version addresses the issue brought up by Richard regarding unconditional export of variables resulting in checksum changes. This exports the required variables specifically within the subprocess for the terminal.

A future patch will alter things like the patch resolver to use this.

The following changes since commit ced947e989dfbca8055fe57e14207cb6f1357430:

qemu: Poke more paths for presence of libgl (2011-08-09 15:21:06 +0100)

are available in the git repository at:
git://github.com/kergoth/oe-core devshell

go here for github's branch comparison interface:
https://github.com/kergoth/oe-core/compare/master...devshell

Chris Larson (2):
Rework how the devshell functions
oe.terminal: improve how we spawn screen

 meta/classes/devshell.bbclass |   24 ++-------
 meta/classes/terminal.bbclass |   40 +++++++++++++++
 meta/lib/oe/terminal.py       |  106 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 152 insertions(+), 18 deletions(-)
 create mode 100644 meta/classes/terminal.bbclass
 create mode 100644 meta/lib/oe/terminal.py
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/2 Rework how the devshell functions

From: Chris Larson <[email protected]>

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

---
 meta/classes/devshell.bbclass |   24 +++-------
 meta/classes/terminal.bbclass |   40 ++++++++++++++++
 meta/lib/oe/terminal.py       |  101 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 147 insertions(+), 18 deletions(-)
 create mode 100644 meta/classes/terminal.bbclass
 create mode 100644 meta/lib/oe/terminal.py
meta/classes/devshell.bbclass +6 -18
index 5f262f4..ddb6e55 100644
@@ -1,22 +1,10 @@
-do_devshell[dirs] = "${S}"
-do_devshell[nostamp] = "1"
+inherit terminal
 
-XAUTHORITY ?= "${HOME}/.Xauthority"
-
-devshell_do_devshell() {
-	export DISPLAY='${DISPLAY}'
-	export DBUS_SESSION_BUS_ADDRESS='${DBUS_SESSION_BUS_ADDRESS}'
-	export XAUTHORITY='${XAUTHORITY}'
-	export TERMWINDOWTITLE="Bitbake Developer Shell"
-	export EXTRA_OEMAKE='${EXTRA_OEMAKE}'
-	export SHELLCMDS="bash"
-	${TERMCMDRUN}
-	if [ $? -ne 0 ]; then
-	    echo "Fatal: '${TERMCMD}' not found. Check TERMCMD variable."
-	    exit 1
-	fi
+python do_devshell () {
+    oe_terminal(d.getVar('SHELL', True), 'OpenEmbedded Developer Shell', d)
 }
-addtask devshell after do_patch
 
-EXPORT_FUNCTIONS do_devshell
+addtask devshell after do_patch
 
+do_devshell[dirs] = "${S}"
+do_devshell[nostamp] = "1"
meta/classes/terminal.bbclass new file +40 -0
new file mode 100644
index 0000000..4123046
@@ -0,0 +1,40 @@
+OE_TERMINAL ?= 'auto'
+OE_TERMINAL[type] = 'choice'
+OE_TERMINAL[choices] = 'auto none \
+                        ${@" ".join(o.name \
+                                    for o in oe.terminal.prioritized())}'
+
+OE_TERMINAL_EXPORTS = 'XAUTHORITY SHELL DBUS_SESSION_BUS_ADDRESS DISPLAY EXTRA_OEMAKE'
+OE_TERMINAL_EXPORTS[type] = 'list'
+
+XAUTHORITY ?= "${HOME}/.Xauthority"
+SHELL ?= "bash"
+
+
+def oe_terminal(command, title, d):
+    import oe.data
+    import oe.terminal
+
+    terminal = oe.data.typed_value('OE_TERMINAL', d).lower()
+    if terminal == 'none':
+        bb.fatal('Devshell usage disabled with OE_TERMINAL')
+    elif terminal != 'auto':
+        try:
+            oe.terminal.spawn(terminal, command, title)
+            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))
+
+    env = dict(os.environ)
+    for export in oe.data.typed_value('OE_TERMINAL_EXPORTS', d):
+        env[export] = d.getVar(export, True)
+
+    try:
+        oe.terminal.spawn_preferred(command, title, env)
+    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))
meta/lib/oe/terminal.py new file +101 -0

101 lines not on this page · raw message

Signature · 1 line
1.7.5.4
#2 lore raw

PATCH 2/2 oe.terminal: improve how we spawn screen

In reply to Christopher Larson

From: Chris Larson <[email protected]>

- Name the screen session 'devshell', to avoid confusion if running bitbake itself under a screen session.
- Display a warning message when spawning screen, so it's clear to the user that screen has been run (otherwise do_devshell just appears to hang).

---
 meta/lib/oe/terminal.py |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
meta/lib/oe/terminal.py +6 -1
index 3767935..3965462 100644
@@ -70,7 +70,12 @@ class Rxvt(XTerminal):
     priority = 1
 
 class Screen(Terminal):
-    command = 'screen -D -m -t "{title}" {command}'
+    command = 'screen -D -m -t "{title}" -S devshell {command}'
+
+    def __init__(self, command, title=None, env=None):
+        Terminal.__init__(self, command, title, env)
+        logger.warn('Screen started. Please connect in another terminal with '
+                    '"screen -r devshell"')
 
 
 def prioritized():
Signature · 1 line
1.7.5.4
#3 lore raw
In reply to Christopher Larson
Quoted 13 lines · Christopher Larson

This version addresses the issue brought up by Richard regarding unconditional export of variables resulting in checksum changes. This exports the required variables specifically within the subprocess for the terminal.

A future patch will alter things like the patch resolver to use this.

The following changes since commit ced947e989dfbca8055fe57e14207cb6f1357430:

qemu: Poke more paths for presence of libgl (2011-08-09 15:21:06 +0100)

are available in the git repository at:
git://github.com/kergoth/oe-core devshell

Quoted 6 lines

go here for github's branch comparison interface:
https://github.com/kergoth/oe-core/compare/master...devshell

Chris Larson (2):
Rework how the devshell functions
oe.terminal: improve how we spawn screen

Merged to master, thanks.

Richard