[buildout]
extends =
  ../fontconfig/buildout.cfg
  ../libexpat/buildout.cfg
parts =
  phantomjs

[phantomjs]
recipe = slapos.recipe.build
shared = true
slapos_promise =
  file:phantomjs-slapos

url = https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-${:_url}.tar.bz2
install =
  import os
  self.copyTree(guessworkdir(self.extract(self.download())), location)
  with open(os.path.join(location, "phantomjs-slapos"), 'w') as wrapper:
    wrapper.write("""#!/bin/sh -e
  export LD_LIBRARY_PATH=%s
  export PATH=%s:$PATH
  exec %s/bin/phantomjs "$@"
  """ % (
    ':'.join(options['library'].split()),
    ':'.join(options['path'].split()),
    location,
  ))
    os.fchmod(wrapper.fileno(), 0o755)
library =
  ${freetype:location}/lib
  ${fontconfig:location}/lib
  ${libexpat:location}/lib
path =
  ${fontconfig:location}/bin

[phantomjs:getattr(sys,'_multiarch',None)=='i386-linux-gnu']
_url = linux-i686
md5sum = 9c1426eef5b04679d65198b1bdd6ef88

[phantomjs:getattr(sys,'_multiarch',None)=='x86_64-linux-gnu']
_url = linux-x86_64
md5sum = f278996c3edd0e8d8ec4893807f27d71
