actions.py 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Licensed under the GNU General Public License, version 3.
  5. # See the file http://www.gnu.org/licenses/gpl.txt
  6. import subprocess
  7. from pisi.actionsapi import get
  8. from pisi.actionsapi import autotools
  9. from pisi.actionsapi import pisitools
  10. from pisi.actionsapi import shelltools
  11. #WorkDir = "mozilla-release-6b51784853e47e091d213d421a19cb623af718f0"
  12. ObjDir = "objdir"
  13. locales = "az bs ca da de el en-US en-GB es-AR es-CL es-ES fi fr hr hu it lt nl pl pt-BR pt-PT ro ru sr sv-SE tr uk".split()
  14. xpidir = "%s/xpi" % get.workDIR()
  15. arch = get.ARCH()
  16. ver = ".".join(get.srcVERSION().split(".")[:3])
  17. jobs = jobs = "-j"+ subprocess.check_output("nproc 2>/dev/null", shell=True).rstrip("\n")
  18. shelltools.export("SHELL", "/bin/sh")
  19. shelltools.export("MACH_USE_SYSTEM_PYTHON", "1")
  20. def setup():
  21. shelltools.system("echo 'Instrumenting Firefox for PGO'")
  22. shelltools.system("cp mozconfig-inst .mozconfig")
  23. # Google API key
  24. shelltools.echo("google_api_key", "AIzaSyBINKL31ZYd8W5byPuwTXYK6cEyoceGh6Y")
  25. pisitools.dosed(".mozconfig", "%%PWD%%", get.curDIR())
  26. pisitools.dosed(".mozconfig", "%%FILE%%", "google_api_key")
  27. pisitools.dosed(".mozconfig", "##JOBCOUNT##", jobs)
  28. # LOCALE
  29. shelltools.system("rm -rf langpack-ff/*/browser/defaults")
  30. if not shelltools.isDirectory(xpidir): shelltools.makedirs(xpidir)
  31. for locale in locales:
  32. shelltools.system("wget -c -P %s https://download-origin.cdn.mozilla.net/pub/firefox/releases/%s/linux-%s/xpi/%s.xpi" % (xpidir, ver, arch, locale))
  33. #shelltools.makedirs("langpack-ff/langpack-%s@firefox.mozilla.org" % locale)
  34. shelltools.makedirs("langpack-ff")
  35. #shelltools.system("unzip -uo %s/%s.xpi -d langpack-ff/langpack-%s@firefox.mozilla.org" % (xpidir, locale, locale))
  36. shelltools.system("cp %s/%s.xpi langpack-ff/langpack-%s@firefox.mozilla.org.xpi" % (xpidir, locale, locale))
  37. print "Replacing browser.properties for %s locale" % locale
  38. #shelltools.copy("browserconfig.properties", "langpack-ff/langpack-%s@firefox.mozilla.org/browser/chrome/%s/locale/branding/" % (locale, locale))
  39. shelltools.copy("browserconfig.properties", "browser/branding/official/locales/")
  40. #shelltools.makedirs(ObjDir)
  41. #shelltools.cd(ObjDir)
  42. #shelltools.system("../configure --prefix=/usr --libdir=/usr/lib --disable-strip --disable-install-strip")
  43. def build():
  44. shelltools.system("echo 'Building instrumented browser'")
  45. #shelltools.cd(ObjDir)
  46. shelltools.system("./mach build")
  47. shelltools.system("echo 'Profiling instrumented browser...'")
  48. shelltools.system("./mach package")
  49. shelltools.system("LLVM_PROFDATA=llvm-profdata \
  50. JARLOG_FILE='%s/jarlog' \
  51. xvfb-run -s '-screen 0 1920x1080x24 -nolisten local' \
  52. ./mach python build/pgo/profileserver.py" %get.curDIR())
  53. shelltools.system("echo 'Removing instrumented browser...'")
  54. shelltools.system("./mach clobber")
  55. shelltools.system("echo 'Building optimized browser...'")
  56. shelltools.system("rm .mozconfig")
  57. shelltools.system("cp mozconfig-opt .mozconfig")
  58. #shelltools.echo("google_api_key", "AIzaSyBINKL31ZYd8W5byPuwTXYK6cEyoceGh6Y")
  59. pisitools.dosed(".mozconfig", "%%PWD%%", get.curDIR())
  60. pisitools.dosed(".mozconfig", "%%FILE%%", "google_api_key")
  61. pisitools.dosed(".mozconfig", "##JOBCOUNT##", jobs)
  62. #shelltools.system("../configure --prefix=/usr --libdir=/usr/lib --disable-strip --disable-install-strip")
  63. shelltools.system("./mach build")
  64. def install():
  65. #shelltools.cd(ObjDir)
  66. shelltools.system("DESTDIR=%s ./mach install " % get.installDIR())
  67. #shelltools.cd("..")
  68. # Install language packs
  69. pisitools.insinto("/usr/lib/firefox/browser/extensions", "./langpack-ff/*")
  70. # Create profile dir, we'll copy bookmarks.html in post-install script
  71. pisitools.dodir("/usr/lib/firefox/browser/defaults/profile")
  72. # Install branding icon
  73. pisitools.insinto("/usr/share/pixmaps", "browser/branding/official/default256.png", "firefox.png")
  74. # Install docs
  75. pisitools.dodoc("README*", "LICENSE")