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

parts =
  firefox

# XXX : Firefox binary tries to find libgnomeui-2.so.0 and it will
# fail to run if exists.

[firefox]
recipe = slapos.recipe.build
slapos_promise =
  file:firefox
  file:firefox-bin

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

version = 27.0

x86 = http://download-installer.cdn.mozilla.net/pub/firefox/releases/${:version}/linux-i686/en-US/firefox-${:version}.tar.bz2 2711961e5fcccbb224625a77fd0f4422
x86-64 = http://download-installer.cdn.mozilla.net/pub/firefox/releases/${:version}/linux-x86_64/en-US/firefox-${:version}.tar.bz2 ea3eb21e260647bfbe5f308bff74d6f0

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", "firefox-slapos")
  wrapper = open(wrapper_location, 'w')
  wrapper.write("""#!${dash:location}/bin/dash
  cd %(location)s
  export LD_LIBRARY_PATH=%(location)s:${alsa:location}/lib:${atk:location}/lib:${bzip2:location}/lib:${cairo:location}/lib:${dbus:location}/lib:${dbus-glib:location}/lib:${fontconfig:location}/lib:${freetype:location}/lib:${gdk-pixbuf:location}/lib:${gettext:location}/lib:${glib:location}/lib:${gtk-2:location}/lib:${harfbuzz:location}/lib:${libICE:location}/lib:${libSM:location}/lib:${libX11:location}/lib:${libXau:location}/lib:${libXcursor:location}/lib:${libXext:location}/lib:${libXrender:location}/lib:${libXt:location}/lib:${libffi:location}/lib:${libpng:location}/lib:${libtool:location}/lib:${libuuid:location}/lib:${libxcb:location}/lib:${libxml2:location}/lib:${pango:location}/lib:${pixman:location}/lib:${xfixes:location}/lib:${zlib:location}/lib
  export PATH=${fontconfig:location}/bin:$PATH
  exec %(location)s/firefox $*""")
  wrapper.close()
  os.chmod(wrapper_location, 0755)