# SlapOS component for ZEO.
# https://zeo.readthedocs.io/

[buildout]
extends =
    ../ZODB/buildout.cfg
    ../git/buildout.cfg

parts = ZEO/scripts


# ZEO provides ZEO<X> depending on ZODB major version.
#
# - ZEO4 works only with ZODB4
#   https://github.com/zopefoundation/ZEO/blob/4.3.1-1-g47d3fbe8/setup.py#L122
# - ZEO5 works only with ZODB5
#   https://github.com/zopefoundation/ZEO/blob/5.2.2-1-g3d90ed42/setup.py#L20
[ZEO]
recipe  = slapos.recipe.build
depends = ${ZODB:egg}
init =
  # link/depend to ZEO<ZODB.major>
  zodb = self.buildout['ZODB']
  zmajor = zodb['major']
  zeo_x = self.buildout['ZEO'+zmajor]
  options['depends'] += '$${%s:egg}' % zeo_x.name
  options['egg'] = zeo_x['egg']

  # update [versions] from what is needed by ZEO<X>
  self.buildout.parse('[_ZEO-versions]\n' + zeo_x['egg-versions'])
  versions = self.buildout['versions']
  versions.update(self.buildout['_ZEO-versions'])
  # propagate updated [versions] -> easy_install
  # (buildout does this in Buildout constructor)
  import zc.buildout.easy_install
  zc.buildout.easy_install.default_versions(versions)


# ZEO/scripts installs scripts from ZEO
[ZEO/scripts]
recipe  = zc.recipe.egg:scripts
eggs    = ${ZEO:egg}


# ZEO4: we maintain our own 4-nxd branch with patches
[ZEO4]
recipe  = zc.recipe.egg:develop
setup   = ${ZEO4-repository:location}
egg     = ZEO
egg-versions =

[ZEO4-repository]
recipe  = slapos.recipe.build:gitclone
repository = https://lab.nexedi.com/nexedi/ZEO.git
branch  = 4-nxd
revision= 5114f909e5a5
location = ${buildout:parts-directory}/ZEO4
git-executable = ${git:location}/bin/git


# ZEO5 is plain upstream egg
[ZEO5]
recipe  = zc.recipe.egg:eggs
egg     = ZEO
eggs    = ${:egg}

egg-versions =
  ZEO = 5.2.3
  trollius = 2.2.1
  futures = 3.3.0


# ZEO4-wc2 is ZEO4 version with patches for wendelin.core 2 to work correctly.
# The patches are backports of what is in ZEO master (ZEO5), but since upstream
# considers 4 branch to be "dead", we have to maintain it by ourselves.
# See https://github.com/zopefoundation/ZEO/pull/161 for the reference.
[ZEO4-wc2]
<= ZEO4
setup   = ${ZEO4-wc2-repository:location}

[ZEO4-wc2-repository]
<= ZEO4-repository
revision = bf80d23d3506
location = ${buildout:parts-directory}/ZEO4-wc2