# Note on LXML/END LXML: they delimit areas where lxml magic is needed. lxml is
# a slapos.cookbook dependency, so it should be fetched automatically. But when
# automatically fetched, it gets built against system headers/libs, which is
# forbidden in slapos. So we need to fetch lxml explicitly so it is properly
# built.

[buildout]
extends =
    buildout.hash.cfg
    ../../stack/slapos.cfg
    ../../stack/logrotate/buildout.cfg
    ../../stack/monitor/buildout.cfg
    ../../component/cython-zstd/buildout.cfg
#LXML
    ../../component/lxml-python/buildout.cfg
#END LXML
    ../../component/msgpack-python/buildout.cfg
    ../../component/python-mysqlclient/buildout.cfg
    ../../component/python-cryptography/buildout.cfg
    ../../component/pycurl/buildout.cfg
    ../../component/ZODB/buildout.cfg
    ../../component/ZEO/buildout.cfg
    ../../component/zodbtools/buildout.cfg

parts =
# keep neoppod first so that ZODB is built correctly,
# before any other section that would depend on it
    neoppod-develop
    neoppod
    slapos-cookbook

[neoppod-repository]
recipe = slapos.recipe.build:gitclone
repository = https://lab.nexedi.com/nexedi/neoppod.git
git-executable = ${git:location}/bin/git

[neoppod-setup-env]
PATH = ${git:location}/bin:%(PATH)s

[neoppod-develop]
recipe = zc.recipe.egg:develop
setup = ${neoppod-repository:location}
environment = neoppod-setup-env

[neoppod]
recipe = zc.recipe.egg
eggs = neoppod[admin, ctl, master]
  ${cython-zstd:egg}
  ${msgpack-python:egg}
  ${:adapter-egg}
  ${ZODB:egg}
  ${zodbtools:egg}
  psutil
  zope.testing
  coverage
  setproctitle
adapter-egg = ${python-mysqlclient:egg}

[download-base-neo]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:filename}
# XXX: following mode should be the default
mode = 644

# XXX: must be rendered, not just dled
[instance-common]
recipe = slapos.recipe.template:jinja2
template = ${:_profile_base_location_}/${:filename}
rendered = ${buildout:directory}/${:_buildout_section_name_}.cfg
context =
    key bin_directory buildout:bin-directory
    key develop_eggs_directory buildout:develop-eggs-directory
    key eggs_directory buildout:eggs-directory
    key neo_admin instance-neo-admin:target
    key neo_master instance-neo-master:target
    key neo instance-neo:target
    key template_logrotate_base template-logrotate-base:rendered
    key template_monitor monitor2-template:rendered
    ${:adapter-context}
adapter-context =
    key mariadb_location mariadb:location
    key template_mysqld_wrapper template-mysqld-wrapper:rendered
    key template_neo_my_cnf template-neo-my-cnf:target

[root-common]
<= download-base-neo

[instance-neo-admin]
<= download-base-neo

[instance-neo-master]
<= download-base-neo

[instance-neo]
<= download-base-neo

[template-neo-my-cnf]
<= download-base-neo

[template-mysqld-wrapper]
recipe = slapos.recipe.template:jinja2
rendered = ${buildout:parts-directory}/${:_buildout_section_name_}/mysqld.in
mode = 644
template =
  inline:{% raw %}#!/bin/sh -e
  basedir='${mariadb:location}'
  datadir='{{datadir}}'
  [ -e "$datadir" ] || {
    rm -vrf "$datadir.new"
    "$basedir/scripts/mysql_install_db" \
      --defaults-file='{{defaults_file}}' \
      --skip-name-resolve \
      --auth-root-authentication-method=normal \
      --basedir="$basedir" --plugin_dir="$basedir/lib/plugin" \
      --datadir="$datadir.new"
    mv -v "$datadir.new" "$datadir"
  }
  {%- if environ is defined %}
  {%-   for variable in environ.splitlines() %}
  {{ variable }} \
  {%-   endfor %}
  {%- endif %}
  exec "$basedir/bin/mysqld" --defaults-file='{{defaults_file}}' "$@"
  {% endraw %}

[versions]
coverage = 4.5.1
mock = 3.0.5
ecdsa = 0.13
mysqlclient = 1.3.12
pycrypto = 2.6.1
pycurl = 7.43.0
setproctitle = 1.1.10
cython-zstd = 0.2
python-dateutil = 2.7.3

# Required by:
# mock = 3.0.5
funcsigs = 1.0.2
