1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-03 13:49:49 +00:00

lib/oe/terminal: Fix tmux new-session on older tmux versions (<1.9)

`tmux new -c` fails on tmux older than 1.9, when that flag was added.
We can omit the flag for older versions of tmux, and the working
directory gets set even without it.

(From OE-Core rev: 290747561ab91fcf38b2c787e13e0eb88eadb389)

Signed-off-by: Peter Budny <pbbudny@amazon.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit c55c294be6f5119f4c58a4e7a0bc052904126569)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Peter Budny
2021-04-12 20:23:17 +00:00
committed by Richard Purdie
parent eb3fd65b42
commit 2d21ece11a
+13 -3
View File
@@ -163,7 +163,12 @@ class Tmux(Terminal):
# devshells, if it's already there, add a new window to it. # devshells, if it's already there, add a new window to it.
window_name = 'devshell-%i' % os.getpid() window_name = 'devshell-%i' % os.getpid()
self.command = 'tmux new -c "{{cwd}}" -d -s {0} -n {0} "{{command}}"'.format(window_name) self.command = 'tmux new -c "{{cwd}}" -d -s {0} -n {0} "{{command}}"'
if not check_tmux_version('1.9'):
# `tmux new-session -c` was added in 1.9;
# older versions fail with that flag
self.command = 'tmux new -d -s {0} -n {0} "{{command}}"'
self.command = self.command.format(window_name)
Terminal.__init__(self, sh_cmd, title, env, d) Terminal.__init__(self, sh_cmd, title, env, d)
attach_cmd = 'tmux att -t {0}'.format(window_name) attach_cmd = 'tmux att -t {0}'.format(window_name)
@@ -253,13 +258,18 @@ def spawn(name, sh_cmd, title=None, env=None, d=None):
except OSError: except OSError:
return return
def check_tmux_version(desired):
vernum = check_terminal_version("tmux")
if vernum and LooseVersion(vernum) < desired:
return False
return vernum
def check_tmux_pane_size(tmux): def check_tmux_pane_size(tmux):
import subprocess as sub import subprocess as sub
# On older tmux versions (<1.9), return false. The reason # On older tmux versions (<1.9), return false. The reason
# is that there is no easy way to get the height of the active panel # is that there is no easy way to get the height of the active panel
# on current window without nested formats (available from version 1.9) # on current window without nested formats (available from version 1.9)
vernum = check_terminal_version("tmux") if not check_tmux_version('1.9'):
if vernum and LooseVersion(vernum) < '1.9':
return False return False
try: try:
p = sub.Popen('%s list-panes -F "#{?pane_active,#{pane_height},}"' % tmux, p = sub.Popen('%s list-panes -F "#{?pane_active,#{pane_height},}"' % tmux,