# SlapOS component for tempstorage.
# https://github.com/zopefoundation/tempstorage

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


# tempstorage provides tempstorage<X> depending on ZODB major version.
#
# - tempstorage >= 4 works only with ZODB5 because ZODB commit protocol was changed
#   https://github.com/zopefoundation/tempstorage/commit/5cc223ea
# - tempstorage <= 5.2 is vulnerable to data corruption in loadBefore
#   https://github.com/zopefoundation/tempstorage/issues/8
#   https://github.com/zopefoundation/tempstorage/pull/16
# - tempstorage 3-nxd provides loadBefore backports to tempstorage 3.
[tempstorage]
recipe  = slapos.recipe.build
depends = ${ZODB:egg}
init =
  # link/depend to tempstorage<ZODB.major>
  zodb = self.buildout['ZODB']
  zmajor = zodb['major']
  tempstorage_x = self.buildout['tempstorage'+zmajor]
  options['depends'] += '$${%s:egg}' % tempstorage_x.name
  options['egg'] = tempstorage_x['egg']

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


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

egg-versions =
  tempstorage = 5.2


# tempstorage4-wc2 is tempstorage 3 + backports for loadBefore fixes
[tempstorage4-wc2]
recipe  = zc.recipe.egg:develop
setup   = ${tempstorage4-wc2-repository:location}
egg     = tempstorage
egg-versions =
  tempstorage =

[tempstorage4-wc2-repository]
recipe  = slapos.recipe.build:gitclone
repository = https://lab.nexedi.com/nexedi/tempstorage.git
branch  = 3-nxd
revision= 77b49295db78
location = ${buildout:parts-directory}/tempstorage
git-executable = ${git:location}/bin/git


# tempstorage4 is the same as tempstorage4-wc2 because of loadBefore fixes.
[tempstorage4]
<= tempstorage4-wc2
