actions.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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("PYTHON", "/usr/bin/python3")
  20. # shelltools.export("MACH_USE_SYSTEM_PYTHON", "1")
  21. shelltools.system("export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE='system'")
  22. shelltools.system("export MOZBUILD_STATE_PATH='mozbuild'")
  23. shelltools.system("export MOZ_NOSPAM=1")
  24. def setup():
  25. shelltools.system("echo 'Instrumenting Firefox for PGO'")
  26. shelltools.system("cp mozconfig-inst .mozconfig")
  27. # Google API key
  28. shelltools.echo("google_api_key", "AIzaSyBINKL31ZYd8W5byPuwTXYK6cEyoceGh6Y")
  29. pisitools.dosed(".mozconfig", "%%PWD%%", get.curDIR())
  30. pisitools.dosed(".mozconfig", "%%FILE%%", "google_api_key")
  31. pisitools.dosed(".mozconfig", "##JOBCOUNT##", jobs)
  32. # LOCALE
  33. shelltools.system("rm -rf langpack-ff/*/browser/defaults")
  34. if not shelltools.isDirectory(xpidir): shelltools.makedirs(xpidir)
  35. for locale in locales:
  36. 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))
  37. #shelltools.makedirs("langpack-ff/langpack-%s@firefox.mozilla.org" % locale)
  38. shelltools.makedirs("langpack-ff")
  39. #shelltools.system("unzip -uo %s/%s.xpi -d langpack-ff/langpack-%s@firefox.mozilla.org" % (xpidir, locale, locale))
  40. shelltools.system("cp %s/%s.xpi langpack-ff/langpack-%s@firefox.mozilla.org.xpi" % (xpidir, locale, locale))
  41. print "Replacing browser.properties for %s locale" % locale
  42. #shelltools.copy("browserconfig.properties", "langpack-ff/langpack-%s@firefox.mozilla.org/browser/chrome/%s/locale/branding/" % (locale, locale))
  43. shelltools.copy("browserconfig.properties", "browser/branding/official/locales/")
  44. #shelltools.makedirs(ObjDir)
  45. #shelltools.cd(ObjDir)
  46. #shelltools.system("../configure --prefix=/usr --libdir=/usr/lib --disable-strip --disable-install-strip")
  47. def build():
  48. shelltools.system("echo 'Building instrumented browser'")
  49. #shelltools.cd(ObjDir)
  50. shelltools.system("./mach build")
  51. shelltools.system("echo 'Profiling instrumented browser...'")
  52. shelltools.system("./mach package")
  53. shelltools.system("LLVM_PROFDATA=llvm-profdata \
  54. JARLOG_FILE='%s/jarlog' \
  55. xvfb-run -s '-screen 0 1920x1080x24 -nolisten local' \
  56. ./mach python3 build/pgo/profileserver.py" %get.curDIR())
  57. shelltools.system("echo 'Removing instrumented browser...'")
  58. shelltools.system("./mach clobber")
  59. shelltools.system("echo 'Building optimized browser...'")
  60. shelltools.system("rm .mozconfig")
  61. shelltools.system("cp mozconfig-opt .mozconfig")
  62. #shelltools.echo("google_api_key", "AIzaSyBINKL31ZYd8W5byPuwTXYK6cEyoceGh6Y")
  63. pisitools.dosed(".mozconfig", "%%PWD%%", get.curDIR())
  64. pisitools.dosed(".mozconfig", "%%FILE%%", "google_api_key")
  65. pisitools.dosed(".mozconfig", "##JOBCOUNT##", jobs)
  66. #shelltools.system("../configure --prefix=/usr --libdir=/usr/lib --disable-strip --disable-install-strip")
  67. shelltools.system("./mach build")
  68. def install():
  69. #shelltools.cd(ObjDir)
  70. shelltools.system("DESTDIR=%s ./mach install " % get.installDIR())
  71. #shelltools.cd("..")
  72. # Install language packs
  73. pisitools.insinto("/usr/lib/firefox/browser/extensions", "./langpack-ff/*")
  74. # Create profile dir, we'll copy bookmarks.html in post-install script
  75. pisitools.dodir("/usr/lib/firefox/browser/defaults/profile")
  76. # Install branding icon
  77. pisitools.insinto("/usr/share/pixmaps", "browser/branding/official/default256.png", "firefox.png")
  78. for s in (16, 22, 24, 32, 48, 64, 128, 256):
  79. pisitools.insinto("/usr/share/icons/hicolor/%dx%d/apps" % (s,s), "browser/branding/official/default%d.png" % s, "firefox.png")
  80. pisitools.insinto("/usr/share/icons/hicolor/192x192/apps", "browser/branding/official/content/about-logo.png", "firefox.png")
  81. pisitools.insinto("/usr/share/icons/hicolor/384x384/apps", "browser/branding/official/content/about-logo@2x.png", "firefox.png")
  82. pisitools.insinto("/usr/share/icons/hicolor/scalable/apps", "browser/branding/official/content/about-logo.svg", "firefox.svg")
  83. # Install docs
  84. pisitools.dodoc("README*", "LICENSE")