[buildout]
extends =
  ../dbus/buildout.cfg
  ../fontconfig/buildout.cfg
  ../glib/buildout.cfg
  ../gtk-2/buildout.cfg
  ../libpng/buildout.cfg
  ../xorg/buildout.cfg

parts = 
  chromium
  
[chromium]
recipe = slapos.recipe.build
slapos_promise =
  file:chrome
  file:chrome-wrapper
  file:chrome-slapos

#chromium zip files for linux seem to be corrupted : rights are not correctly
#set (+x) when unzipping using python, but it works when doing "unzip chromium.zip"
#AND it works when unzipping any other archive with python.
#Conclusion : Google, please, learn how to make zip files.
linux_x86 = http://commondatastorage.googleapis.com/chromium-browser-continuous/Linux/109696/chrome-linux.zip 8ba6c022849b2a882b6e65163c147eb9
linux_x86-64 = http://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/109696/chrome-linux.zip a3ed3feb285ecfe7c722576db80d5099
mac_x86-64 = http://commondatastorage.googleapis.com/chromium-browser-continuous/Mac/100142/chrome-mac.zip cb3a76b8a1a93be94df2f500fb621131

script =
  #If part directory already exist, will just throw an error.
  import sys
  platform = '%%s_%%s' %% (guessOperatingSystem(), guessPlatform())
  if not self.options.get('url'): self.options['url'], self.options['md5sum'] = self.options[platform].split(' ')
  extract_dir = self.extract(self.download(self.options['url'], self.options.get('md5sum')))
  workdir = guessworkdir(extract_dir)
  self.copyTree(workdir, "%(location)s")
  wrapper_location = os.path.join("%(location)s", "chrome-slapos")
  wrapper = open(wrapper_location, 'w')
  wrapper.write("""#!/bin/sh
  export LD_LIBRARY_PATH=${libXrender:location}/lib/:${fontconfig:location}/lib/:${dbus:location}/lib/:${dbus-glib:location}/lib/:${pango:location}/lib:${cairo:location}/lib:${glib:location}/lib:${gtk-2:location}/lib:${atk:location}/lib:${gdk-pixbuf:location}/lib:${libXt:location}/lib:${gtk-2:location}/lib:${libpng15:location}/lib:%(location)s
  %(location)s/chrome""")
  wrapper.flush()
  wrapper.close()
  os.chmod(wrapper_location, 0766)
  os.chmod(os.path.join("%(location)s", 'chrome'), 0766)
  os.chmod(os.path.join("%(location)s", 'chrome-wrapper'), 0766)

# requirements : libXrender1 libxss1 x11-common