[buildout]

parts =
  firewalld-patch

extends =
  ../pkgconfig/buildout.cfg
  ../autoconf/buildout.cfg
  ../automake/buildout.cfg
  ../libtool/buildout.cfg
  ../intltool/buildout.cfg
  ../gettext/buildout.cfg
  ../glib/buildout.cfg
  ../m4/buildout.cfg
  ../python-slip/buildout.cfg
  ../dbus/buildout.cfg
  ../python-2.7/buildout.cfg
  ../libffi/buildout.cfg
  ../flex/buildout.cfg
  ../bison/buildout.cfg
  ../xz-utils/buildout.cfg
  ../perl/buildout.cfg

[firewalld]
recipe = slapos.recipe.cmmi
url = https://github.com/t-woerner/firewalld/archive/v0.3.14.2.tar.gz
md5sum = b8f81b536ede502721f69300d374447b
python-egg = ${buildout:parts-directory}/${:_buildout_section_name_}/lib/python2.7/site-packages
pre-configure =
  sed -i -E 's,(^SUBDIRS *=.*) doc(\b.*),\1\2,' Makefile.am
  aclocal -I${pkgconfig:location}/share/aclocal -I${gettext:location}/share/aclocal -I${libtool:location}/share/aclocal
  ./autogen.sh

environment =
  PKG_CONFIG_PATH=${glib:location}/lib/pkgconfig
  PATH=${autoconf:location}/bin:${automake:location}/bin:${pkgconfig:location}/bin:${libtool:location}/bin:${intltool:location}/bin:${gettext:location}/bin:${glib:location}/bin:${perl:location}/bin:%(PATH)s
  CPPFLAGS=-I${gettext:location}/include
  LDFLAGS=-L${gettext:location}/lib -Wl,-rpath=${gettext:location}/lib
  PYTHON=${python2.7:location}/bin/python2.7
  M4=${m4:location}/bin/m4
  ACLOCAL_PATH=${pkgconfig:location}/share/aclocal:${gettext:location}/share/aclocal:${libtool:location}/share/aclocal:${glib:location}/share/aclocal:${intltool:location}/share/aclocal
  FIREWALLD_DEVEL_ENV=${buildout:parts-directory}/${:_buildout_section_name_}/src
  PYTHONPATH=${buildout:parts-directory}/${:_buildout_section_name_}/src

[dbus-python]
recipe = slapos.recipe.cmmi
version = 1.2.0
url = http://dbus.freedesktop.org/releases/dbus-python/dbus-python-${:version}.tar.gz
md5sum = b09cd2d1a057cc432ce944de3fc06bf7
python-egg = ${buildout:parts-directory}/${:_buildout_section_name_}/lib/python2.7/site-packages
environment =
  PKG_CONFIG_PATH=${dbus:location}/lib/pkgconfig:${dbus-glib:location}/lib/pkgconfig:${glib:location}/lib/pkgconfig
  PATH=${pkgconfig:location}/bin:%(PATH)s
  DBUS_CFLAGS=-I${dbus:location}/include/dbus-1.0 -I${dbus:location}/lib/dbus-1.0/include
  DBUS_LIBS=-L${dbus:location}/lib -ldbus-1
  DBUS_GLIB_CFLAGS=-I${dbus-glib:location}/include/dbus-1.0
  DBUS_GLIB_LIBS=-L${dbus-glib:location}/lib -ldbus-glib-1
  CPPFLAGS=-I${glib:location}/include/glib-2.0 -I${glib:location}/lib/glib-2.0/include
  LDFLAGS=-L${glib:location}/lib -Wl,-rpath=${glib:location}/lib
  PYTHON=${python2.7:location}/bin/python2.7
  PYTHON_INCLUDES=-I${python2.7:location}/include/python2.7
  PYTHON_LIBS=-L${python2.7:location}/lib -lpython2.7

[gobject-introspection]
recipe = slapos.recipe.cmmi
url = https://github.com/GNOME/gobject-introspection/archive/GOBJECT_INTROSPECTION_1_45_2.tar.gz
pre-configure =
  libtoolize -c -f
  aclocal -I${pkgconfig:location}/share/aclocal -I${gettext:location}/share/aclocal -I${libtool:location}/share/aclocal
  ./autogen.sh
configure-options =
  --disable-static

environment =
  PATH=${autoconf:location}/bin:${automake:location}/bin:${pkgconfig:location}/bin:${libtool:location}/bin:${intltool:location}/bin:${gettext:location}/bin:${glib:location}/bin:${flex:location}/bin:${bison:location}/bin:%(PATH)s
  PKG_CONFIG_PATH=${glib:location}/lib/pkgconfig
  CPPFLAGS=-I${glib:location}/include/glib-2.0 -I${glib:location}/lib/glib-2.0/include
  LDFLAGS=-L${glib:location}/lib -Wl,-rpath=${glib:location}/lib -L${libffi:location}/lib -Wl,-rpath=${libffi:location}/lib -lffi
  M4=${m4:location}/bin/m4
  ACLOCAL_PATH=${pkgconfig:location}/share/aclocal:${gettext:location}/share/aclocal:${libtool:location}/share/aclocal:${glib:location}/share/aclocal:${intltool:location}/share/aclocal
  PYTHON=${python2.7:location}/bin/python2.7
  GLIB_CFLAGS=-I${glib:location}/include/glib-2.0 -I${glib:location}/lib/glib-2.0/include
  GLIB_LIBS=-L${glib:location}/lib -lglib-2.0 -lintl -lgobject-2.0
  FFI_CFLAGS=-I${libffi:location}/include
  FFI_LIBS=-L${libffi:location}/lib -Wl,-rpath=${libffi:location}/lib -lffi
  GIR_DIR=${buildout:parts-directory}/${:_buildout_section_name_}/share/gir-1.0

[pygobject3]
recipe = slapos.recipe.cmmi
url = http://ftp.gnome.org/pub/GNOME/sources/pygobject/3.10/pygobject-3.10.2.tar.xz
python-egg = ${buildout:parts-directory}/${:_buildout_section_name_}/lib/python2.7/site-packages
 md5sum = f311155be8510df6ad8e4edf1cb463d4
pre-configure =
  sed -i 's#/usr/local#${gobject-introspection:location}#g' ${gobject-introspection:location}/lib/pkgconfig/gobject-introspection-1.0.pc
configure-options =
  --disable-static
  --disable-cairo
  --with-python=${python2.7:location}/bin/python2.7

environment =
  PATH=${pkgconfig:location}/bin:${libtool:location}/bin:${glib:location}/bin:${xz-utils:location}/bin:%(PATH)s
  PKG_CONFIG_PATH=${glib:location}/lib/pkgconfig:${gobject-introspection:location}/lib/pkgconfig
  PYTHON=${python2.7:location}/bin/python2.7
  FFI_CFLAGS=-I${libffi:location}/include
  FFI_LIBS=-L${libffi:location}/lib -Wl,-rpath=${libffi:location}/lib -lffi
  CPPFLAGS=-I${glib:location}/include/glib-2.0 -I${glib:location}/lib/glib-2.0/include -I${gettext:location}/include -I${libffi:location}/include
  LDFLAGS=-L${glib:location}/lib -Wl,-rpath=${glib:location}/lib -L${gettext:location}/lib -Wl,-rpath=${gettext:location}/lib
#  GLIB_CFLAGS=-I${glib:location}/include/glib-2.0 -I${glib:location}/lib/glib-2.0/include
#  GLIB_LIBS=-L${glib:location}/lib -lgobject-2.0 -lgthread-2.0 -pthread -lrt -lglib-2.0
  GIO_LIBS=-L${glib:location}/lib -lgio-2.0
  GI_CFLAGS=-I${gobject-introspection:location}/include/gobject-introspection-1.0
  GI_LIBS=-L${gobject-introspection:location}/lib -lgirepository-1.0

[trusted-config]
recipe = hexagonit.recipe.download
ignore-existing = true
url = https://raw.githubusercontent.com/t-woerner/firewalld/v0.3.14/config/zones/trusted.xml
download-only = true
filename = trusted.xml
md5sum = 893752ba2e93a1e96334dfee19f884ad

[firewalld-patch]
recipe = plone.recipe.command
python = ${buildout:directory}/bin/${firewalld-eggs:interpreter}
command =
  sed -i 's#/usr/bin/python -Es#${:python}#' ${firewalld:location}/bin/firewall-cmd
  sed -i 's#/usr/bin/python -Es#${:python}#' ${firewalld:location}/sbin/firewalld
  sed -i 's#DefaultZone=public#DefaultZone=trusted#' ${firewalld:location}/etc/firewalld/firewalld.conf
  sed -i 's#/usr/lib/firewalld#${firewalld:location}/lib/firewalld#' ${firewalld:location}/lib/python2.7/site-packages/firewall/config/__init__.py
  sed -i 's#/usr/share/#${firewalld:location}/share#' ${firewalld:location}/lib/python2.7/site-packages/firewall/config/__init__.py
  sed -i "s#import sys#import sys, os\n\nos.environ['GI_TYPELIB_PATH'] = '${gobject-introspection:location}/lib/girepository-1.0/'#" ${:python}
  sed -i 's#<syslog/>#<!-- no syslog -->#' ${dbus:location}/etc/dbus-1/system.conf
  sed -i 's#<user>messagebus</user>#<user>slapsoft</user>#' ${dbus:location}/etc/dbus-1/system.conf
  cp -f ${firewalld:location}/lib/firewalld/zones/trusted.xml ${firewalld:location}/etc/firewalld/zones/
  cp -f ${firewalld:location}/etc/dbus-1/system.d/FirewallD.conf ${dbus:location}/etc/dbus-1/system.d/
  mkdir -p ${buildout:directory}/sbin
update-command = ${:command}

[firewalld-eggs]
recipe = zc.recipe.egg:scripts
interpreter = python.eggs
eggs =
  decorator
  six
  ${python-slip-egg:eggs}

extra-paths =
  ${dbus-python:python-egg}
  ${firewalld:python-egg}
  ${pygobject3:python-egg}
