summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Budny <pbbudny@amazon.com>2021-04-12 20:23:17 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-04-30 14:37:24 +0100
commit762fe99172fa421b6559092568379c9e4abb9296 (patch)
tree16c7c18910546ea78fb2becbfe88efd668d8f3ad
parent464472d851d3e36334f3f2c39e6f62952eae7326 (diff)
downloadpoky-762fe99172fa421b6559092568379c9e4abb9296.tar.gz
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: d049d7413b72c22388693b71c5901b2283f83df9) 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: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oe/terminal.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py
index 61c2687ef4..59aa80de66 100644
--- a/meta/lib/oe/terminal.py
+++ b/meta/lib/oe/terminal.py
@@ -163,7 +163,12 @@ class Tmux(Terminal):
163 # devshells, if it's already there, add a new window to it. 163 # devshells, if it's already there, add a new window to it.
164 window_name = 'devshell-%i' % os.getpid() 164 window_name = 'devshell-%i' % os.getpid()
165 165
166 self.command = 'tmux new -c "{{cwd}}" -d -s {0} -n {0} "{{command}}"'.format(window_name) 166 self.command = 'tmux new -c "{{cwd}}" -d -s {0} -n {0} "{{command}}"'
167 if not check_tmux_version('1.9'):
168 # `tmux new-session -c` was added in 1.9;
169 # older versions fail with that flag
170 self.command = 'tmux new -d -s {0} -n {0} "{{command}}"'
171 self.command = self.command.format(window_name)
167 Terminal.__init__(self, sh_cmd, title, env, d) 172 Terminal.__init__(self, sh_cmd, title, env, d)
168 173
169 attach_cmd = 'tmux att -t {0}'.format(window_name) 174 attach_cmd = 'tmux att -t {0}'.format(window_name)
@@ -253,13 +258,18 @@ def spawn(name, sh_cmd, title=None, env=None, d=None):
253 except OSError: 258 except OSError:
254 return 259 return
255 260
261def check_tmux_version(desired):
262 vernum = check_terminal_version("tmux")
263 if vernum and LooseVersion(vernum) < desired:
264 return False
265 return vernum
266
256def check_tmux_pane_size(tmux): 267def check_tmux_pane_size(tmux):
257 import subprocess as sub 268 import subprocess as sub
258 # On older tmux versions (<1.9), return false. The reason 269 # On older tmux versions (<1.9), return false. The reason
259 # is that there is no easy way to get the height of the active panel 270 # is that there is no easy way to get the height of the active panel
260 # on current window without nested formats (available from version 1.9) 271 # on current window without nested formats (available from version 1.9)
261 vernum = check_terminal_version("tmux") 272 if not check_tmux_version('1.9'):
262 if vernum and LooseVersion(vernum) < '1.9':
263 return False 273 return False
264 try: 274 try:
265 p = sub.Popen('%s list-panes -F "#{?pane_active,#{pane_height},}"' % tmux, 275 p = sub.Popen('%s list-panes -F "#{?pane_active,#{pane_height},}"' % tmux,