# SlapOS component for ZODB.
# https://zodb.org/

[buildout]
extends =
    ../git/buildout.cfg
    ../python-cffi/buildout.cfg

parts = ZODB/scripts


# ZODB allows to use either ZODB4, ZODB4-wc2 or ZODB5.
# To select which version to use users should do:
#
#   [ZODB]
#   major = <ZODB-version-major>
#
# By default ZODB4 is used.
[ZODB]
recipe = slapos.recipe.build
major  = 4
init =
  # link/depend ZODB -> ZODB<X>
  zodb_x = 'ZODB'+options['major']
  zodb_x = self.buildout[zodb_x]
  options['depends'] = '$${%s:egg}' % zodb_x.name

  options['egg'] = zodb_x['egg']

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


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

# ZODB4 and ZODB5 are plain upstream eggs
[_ZODB]
recipe  = zc.recipe.egg:eggs
egg     = ZODB
eggs    = ${:egg}
depends = ${persistent:egg} ${BTrees:egg}

[ZODB4]
<= _ZODB
egg-versions =
  ZODB = 4.4.5
  transaction = 1.7.0

[ZODB5]
<= _ZODB
egg-versions =
  ZODB = 5.6.0
  transaction = 2.4.0


# ZODB4-wc2 is ZODB4 version with patches for wendelin.core 2 to work correctly.
# The main change is backport of the way MVCC is handled by always calling
# loadBefore instead of load.
# See https://lab.nexedi.com/nexedi/ZODB/commit/8e7eab33 for details.
[ZODB4-wc2]
<= ZODB4
recipe = zc.recipe.egg:develop
setup = ${ZODB4-wc2-repository:location}

[ZODB4-wc2-repository]
recipe  = slapos.recipe.build:gitclone
repository = https://lab.nexedi.com/nexedi/ZODB.git
git-executable = ${git:location}/bin/git
branch = 4-nxd+MVCC-load-before
revision = 4.4.5-9-g8e7eab330
location = ${buildout:parts-directory}/ZODB4-wc2


# 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}


# eggs that are common to ZODB4 and ZODB5.
[versions]
BTrees = 4.5.1
persistent = 4.6.4
zodbpickle = 1.0.4

# Provide ZODB3 for those eggs that still care about ZODB3 compatibility -
# for example wendelin.core. ZODB3 3.11 is just a dependency egg on _latest_
# ZODB, persistent, BTrees and ZEO.
ZODB3 = 3.11.0
