[buildout]
# Work in progress
extends = 
  ../xorg/buildout.cfg
  ../fontconfig/buildout.cfg
  ../dbus/buildout.cfg
  ../gtk-2/buildout.cfg
  ../libpng/buildout.cfg

parts = 
  opera
  
[opera]
recipe = slapos.recipe.build
slapos_promise =
  file:opera

depends = 
  ${liberation-fonts:location}
  ${ipaex-fonts:location}

x86 = http://arc.opera.com/pub/opera/linux/1151/opera-11.51-1087.i386.linux.tar.bz2 91db21fc001e736a6432627fbf93062f
x86-64 = todohttp://arc.opera.com/pub/opera/linux/1151/opera-11.51-1087.i386.linux.tar.bz2 91db21fc001e736a6432627fbf93062f

script =
  if not self.options.get('url'): self.options['url'], self.options['md5sum'] = self.options[guessPlatform()].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", "opera-slapos")
  wrapper = open(wrapper_location, 'w')
  wrapper.write("""#!/bin/sh
  cd %(location)s
  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:${libpng15:location}/lib:${libSM:location}/lib:${libICE:location}/lib:%(location)s
  export PATH=${fontconfig:location}/bin:$PATH
  %(location)s/opera $*""")
  wrapper.close()
  profile_directory = os.path.join("%(location)s", "profile")
  os.mkdir(profile_directory)
  opera_config = open(os.path.join(profile_directory, "opera6.ini"), "w")
  opera_config.write("""[State]
  Reading Plugins=0
  Accept License=1
  Run=0""")
  opera_config.close()
  os.chmod(wrapper_location, 0766)

