[buildout]

extends =
  ../freetype/buildout.cfg
  ../fontconfig/buildout.cfg
  ../libpng/buildout.cfg
  ../xorg/buildout.cfg
  ../xz-utils/buildout.cfg
  ../zlib/buildout.cfg

parts =
  wkhtmltopdf

[wkhtmltopdf]
recipe = slapos.recipe.build
url = https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_${:_url}.tar.xz
environment =
  PATH=${xz-utils:location}/bin:%(PATH)s
install =
  import os
  self.copyTree(guessworkdir(self.extract(self.download())), location)
  with open(os.path.join(location, "wkhtmltopdf"), 'w') as wrapper:
    wrapper.write("""#!/bin/sh -e
  d=%s
  export LD_LIBRARY_PATH=$d/lib:%s
  export PATH=%s:$PATH
  exec $d/bin/wkhtmltopdf "$@"
  """ % (
    location,
    ':'.join(options['library'].split()),
    ':'.join(options['path'].split()),
  ))
    os.fchmod(wrapper.fileno(), 0o755)
library =
  ${fontconfig:location}/lib
  ${freetype:location}/lib
  ${libX11:location}/lib
  ${libXext:location}/lib
  ${libXrender:location}/lib
  ${libpng12:location}/lib
  ${zlib:location}/lib
path =
  ${fontconfig:location}/bin

[wkhtmltopdf:getattr(sys,'_multiarch',None)=='i386-linux-gnu']
_url = linux-generic-i386
md5sum = ce1a2c0b2cf786ccc5d5828c42c99ddd

[wkhtmltopdf:getattr(sys,'_multiarch',None)=='x86_64-linux-gnu']
_url = linux-generic-amd64
md5sum = 96b7306cebb9e65355f69f7ab63df68b
