[buildout]
extends =
  ../alsa/buildout.cfg
  ../dash/buildout.cfg
  ../dbus/buildout.cfg
  ../fontconfig/buildout.cfg
  ../gtk-2/buildout.cfg
  ../libffi/buildout.cfg
  ../libpng/buildout.cfg
  ../p11-kit/buildout.cfg
  ../xorg/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 = 34.0.5

# MD5SUMs are available at :
# https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/${:version}/MD5SUMS
x86 = http://download-installer.cdn.mozilla.net/pub/firefox/releases/${:version}/linux-i686/en-US/firefox-${:version}.tar.bz2 dfe5bc7643b3a5636e6775d236f071a5
x86-64 = http://download-installer.cdn.mozilla.net/pub/firefox/releases/${:version}/linux-x86_64/en-US/firefox-${:version}.tar.bz2 1ffca0d8ef608123f2b9b30382043b6a

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:${libXcomposite: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:${p11-kit:location}/lib:${pango:location}/lib:${pixman:location}/lib:${xdamage: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)
