[buildout]
extends =
  ../dash/buildout.cfg
  ../curl/buildout.cfg

parts +=
  onlyoffice-x2t

[onlyoffice-x2t]
recipe = slapos.recipe.build

url = https://lab.nexedi.com/tc/bin/raw/fc3af671d3b19e9d25b40326373222b601f23edc/onlyoffice-x2t-part.tar.gz
md5sum = 3e08a8b1345c301078cdce3a7f7360b2

# script to install.
script =
  location = %(location)r
  self.failIfPathExists(location)
  import sys
  extract_dir = self.extract(self.download(self.options['url'], self.options.get('md5sum')))
  shutil.move(extract_dir, location)
  wrapper_location = os.path.join("%(location)s", "x2t")
  wrapper = open(wrapper_location, 'w')
  wrapper.write('''#!${dash:location}/bin/dash
  cd %(location)s
  export LD_LIBRARY_PATH=%(location)s/lib:${curl:location}/lib
  exec %(location)s/bin/x2t "$@"''')
  wrapper.close()
  os.chmod(wrapper_location, 0755)
  os.chmod(location, 0750)
