software.cfg 10.4 KB
Newer Older
1 2 3 4 5 6
[buildout]
extends =
   ../../component/nodejs/buildout.cfg
   ../../component/caddy/buildout.cfg
   ../../component/git/buildout.cfg
   ../../component/bash/buildout.cfg
7
   ../../component/bash-completion/buildout.cfg
8 9 10 11 12
   ../../component/fish-shell/buildout.cfg
   ../../component/tmux/buildout.cfg
   ../../component/tig/buildout.cfg
   ../../component/vim/buildout.cfg
   ../../component/curl/buildout.cfg
13
   ../../component/coreutils/buildout.cfg
14
   ../../component/java-jdk/buildout.cfg
15
   ../../component/fonts/buildout.cfg
16
   ../../stack/slapos.cfg
17
   ../../stack/monitor/buildout.cfg
18
   ../../component/defaults.cfg
19
   ./download-plugins.cfg
20 21 22 23 24 25 26
   ./buildout.hash.cfg

parts =
  theia-wrapper
  slapos-cookbook
  instance

27 28 29
# default for slapos-standalone
shared-part-list =

30 31 32 33 34
# We keep the gcc part in sync with the one from erp5 software, so that when we install
# erp5 inside theia's slapos parts can be shared.
[gcc]
max_version = 0

35 36

[nodejs]
37
<= nodejs-12.18.3
38 39 40 41 42

[yarn]
# this could become a component, but it needs to be invoked from nodejs explicitly,
# otherwise it uses system's nodejs
# XXX why don't we build a wrapper ?
43
version = 1.17.3
44 45
recipe = slapos.recipe.build:download-unpacked
url = https://github.com/yarnpkg/yarn/releases/download/v${:version}/yarn-v${:version}.tar.gz
46
md5sum = 4a02e1687a150113ad6b0215f9afdb3e
47

48 49 50 51 52 53 54 55 56 57 58 59
[slapos-standalone]
recipe = zc.recipe.egg
eggs =
  slapos.core
scripts = ${:_buildout_section_name_}
script-path = ${buildout:bin-directory}/${:scripts}
# XXX generate a fake entry point for a non existant module, that will not
# be used because we exit in initialization step
entry-points =
  ${:scripts}=not_used:main
initialization =
  import argparse
60
  import glob
61 62
  import os.path
  import sys
63 64
  import signal
  import time
65 66 67 68 69 70 71 72

  import slapos.slap.standalone

  parser = argparse.ArgumentParser()
  parser.add_argument('base_directory')
  parser.add_argument('ipv4')
  parser.add_argument('ipv6')
  parser.add_argument('server_port', type=int)
73
  parser.add_argument('computer_id')
74 75 76 77 78 79 80
  forwarded_arguments = parser.add_argument_group('forwarded')
  forwarded_arguments.add_argument('master_url')
  forwarded_arguments.add_argument('computer')
  forwarded_arguments.add_argument('partition')
  # cert and key are optional
  forwarded_arguments.add_argument('--cert')
  forwarded_arguments.add_argument('--key')
81 82
  args = parser.parse_args()
  shared_part_list = [x.strip() for x in '''${buildout:shared-part-list}'''.splitlines() if x.strip()]
83 84 85 86 87 88 89 90 91 92 93 94
  partition_forward_configuration = (
      slapos.slap.standalone.PartitionForwardAsPartitionConfiguration(
          master_url=args.master_url,
          computer=args.computer,
          partition=args.partition,
          cert=args.cert,
          key=args.key,
          software_release_list=(
            'http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg',
          ),
      ),
  )
95 96 97 98
  standalone = slapos.slap.standalone.StandaloneSlapOS(
      args.base_directory,
      args.ipv4,
      args.server_port,
99
      computer_id=args.computer_id,
100
      shared_part_list=shared_part_list,
101 102
      software_root="%s/software" % args.base_directory,
      instance_root="%s/instance" % args.base_directory,
103
      partition_forward_configuration=partition_forward_configuration,
104 105 106 107 108 109 110 111 112 113 114
  )
  standalone.start()
  partition_count = 20
  if len(glob.glob(os.path.join(standalone.instance_directory, '*'))) < partition_count:
    print("Standalone SlapOS: Formatting {partition_count} partitions".format(
        partition_count=partition_count))
    standalone.format(
        partition_count,
        args.ipv4,
        args.ipv6
    )
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
  print("Standalone SlapOS for computer `{}` started".format(args.computer_id))
  # Run instance at least once, to start the supervisor managing instances.
  try:
    standalone.waitForInstance(max_retry=0)
  except slapos.slap.standalone.SlapOSNodeCommandError as e:
    print("Error instanciating: {}".format(e))

  quit_requested = []
  def signal_handler(signum, frame):
    print("Signal {signum} received".format(signum=signum))
    quit_requested.append(True)
  signal.signal(signal.SIGTERM, signal_handler)

  print("Standalone SlapOS ready")
  while not quit_requested:
    time.sleep(.1)

  print("Stopping standalone subsystem")
  standalone.stop()
  print("Exiting")
135 136 137 138 139 140 141 142 143 144 145
  sys.exit(0)

needs-these-eggs-scripts-in-path =
  ${supervisor:recipe}
  ${slapos-command:recipe}

[supervisor]
recipe = zc.recipe.egg
eggs =
  supervisor
  setuptools
146

147 148 149 150 151 152
[template-base]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/${:filename}
output = ${buildout:parts-directory}/${:_buildout_section_name_}
mode = 0644

153 154 155 156
[python-language-server]
version = 0.19.0
recipe = plone.recipe.command
command =
157
  PATH=${git:location}/bin/:$PATH  bash -c "${python3:executable} -m venv --clear ${:location} && \
158 159 160 161 162 163
    . ${:location}/bin/activate && \
    pip install -r ${python-language-server-requirements.txt:output}"
location = ${buildout:parts-directory}/${:_buildout_section_name_}
stop-on-error = true

[python-language-server-requirements.txt]
164
<= template-base
165 166 167 168

[theia]
recipe = plone.recipe.command
command = ${bash:location}/bin/bash -c "
169
  export TMPDIR=${:location}/tmp PATH=${nodejs:location}/bin:$PATH &&
170
  mkdir -p ${:location} && \
171
  mkdir -p \$TMPDIR && \
172 173 174 175
  cd ${:location} && \
  cp ${package.json:rendered} . &&
  cp ${yarn.lock:output} . &&
  ${yarn:location}/bin/yarn && \
176
  ${yarn:location}/bin/yarn theia build"
177 178
location = ${buildout:parts-directory}/${:_buildout_section_name_}
stop-on-error = true
179
uses = ${yarn.lock:recipe}
180 181 182 183 184 185 186 187 188 189 190 191

[theia-plugins]
recipe = slapos.recipe.build
urls = ${theia-download-plugins:urls}
install =
  import os
  for line in options['urls'].splitlines():
    extension_name, url, md5sum = line.split()
    extract_dir = self.extract(self.download(url, md5sum))
    destination_dir = os.path.join(options['location'], extension_name)
    self.copyTree(guessworkdir(extract_dir), destination_dir)
    os.chmod(destination_dir, 0o750)
192 193

[yarn.lock]
194 195 196 197 198 199 200
<= template-base

[preloadTemplate.html]
<= template-base

[slapos.css.in]
<= template-base
201

202 203 204
[logo.png]
<= template-base

205 206 207
[package.json]
recipe = slapos.recipe.template:jinja2
template =
208
  inline:{
209 210 211 212 213 214
      "private": true,
      "theia": {
          "frontend": {
              "config": {
                  "applicationName": "Theia SlapOS",
                  "preferences": {
215
                      "application.confirmExit": "always",
216 217 218
                      "files.associations": {
                          "*.cfg": "zc-buildout"
                      },
219 220 221 222 223 224
                      "files.enableTrash": false,
                      "files.exclude": {
                          "**.pyc": true,
                          "**.egg-info": true,
                          "__pycache__": true,
                          ".git": true,
225 226
                          ".env": true,
                          "**/node_modules/**": true
227 228
                      },
                      "files.watcherExclude": {
229 230 231 232
                          "**/.eggs/**": true,
                          "**/.env/**": true,
                          "**/.git/**": true,
                          "**/node_modules/**": true
233 234
                      },
                      "editor.multiCursorModifier": "ctrlCmd",
235
                      "editor.tabSize": 2,
236 237
                      "plantuml.server": "https://plantuml.host.vifib.net/svg/",
                      "plantuml.render": "PlantUMLServer",
238 239
                      "gitlens.remotes": [{ "domain": "lab.nexedi.com", "type": "GitLab" }],
                      "java.home": "${java-jdk:location}"
240 241
                  }
              }
242 243 244 245 246
          },
          "generator": {
              "config": {
                  "preloadTemplate": "${preloadTemplate.html:output}"
              }
247 248 249
          }
      },
      "dependencies": {
250
          "@theia/callhierarchy": "latest",
251
          "@theia/console": "latest",
252
          "@theia/core": "latest",
253
          "@theia/cpp-debug": "latest",
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
          "@theia/debug": "latest",
          "@theia/editor": "latest",
          "@theia/editor-preview": "latest",
          "@theia/file-search": "latest",
          "@theia/filesystem": "latest",
          "@theia/getting-started": "latest",
          "@theia/git": "latest",
          "@theia/keymaps": "latest",
          "@theia/markers": "latest",
          "@theia/messages": "latest",
          "@theia/metrics": "latest",
          "@theia/mini-browser": "latest",
          "@theia/monaco": "latest",
          "@theia/navigator": "latest",
          "@theia/outline-view": "latest",
          "@theia/output": "latest",
          "@theia/plugin": "latest",
          "@theia/plugin-ext": "latest",
          "@theia/plugin-ext-vscode": "latest",
          "@theia/preferences": "latest",
          "@theia/preview": "latest",
          "@theia/process": "latest",
276
          "@theia/scm": "latest",
277 278 279
          "@theia/search-in-workspace": "latest",
          "@theia/task": "latest",
          "@theia/terminal": "latest",
280
          "@theia/typehierarchy": "latest",
281 282
          "@theia/userstorage": "latest",
          "@theia/variable-resolver": "latest",
283
          "@theia/vsx-registry": "latest",
284
          "@theia/workspace": "latest",
285
          "@perrinjerome/theia-open": "0.1.2"
286 287
      },
      "devDependencies": {
288
          "@theia/cli": "latest"
289
      }
290
    }
291 292 293 294 295
rendered = ${buildout:directory}/${:_buildout_section_name_}
mode = 0644


[gowork]
296 297 298 299
golang = ${golang1.14:location}

[gowork.goinstall]
command =
300
  bash -c ". ${gowork:env.sh} && GO111MODULE=on go get golang.org/x/tools/gopls@v0.4.3 && cd ${go_github.com_caddyserver_caddy:location} && GO111MODULE=on go install -v github.com/caddyserver/caddy/..."
301

302

303
[cli-utilities]
304
PATH = ${nodejs:location}/bin/:${bash:location}/bin/:${fish-shell:location}/bin/:${tig:location}/bin/:${vim:location}/bin/:${tmux:location}/bin/:${git:location}/bin/:${curl:location}/bin:${python2.7:location}/bin/:${buildout:bin-directory}
305 306 307 308 309 310 311 312 313

[theia-wrapper]
recipe = slapos.recipe.template:jinja2
rendered = ${buildout:bin-directory}/${:_buildout_section_name_}
mode = 0777
template =
  inline:
  #!/bin/bash
  . ${gowork:env.sh}
314
  export PATH=${python-language-server:location}/bin/:${java-jdk:location}/bin/:${cli-utilities:PATH}:$HOME/.cargo/bin:$PATH
315
  export THEIA_DEFAULT_PLUGINS="local-dir:${theia-plugins:location}"
Jérome Perrin's avatar
Jérome Perrin committed
316 317
  # reset PS1 from gowork
  export PS1='$ '
318 319 320 321 322
  cd ${theia:location}
  exec ${yarn:location}/bin/yarn theia start $@


[instance]
323
<= template-base
324 325 326
output = ${buildout:directory}/instance.cfg

[versions]
327
slapos.recipe.template = 4.4