# 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/patch/buildout.cfg
    ../../component/python-mysqlclient/buildout.cfg
    ../../component/python-cryptography/buildout.cfg
    ../../component/pycurl/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}
  ${BTrees:egg}
  psutil
  ZODB
  zope.testing
  zodbtools
  coverage
  setproctitle
adapter-egg = ${python-mysqlclient:egg}
patch-binary = ${patch:location}/bin/patch
ZEO-patch-options = -p1
ZEO-patches =
  ${:_profile_base_location_}/../../component/egg-patch/ZEO4/TCP_NODELAY.patch#b07288522d5c6857738240d948321df6

# XXX: buildout fails to install properly eggs with setup_requires
[BTrees]
recipe = zc.recipe.egg:custom
egg = ${:_buildout_section_name_}
setup-eggs = ${persistent:egg}

[persistent]
recipe = zc.recipe.egg:custom
egg = ${:_buildout_section_name_}
setup-eggs = ${python-cffi: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]
BTrees = 4.5.1
ZODB = 4.4.5
coverage = 4.5.1
mock = 3.0.5
ecdsa = 0.13
gitdb2 = 2.0.0
msgpack = 0.5.6
msgpack-python = 0.5.6
mysqlclient = 1.3.12
persistent = 4.5.0
pycrypto = 2.6.1
pycurl = 7.43.0
setproctitle = 1.1.10
slapos.recipe.template = 4.4
smmap2 = 2.0.1
transaction = 1.7.0
zodbpickle = 1.0.4
zodbtools = 0.0.0.dev4
cython-zstd = 0.2
python-dateutil = 2.7.3

# Required by:
# zodbtools==0.0.0dev4
zodburi = 2.3.0

# Required by:
# zodburi==2.0
# ZEO 5 requires transaction >= 2
ZEO = 4.3.1+SlapOSPatched001

# Required by:
# ZEO==4.3.1
zdaemon = 4.2.0

# Required by:
# mock = 3.0.5
funcsigs = 1.0.2