[buildout]
extends =
  ../boost-lib/buildout.cfg
  ../cmake/buildout.cfg
  ../cryptsetup/buildout.cfg
  ../curl/buildout.cfg
  ../keyutils/buildout.cfg
  ../libnl/buildout.cfg
  ../ncurses/buildout.cfg
  ../ninja/buildout.cfg
  ../openssl/buildout.cfg
  ../patch/buildout.cfg
  ../snappy/buildout.cfg
  ../systemd/buildout.cfg
  ../util-linux/buildout.cfg
  ../zlib/buildout.cfg
  ../pkgconfig/buildout.cfg

[pyyaml-download]
recipe = slapos.recipe.build:download
shared = true
url = https://files.pythonhosted.org/packages/e3/e8/b3212641ee2718d556df0f23f78de8303f068fe29cdaa7a91018849582fe/${:filename}
filename = PyYAML-5.1.2.tar.gz
md5sum = 20f87ab421b0271dbf371dc5c1cddb5c

[pyaml-download]
recipe = slapos.recipe.build:download
shared = true
url = https://files.pythonhosted.org/packages/b6/f0/dbb524509ce28f5cfd4e1d9e3ef955f51186cfd1b8297f6e158778c4a8ef/${:filename}
filename = pyaml-21.10.1.tar.gz
md5sum = a915f577f6fc62344fa4775b22db9052

[librbd-python]
recipe = slapos.recipe.build
shared = true
pyyaml = ${pyyaml-download:target}
pyaml = ${pyaml-download:target}
init =
  # add the python executable in the options dict so that
  # buildout signature changes if python executable changes
  import sys
  options['python-executable'] = sys.executable

install =
  import os, sys
  call([sys.executable, '-m', 'venv', '--clear', location])
  pip = os.path.join(location, 'bin', 'pip')
  call([pip, 'install', '--no-index', options['pyyaml'], options['pyaml']])
  call([pip, 'uninstall', '-y', 'pip', 'setuptools'])
  # selftest
  python = os.path.join(location, 'bin', 'python')
  call([python, '-c', 'import yaml'])

[librbd]
# CEPH only for librbd
recipe = slapos.recipe.cmmi
shared = true
url = https://download.ceph.com/tarballs/ceph-17.2.6.tar.gz
md5sum = aba03b7caacc590295b09829e0d4f088

# Note: SlapOSifying whole ceph, including it's managers, is an enormous effort
#       so only "librbd" is provided with header files and this requires
#       careful selection and ordering of ninja's targets and also manual
#       copying of common library
configure-command = cmake
make-binary = ninja -C build librbd librados
make-targets = src/librbd/install src/librados/install src/common/install src/include/install ; cp build/lib/libceph-common.so build/lib/libceph-common.so.2 %(location)s/lib ; cd %(location)s/lib

patch-binary = ${patch:location}/bin/patch
patch-options = -p1
patches =
  ${:_profile_base_location_}/ceph-minimal.patch#a84c4d30586c8b8f87a581fed5fbf5d8

CMAKE_LIBRARY_PATH="${util-linux:location}/lib;${ncurses:location}/lib;${keyutils:location}/x86_64-linux-gnu;${cryptsetup:location}/lib;${snappy:location}/lib;${systemd:location}/lib64;${zlib:location}/lib;${libnl:location}/lib;${boost-lib:location}/lib;${curl:location}/lib;${openssl:location}/lib"
CMAKE_INCLUDE_PATH="${systemd:location}/include;${util-linux:location}/include;${boost-lib:location}/include;${ncurses:location}/include;${keyutils:location}/include;${cryptsetup:location}/include;${snappy:location}/include;${zlib:location}/include;${libnl:location}/include;${curl:location}/include;${openssl:location}/include"

environment =
  PATH=${cmake:location}/bin:${ninja:location}/bin:${pkgconfig:location}/bin:${librbd-python:location}/bin:%(PATH)s

configure-options =
  -DCMAKE_BUILD_TYPE=RelWithDebInfo
  -DCMAKE_INCLUDE_PATH=${:CMAKE_INCLUDE_PATH}
  -DCMAKE_INSTALL_PREFIX=%(location)s
  -DCMAKE_LIBRARY_PATH=${:CMAKE_LIBRARY_PATH}
  -DCMAKE_INSTALL_RPATH=%(location)s/lib
  -DDEBUG_GATHER=OFF
  -DWITH_SYSTEM_ROCKSDB=OFF
  -DWITH_BABELTRACE=OFF
  -DWITH_BLUESTORE=OFF
  -DWITH_CEPHFS=OFF
  -DWITH_FUSE=OFF
  -DWITH_FUSE=OFF
  -DWITH_KRBD=OFF
  -DWITH_LIBCEPHFS=OFF
  -DWITH_LIBCEPHSQLITE=OFF
  -DWITH_LTTNG=OFF
  -DWITH_LZ4=OFF
  -DWITH_MANPAGE=OFF
  -DWITH_MGR=OFF
  -DWITH_MGR_DASHBOARD_FRONTEND=OFF
  -DWITH_OPENLDAP=OFF
  -DWITH_RADOSGW=OFF
  -DWITH_RADOSGW_AMQP_ENDPOINT=OFF
  -DWITH_RADOSGW_BEAST_OPENSSL=OFF
  -DWITH_RADOSGW_DBSTORE=OFF
  -DWITH_RADOSGW_KAFKA_ENDPOINT=OFF
  -DWITH_RADOSGW_LUA_PACKAGES=OFF
  -DWITH_RADOSGW_SELECT_PARQUET=OFF
  -DWITH_RBD=ON
  -DWITH_RDMA=OFF
  -DWITH_SYSTEMD=OFF
  -DWITH_SYSTEM_BOOST=ON
  -DWITH_TESTS=OFF
  -DWITH_XFS=OFF
  -GNinja
  -S . -B build