[buildout]
extends =
    ../../stack/slapos.cfg
    ../../component/rina-tools/buildout.cfg
parts =
    slapos-cookbook
    template

[file]
# For old GCC like 4.9.2 on Debian 8.
# XXX: This should be moved to component/rina-tools/buildout.cfg, next to where
#      we force use of system GCC. However, our buildout patches are still not
#      perfect concerning the processing of +=
environment +=
  CFLAGS=-std=c99 -g -O2

[template]
recipe = slapos.recipe.template:jinja2
url = ${:_profile_base_location_}/instance.cfg.in
md5sum = d7506e861ef87977eaa554b8928d2c99
# XXX: "template.cfg" is hardcoded in instanciation recipe
output = ${buildout:directory}/template.cfg
context =
    key develop_eggs_directory buildout:develop-eggs-directory
    key eggs_directory buildout:eggs-directory
    key rina_tools_location rina-tools:location
    key instance_root instance-root:target
    key instance_server instance-server:target
    key rina_proxy proxy:location

[download-base]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:_buildout_section_name_}.cfg.in

[instance-root]
<= download-base
md5sum = 1c0e222aab51dfc598094e972f1d1482

[instance-server]
<= download-base
md5sum = 88a451b0f7f8def12713b92b91659b98

[proxy]
recipe = slapos.recipe.build
location = ${buildout:bin-directory}/${:_buildout_section_name_}
url = ${:_profile_base_location_}/${:_buildout_section_name_}
md5sum = 78b77a6bda9958f547f7d89b747731e3
install =
  import os, sys
  with open(self.download(options['url'], options['md5sum'])) as src, \
       open(options['location'], 'w') as dst:
    os.fchmod(dst.fileno(), 0o755)
    src.readline()
    dst.write('#!%s\n' % sys.executable)
    dst.write(src.read())
