From 16d9b5572df2a620728283618db9f79df591fd16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= Date: Thu, 16 Jul 2020 02:15:56 +0200 Subject: [PATCH] software/theia: generate a shell compatible with tasks When running tasks, shell is invoked like: $THEIA_SHELL -c "command with arguments that\ can\ contain\ spaces" --- software/theia/buildout.hash.cfg | 2 +- software/theia/instance.cfg.in | 20 +++++++++++++------- software/theia/test/test.py | 11 +++++++++++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/software/theia/buildout.hash.cfg b/software/theia/buildout.hash.cfg index cd11b25e3..318c78bbd 100644 --- a/software/theia/buildout.hash.cfg +++ b/software/theia/buildout.hash.cfg @@ -15,7 +15,7 @@ [instance] filename = instance.cfg.in -md5sum = 0cd7d44974b568dbb7b880d6c103dfdf +md5sum = d8ad39bc93c492026a93c28b33a5dc3a [yarn.lock] filename = yarn.lock diff --git a/software/theia/instance.cfg.in b/software/theia/instance.cfg.in index 52eb62a44..f747d0d42 100644 --- a/software/theia/instance.cfg.in +++ b/software/theia/instance.cfg.in @@ -121,7 +121,7 @@ recipe = slapos.cookbook:userinfo recipe = slapos.cookbook:wrapper wrapper-path = $${directory:services}/$${:_buildout_section_name_} command-line = - env LC_ALL=C.UTF-8 TMP=$${directory:tmp} THEIA_WEBVIEW_EXTERNAL_ENDPOINT='{{hostname}}' THEIA_SHELL=$${theia-shell:wrapper-path} ${theia-wrapper:rendered} --hostname=$${:hostname} --port=$${:port} $${directory:project} + env LC_ALL=C.UTF-8 TMP=$${directory:tmp} THEIA_WEBVIEW_EXTERNAL_ENDPOINT='{{hostname}}' THEIA_SHELL=$${theia-shell:rendered} ${theia-wrapper:rendered} --hostname=$${:hostname} --port=$${:port} $${directory:project} ip = $${instance-parameter:ipv4-random} hostname = $${:ip} @@ -132,12 +132,18 @@ hash-existing-files = ${theia-wrapper:rendered} [theia-shell] -recipe = slapos.cookbook:wrapper -wrapper-path = $${directory:bin}/$${:_buildout_section_name_} -# reset GIT_EXEC_PATH to workaround https://github.com/eclipse-theia/theia/issues/7555 -# activate slapos configuration -command-line = - ${bash:location}/bin/bash -c ". $${slapos-standalone-activate:rendered} && exec env GIT_EXEC_PATH= ${bash:location}/bin/bash" +recipe = slapos.recipe.template:jinja2 +rendered = $${directory:bin}/$${:_buildout_section_name_} +mode = 0700 +template = inline: + #!${python:location}/bin/python + import sys + import os + args = sys.argv[1:] + # when running interactively, activate slapos configuration and reset GIT_EXEC_PATH to workaround https://github.com/eclipse-theia/theia/issues/7555 + if not args: args = ["-c", ". $${slapos-standalone-activate:rendered} && exec env GIT_EXEC_PATH= ${bash:location}/bin/bash", ] + os.execv('${bash:location}/bin/bash', ['${bash:location}/bin/bash'] + args) + [slapos-standalone-activate] recipe = slapos.recipe.template:jinja2 diff --git a/software/theia/test/test.py b/software/theia/test/test.py index 43cd3f104..23a97dacb 100644 --- a/software/theia/test/test.py +++ b/software/theia/test/test.py @@ -29,6 +29,7 @@ from __future__ import unicode_literals import os import textwrap import logging +import subprocess import tempfile import time from six.moves.urllib.parse import urlparse, urljoin @@ -131,3 +132,13 @@ class TestTheia(SlapOSInstanceTestCase): process.terminate() process.wait() + + def test_theia_shell_execute_tasks(self): + # shell needs to understand -c "comamnd" arguments for theia tasks feature + test_file = '{}/test file'.format(self.computer_partition_root_path) + subprocess.check_call([ + '{}/bin/theia-shell'.format(self.computer_partition_root_path), + '-c', + 'touch "{}"'.format(test_file) + ]) + self.assertTrue(os.path.exists(test_file)) -- 2.25.1