[buildout]

extends =
  buildout.hash.cfg
  ../../component/openssl/buildout.cfg
  ../../component/logrotate/buildout.cfg
  ../../component/apache/buildout.cfg
  ../../component/geoip2/buildout.cfg
  ../../component/git/buildout.cfg
  ../../component/python-cryptography/buildout.cfg
  ../../stack/slapos.cfg

# Monitoring stack (keep on bottom)
  ../../stack/monitor/buildout.cfg

parts +=
  slapos-cookbook
  template

[python]
part = python2.7

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

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

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

[re6stnet]
recipe = zc.recipe.egg
interpreter = python-${:_buildout_section_name_}
eggs =
  ${python-cffi:egg}
  ${python-cryptography:egg}
  pyOpenSSL
  re6stnet[geoip]
initialization =
  import os
  path = os.environ.get('PATH', '/bin:/usr/bin')
  os.environ['PATH'] = '${openssl:location}/bin:${git:location}/bin' + (
    path and ':' + path)
  os.environ['GEOIP2_MMDB'] = "${geolite2-country:location}/GeoLite2-Country.mmdb"
depends = ${re6stnet-develop:recipe}

[re6stnet-backup]
recipe = slapos.recipe.template:jinja2
output = ${buildout:bin-directory}/re6st-backup
inline =
  #!/bin/sh -e
  PATH={{git_location}}/bin:{{sqlite3_location}}/bin:$PATH
  cd "$1" || {
    rm -rf "$1.new"
    git init --bare "$1.new"
    rm "$1.new"/description "$1.new"/hooks/*
    mv "$1.new" "$1"
    cd "$1"
  }
  h=`sqlite3 "$2" .dump |git hash-object --stdin -w`
  git update-index --add --cacheinfo 0644 "$h" registry.sql
  git diff --cached --quiet || GIT_WORK_TREE=$PWD GIT_DIR=$PWD git \
    -c user.name="$${0##*/}" -c user.email="$USER@`hostname`" \
    -c gc.auto=100 -c gc.autoDetach=false commit --allow-empty-message -qm ''
  [ ! "$3" ] || git push --mirror "$3"
context =
  key git_location git:location
  key sqlite3_location sqlite3:location

[download-base]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:filename}

[template]
recipe = slapos.recipe.template:jinja2
output = ${buildout:directory}/instance.cfg
url = ${:_profile_base_location_}/${:filename}
context =
    key bin_directory buildout:bin-directory
    key develop_eggs_directory buildout:develop-eggs-directory
    key eggs_directory buildout:eggs-directory
    key apache_location apache:location
    key logrotate_location logrotate:location
    key openssl_location openssl:location
    key re6stnet_backup re6stnet-backup:output
    key template_apache_conf template-apache-conf:target
    key template_re6stnet template-re6stnet:target
    key template_re6st_registry_conf template-re6st-registry-conf:target
    key template_logrotate_base template-logrotate-base:output
    key monitor2_template_rendered monitor2-template:output
    raw python_with_eggs ${buildout:bin-directory}/${re6stnet:interpreter}

[template-re6stnet]
< = download-base

[template-apache-conf]
< = download-base

[template-re6st-registry-conf]
< = download-base

[versions]
miniupnpc = 1.9


# Test Suite: SlapOS.Eggs.UnitTest-Master.Python2 ran at 2023/09/20 14:41:35.133901 UTC
#             0 failures, 2 errors, 1345 total, status: FAIL

[re6stnet]
revision = 6a26bd1cf97bee879dec791ce0f1202c4e09333d