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-23 10:41:21 +0100
commit7d2219bd533cf19f1a042a6ca269ef358989042b (patch)
tree9153b28fe98d99c244fb75cd3b7bbf1601d121b9
parent5f8ab6eaa7adb1f8fd836b305b209630bdf1d4f4 (diff)
downloadpoky-7d2219bd533cf19f1a042a6ca269ef358989042b.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: f1a5ca0b833e3f5bc7e4ccf8d75f0c5296fa9ea5) 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 eb10a6e33e..2ac39df9e1 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,