template.py 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. pkgname = "firefox"
  2. pkgver = "111.0"
  3. pkgrel = 0
  4. make_cmd = "gmake"
  5. hostmakedepends = [
  6. "pkgconf", "zip", "nasm", "yasm", "cargo", "rust", "python", "cbindgen",
  7. "llvm-devel", "clang-devel", "nodejs", "gettext-tiny", "automake",
  8. "libtool", "gmake",
  9. ]
  10. makedepends = [
  11. "rust-std", "nss-devel", "nspr-devel", "gtk+3-devel", "icu-devel",
  12. "dbus-devel", "glib-devel", "libpulse-devel", "pixman-devel",
  13. "freetype-devel", "libjpeg-turbo-devel", "libpng-devel", "libwebp-devel",
  14. "libevent-devel", "libnotify-devel", "libvpx-devel", "libvorbis-devel",
  15. "libogg-devel", "libtheora-devel", "libxt-devel", "libxcomposite-devel",
  16. "libxscrnsaver-devel", "pipewire-jack-devel", "ffmpeg-devel",
  17. "alsa-lib-devel", "mesa-devel", "libffi-devel", "zlib-devel",
  18. # XXX: https://bugzilla.mozilla.org/show_bug.cgi?id=1532281
  19. "dbus-glib-devel",
  20. ]
  21. depends = ["libavcodec", "hicolor-icon-theme"]
  22. pkgdesc = "Mozilla Firefox web browser"
  23. maintainer = "q66 <q66@chimera-linux.org>"
  24. license = "GPL-3.0-only AND LGPL-2.1-only AND LGPL-3.0-only AND MPL-2.0"
  25. url = "https://www.mozilla.org/firefox"
  26. # TODO: ppc64le JIT
  27. source = f"$(MOZILLA_SITE)/firefox/releases/{pkgver}/source/firefox-{pkgver}.source.tar.xz"
  28. sha256 = "e1006c0872aa7eb30fb5a689413957f1e5fc8d2048b1637bf6f6fafdbd4ea55f"
  29. debug_level = 1 # defatten, especially with LTO
  30. tool_flags = {
  31. "LDFLAGS": ["-Wl,-rpath=/usr/lib/firefox", "-Wl,-z,stack-size=2097152"]
  32. }
  33. env = {
  34. "MAKE": "/usr/bin/gmake",
  35. "SHELL": "/usr/bin/sh",
  36. "BUILD_OFFICIAL": "1",
  37. "MOZILLA_OFFICIAL": "1",
  38. "USE_SHORT_LIBNAME": "1",
  39. "MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE": "system",
  40. "MOZ_APP_REMOTINGNAME": "Firefox",
  41. "MOZBUILD_STATE_PATH": f"/builddir/{pkgname}-{pkgver}/.mozbuild",
  42. # firefox checks for it by calling --help
  43. "CBUILD_BYPASS_STRIP_WRAPPER": "1",
  44. }
  45. # FIXME: youtube causes crashes in libxul after some seconds
  46. hardening = ["!int"]
  47. options = ["!cross"]
  48. exec_wrappers = [
  49. ("/usr/bin/llvm-objdump", "objdump"),
  50. ("/usr/bin/llvm-readelf", "readelf"),
  51. ]
  52. if self.profile().endian == "big":
  53. broken = "broken colors, needs patching, etc."
  54. # crashes compiler in gl.c
  55. if self.profile().arch == "riscv64":
  56. tool_flags["CXXFLAGS"] = ["-U_FORTIFY_SOURCE"]
  57. def post_extract(self):
  58. self.cp(
  59. self.files_path / "stab.h", "toolkit/crashreporter/google-breakpad/src"
  60. )
  61. def post_patch(self):
  62. from cbuild.util import cargo
  63. for crate in []:
  64. cargo.clear_vendor_checksums(
  65. self, crate, vendor_dir = "third_party/rust"
  66. )
  67. def init_configure(self):
  68. from cbuild.util import cargo
  69. env["AS"] = self.get_tool("CC")
  70. env["MOZ_MAKE_FLAGS"] = f"-j{self.make_jobs}"
  71. env["RUST_TARGET"] = self.profile().triplet
  72. # use all the cargo env vars we enforce
  73. env.update(cargo.get_environment(self))
  74. def do_configure(self):
  75. self.rm("objdir", recursive = True, force = True)
  76. self.mkdir("objdir")
  77. extra_opts = []
  78. match self.profile().arch:
  79. case "x86_64" | "aarch64":
  80. extra_opts += ["--disable-elf-hack", "--enable-rust-simd"]
  81. if self.has_lto():
  82. extra_opts += ["--enable-lto=cross"]
  83. self.do(
  84. self.chroot_cwd / "mach", "configure",
  85. "--prefix=/usr",
  86. "--libdir=/usr/lib",
  87. "--host=" + self.profile().triplet,
  88. "--target=" + self.profile().triplet,
  89. "--enable-linker=lld",
  90. "--enable-release",
  91. "--enable-optimize",
  92. "--disable-install-strip",
  93. "--disable-strip",
  94. # system libs
  95. "--with-system-pixman",
  96. "--with-system-ffi",
  97. "--with-system-nspr",
  98. "--with-system-nss",
  99. "--with-system-jpeg",
  100. "--with-system-webp",
  101. "--with-system-zlib",
  102. "--with-system-libevent",
  103. "--with-system-libvpx",
  104. "--with-system-icu",
  105. # no apng support
  106. "--without-system-png",
  107. # wasi currently not ready
  108. "--without-wasm-sandboxed-libraries",
  109. # features
  110. "--enable-dbus",
  111. "--enable-jack",
  112. "--enable-ffmpeg",
  113. "--enable-pulseaudio",
  114. "--enable-necko-wifi",
  115. "--enable-default-toolkit=cairo-gtk3-wayland",
  116. "--enable-audio-backends=pulseaudio",
  117. # disabled features
  118. "--disable-crashreporter",
  119. "--disable-profiling",
  120. "--disable-jemalloc",
  121. "--disable-tests",
  122. "--disable-updater",
  123. "--disable-alsa",
  124. # browser options
  125. "--enable-official-branding",
  126. "--enable-application=browser",
  127. "--allow-addon-sideload",
  128. # conditional opts
  129. *extra_opts, wrksrc = "objdir"
  130. )
  131. def do_build(self):
  132. self.do(self.chroot_cwd / "mach", "build", wrksrc = "objdir")
  133. def do_install(self):
  134. self.do(self.chroot_cwd / "mach", "install", wrksrc = "objdir", env = {
  135. "DESTDIR": str(self.chroot_destdir)
  136. })
  137. self.install_file(
  138. self.files_path / "vendor.js",
  139. "usr/lib/firefox/browser/defaults/preferences"
  140. )
  141. self.install_file(
  142. "taskcluster/docker/firefox-snap/firefox.desktop",
  143. "usr/share/applications"
  144. )
  145. # icons
  146. for sz in [16, 22, 24, 32, 48, 128, 256]:
  147. self.install_file(
  148. f"browser/branding/official/default{sz}.png",
  149. f"usr/share/icons/hicolor/{sz}x{sz}/apps", name = "firefox.png"
  150. )
  151. # https://bugzilla.mozilla.org/show_bug.cgi?id=658850
  152. self.rm(self.destdir / "usr/lib/firefox/firefox-bin")
  153. self.install_link("firefox", "usr/lib/firefox/firefox-bin")
  154. def do_check(self):
  155. # XXX: maybe someday
  156. pass