Rework the devshell
Changes since the previous sends: resurrects the export of some variables that were inadvertently removed.
The following changes since commit de4dc5f0741533529789a6094721f708728af386:
eglibc: fix runtime assertion failure (2011-07-13 12:34:23 +0100)
are available in the git repository at:
http://github.com/kergoth/oe-core devshell
Chris Larson (2):
Rework how the devshell functions
oe.terminal: improve how we spawn screen
meta/classes/devshell.bbclass | 29 +++++------- meta/classes/terminal.bbclass | 30 +++++++++++ meta/lib/oe/terminal.py | 107 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 17 deletions(-) create mode 100644 meta/classes/terminal.bbclass create mode 100644 meta/lib/oe/terminal.py
Signature · 1 line
1.7.5.4
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 | 29 +++++------- meta/classes/terminal.bbclass | 30 ++++++++++++ meta/lib/oe/terminal.py | 102 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+), 17 deletions(-) create mode 100644 meta/classes/terminal.bbclass create mode 100644 meta/lib/oe/terminal.py
meta/classes/devshell.bbclass +12 -17
@@ -1,22 +1,17 @@ -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 +export XAUTHORITY ?= "${HOME}/.Xauthority" +export SHELL ?= "bash" +export DBUS_SESSION_BUS_ADDRESS +export DISPLAY +export EXTRA_OEMAKE + +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 +30 -0
@@ -0,0 +1,30 @@ +OE_TERMINAL ?= 'auto' +OE_TERMINAL[type] = 'choice' +OE_TERMINAL[choices] = 'auto none \ + ${@" ".join(o.name \ + for o in oe.terminal.prioritized())}' + + +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)) + + try: + oe.terminal.spawn_preferred(command, title) + 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 +102 -0
102 lines not on this page · raw message
Signature · 1 line
1.7.5.4
Re: [PATCH 1/2] Rework how the devshell functions
Quoted 49 lines · Christopher Larson
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_TERMINALvariable, 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
screenSigned-off-by Chris Larson <[email protected]>--- meta/classes/devshell.bbclass | 29 +++++------- meta/classes/terminal.bbclass | 30 ++++++++++++ meta/lib/oe/terminal.py | 102 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+), 17 deletions(-) create mode 100644 meta/classes/terminal.bbclass create mode 100644 meta/lib/oe/terminal.pymeta/classes/devshell.bbclass +1
-10@@ -1,22 +1,17 @@ -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"
meta/classes/devshell.bbclass line 8
Quoted 10 lines
meta/classes/devshell.bbclass +5
-5- ${TERMCMDRUN} - if [ $? -ne 0 ]; then - echo "Fatal: '${TERMCMD}' not found. Check TERMCMD variable." - exit 1 - fi +export XAUTHORITY ?= "${HOME}/.Xauthority" +export SHELL ?= "bash" +export DBUS_SESSION_BUS_ADDRESS +export DISPLAY +export EXTRA_OEMAKE
Variables that are placed into the global environment affect the checksums of any shell tasks when they change so I don't think we can do this (and its why they are in a function as above).
Perhaps we could list the variables we want to export in a variable and then pass that list to popen's environment?
Cheers,
Richard
Re: [PATCH 1/2] Rework how the devshell functions
Quoted 34 lines · Richard Purdie
Quoted 18 lines · Christopher Larson
meta/classes/devshell.bbclass +1
-10@@ -1,22 +1,17 @@ -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"meta/classes/devshell.bbclass line 8
Quoted 10 lines
meta/classes/devshell.bbclass +5
-5- ${TERMCMDRUN} - if [ $? -ne 0 ]; then - echo "Fatal: '${TERMCMD}' not found. Check TERMCMD variable." - exit 1 - fi +export XAUTHORITY ?= "${HOME}/.Xauthority" +export SHELL ?= "bash" +export DBUS_SESSION_BUS_ADDRESS +export DISPLAY +export EXTRA_OEMAKEVariables that are placed into the global environment affect the checksums of any shell tasks when they change so I don't think we can do this (and its why they are in a function as above).
Quoted 2 lines
Perhaps we could list the variables we want to export in a variable and then pass that list to popen's environment?
Hmm, fair enough, I'll rework it that way (aside: we really need a general flag-based mechanism to do per-task exports).
Signature · 5 lines
Christopher Larson clarson at kergoth dot com Founder - BitBake, OpenEmbedded, OpenZaurus Maintainer - Tslib Senior Software Engineer, Mentor Graphics
PATCH 2/2 oe.terminal: improve how we spawn screen
In reply to Christopher LarsonFrom: 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
@@ -71,7 +71,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): + Terminal.__init__(self, command, title) + logger.warn('Screen started. Please connect in another terminal with ' + '"screen -r devshell"') def prioritized():
Signature · 1 line
1.7.5.4