[buildout]
extends =
  ../java/buildout.cfg
  ../xorg/buildout.cfg
  ../tesseract/buildout.cfg
parts =
  sikuli

[java]
<= java-re-temurin-11

[sikuli-download]
recipe = slapos.recipe.build:download
url = https://launchpad.net/sikuli/sikulix/2.0.5/+download/sikulixide-2.0.5.jar
filename = sikulixide-2.0.5.jar
md5sum = 0795f1e0866ee5a7a84e4c89793ea78c

[sikuli]
recipe = slapos.recipe.template
output = ${buildout:parts-directory}/${:_buildout_section_name_}/sikulix
inline =
  #!/bin/sh -e
  export JAVA_HOME=${java:location}
  export JRE_HOME=${java:location}
  export PATH=${java:location}/bin:$PATH
  # Sikulix jar file hash some embeded shared libraries (libJXGrabKey.so, libopencv_java430.so)
  export LD_LIBRARY_PATH=${tesseract:location}/lib:${libX11:location}/lib:${gcc:prefix}/lib64:${gcc:prefix}/lib:${libxcb:location}/lib:${libXau:location}/lib:${libXdmcp:location}/lib$${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}

  exec java -jar ${sikuli-download:location}/${sikuli-download:filename} "$@"
