PKGBUILD 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097
  1. # Maintainer (arch:firefox): Jan Alexander Steffens (heftig) <heftig@archlinux.org>
  2. # Contributor: Ionut Biru <ibiru@archlinux.org>
  3. # Contributor: Jakub Schmidtke <sjakub@gmail.com>
  4. # Contributor: Henry Jensen <hjensen@connochaetos.org>
  5. # Maintainer (archarm:firefox): Kevin Mihelich <kevin@archlinuxarm.org>
  6. # Maintainer (arch32:firefox): Andreas Baumann <mail@andreasbaumann.cc>
  7. # Contributor: Erich Eckner <git@eckner.net>
  8. # Contributor: Andreas Grapentin <andreas@grapentin.org>
  9. # Contributor: Luke Shumaker <lukeshu@parabola.nu>
  10. # Contributor: André Silva <emulatorman@hyperbola.info>
  11. # Contributor: Márcio Silva <coadde@hyperbola.info>
  12. # Contributor: fauno <fauno@kiwwwi.com.ar>
  13. # Contributor: vando <facundo@esdebian.org>
  14. # Contributor: Figue <ffigue at gmail>
  15. # Contributor: evr <evanroman at gmail>
  16. # Contributor: Muhammad 'MJ' Jassim <UnbreakableMJ@gmail.com>
  17. # Contributor: vando <facundo@esdebian.org>
  18. # Contributor: taro-k <taro-k@movasense_com>
  19. # Contributor: Michał Masłowski <mtjm@mtjm.eu>
  20. # Contributor: Luke R. <g4jc@openmailbox.org>
  21. # Contributor: Isaac David <isacdaavid@isacdaavid.info>
  22. # Contributor: bill-auger <bill-auger@programmer.net>
  23. # Contributor: grizzlyuser <grizzlyuser@protonmail.com>
  24. # parabola changes and rationale:
  25. # libre:
  26. # - Modify the add-ons GUI to search the Gnuzilla Mozzarella website
  27. # instead of the Mozilla add-ons website, which hosts non-free addons
  28. # - Disable EME, which is implemented via the non-free libWideVine CDM
  29. # - Disable Normandy that let Mozilla push messages with recommendations
  30. # of nonfree software
  31. # - Make Remote Settings work completely offline using local data
  32. # - Use system python libs. The arch package uses 'pip' to download
  33. # dependencies from the internet at build-time, despite that those needed
  34. # dependencies are already packaged in the arch repos. So strictly-speaking,
  35. # the package is not built from source, as some sources will be missing
  36. # from the published source package, and will not be required as makedepends.
  37. #
  38. # technical:
  39. # - build 32-bit arches with GCC instead of clang (sometimes)
  40. # - disable rust-SIMD, LTO, PGO, and skip profiling build for armv7h and i686
  41. # - allow skipping profiling build for x86_64 (_SKIP_PGO).
  42. # this is to avoid OOM problems, and occasional deadlocks in some versions,
  43. # which expect active netwokring or internet access at build time.
  44. # - prefer as many system libs as possible, over their vendored couterparts
  45. # - Rebrand to Iceweasel, per the mozilla trademark policy, due to the FSDG changes
  46. # - set user profile directory to ~/.mozilla/iceweasel
  47. #
  48. # privacy:
  49. # - Remove Google API keys and usage
  50. # - Disable Mozilla telemetry and crash reporting
  51. # (good manners because of all of the other patching we're doing)
  52. # - do not compile/upload remote debug symbols
  53. # NOTE: This PKGBUILD is kept in-sync, as closely as possible,
  54. # with arch{,arm,32} (firefox), and parabola {iceweasel,icecat},
  55. # for the sake of documentation and cleaner diffs.
  56. # That also helps to identify which changes were made by Parabola vs upstream.
  57. # Therefore, this PKGBUILD may declare blacklisted dependencies, non-free sources,
  58. # or include code for anti-features; but those will be filtered-out subsequently.
  59. # Any code which implements an anti-feature should be commented-out;
  60. # and include an 'anti-feature' comment, for clarity.
  61. # Any blacklisted dependencies and non-free sources should be filtered,
  62. # and include a 'non-free' comment, for clarity.
  63. # Without those over-rides, the resulting program may not be FSDG-fit.
  64. # Do not circumvent those over-rides, if compiling for the Parabola repos.
  65. pkgname=iceweasel
  66. epoch=1
  67. pkgver=133.0
  68. pkgrel=1
  69. _brandingver=131.0
  70. _brandingrel=1
  71. pkgdesc="Fast, Private & Safe Web Browser"
  72. url=https://wiki.parabola.nu/Iceweasel
  73. arch=(x86_64)
  74. arch+=(armv7h i686)
  75. license=(MPL-2.0)
  76. depends=(
  77. alsa-lib
  78. at-spi2-core
  79. bash
  80. cairo
  81. dbus
  82. ffmpeg
  83. fontconfig
  84. freetype2
  85. gcc-libs
  86. gdk-pixbuf2
  87. glib2
  88. glibc
  89. gtk3
  90. hicolor-icon-theme
  91. libpulse
  92. libx11
  93. libxcb
  94. libxcomposite
  95. libxdamage
  96. libxext
  97. libxfixes
  98. libxrandr
  99. libxss
  100. libxt
  101. mime-types
  102. nspr
  103. nss
  104. pango
  105. ttf-font
  106. )
  107. makedepends=(
  108. cbindgen
  109. clang
  110. diffutils
  111. imake
  112. inetutils
  113. jack
  114. lld
  115. llvm
  116. mesa
  117. nasm
  118. nodejs
  119. python
  120. rust
  121. unzip
  122. wasi-compiler-rt
  123. wasi-libc
  124. wasi-libc++
  125. wasi-libc++abi
  126. xorg-server-xvfb
  127. yasm
  128. zip
  129. )
  130. makedepends+=(
  131. git # clean source-ball
  132. imagemagick # process branding images
  133. jq # anti-features check
  134. libxslt # process branding images
  135. python-jsonschema # process-json-files.py
  136. python-setuptools # de-pip
  137. python-typing_extensions # de-vendoring
  138. python-zstandard # de-pip
  139. quilt # apply branding patches
  140. )
  141. optdepends=(
  142. 'hunspell-en_US: Spell checking, American English'
  143. 'libnotify: Notification integration'
  144. 'networkmanager: Location detection via available WiFi networks'
  145. 'speech-dispatcher: Text-to-Speech'
  146. 'xdg-desktop-portal: Screensharing with Wayland'
  147. )
  148. # install=${pkgname}.install # TODO: redmine #2164
  149. # provides=('firefox') # TODO: redmine #2164 - currently conflicts with 'your-freedom'
  150. replaces=('firefox')
  151. options=(
  152. !emptydirs
  153. !lto
  154. !makeflags
  155. )
  156. source=(
  157. https://archive.mozilla.org/pub/firefox/releases/$pkgver/source/firefox-$pkgver.source.tar.xz{,.asc}
  158. $pkgname-symbolic.svg
  159. $pkgname.desktop
  160. org.mozilla.$pkgname.metainfo.xml
  161. )
  162. source=( ${source[*]/${pkgname}-symbolic.svg/} ) # branding over-ride
  163. source=( ${source[*]/org.mozilla./nu.parabola.}) # branding over-ride
  164. source+=( vendor.js.in ) # FSDG config options
  165. source_i686=(
  166. avoid-libxul-OOM-python-check.patch
  167. firefox-111.0.1-fdlibm.patch
  168. fix-i686-build-moz-1792159.patch
  169. fix-i686-xsimd-incomplete.patch
  170. )
  171. validpgpkeys=(
  172. # Mozilla Software Releases <release@mozilla.com>
  173. # https://blog.mozilla.org/security/2023/05/11/updated-gpg-key-for-signing-firefox-releases/
  174. 14F26682D0916CDD81E37B6D61B7B526D98F0353
  175. )
  176. validpgpkeys+=(
  177. 3954A7AB837D0EA9CFA9798925DB7D9B5A8D4B40 # bill-auger (branding source-ball)
  178. BFA8008A8265677063B11BF47171986E4B745536 # Andreas Grapentin (branding source-ball)
  179. 3954A7AB837D0EA9CFA9798925DB7D9B5A8D4B40 # bill-auger (libre source-ball)
  180. )
  181. sha256sums=('492b2c9a3b6d215e38ce490624e8b2b9473419accdeaddb24ba00bc6adc3cc60'
  182. 'SKIP'
  183. # $pkgname-symbolic.svg
  184. '614f2ab3f7bbe783ca50b94f4c78081ee1f98605156ee8ff379e251191b61bdb' # $pkgname.desktop
  185. 'a6e4ab312203ae1df50537f4e6631417b84df46bac4cce2d51145751a405cd8f') # nu.parabola.$pkgname.metainfo.xml
  186. sha256sums+=('86bd54db6026ff65bd24ac4f05d0679a645ff447e2f81b0ee44037c0c4285e06') # vendor.js.in
  187. sha256sums_i686=('65395a49fd3d998f7e06a430bdd656ad453254dafcc34e21ec7931902d8c1809' # avoid-libxul-OOM-python-check.patch
  188. 'ed3bb281697af7c4353a34067ffb4b18a971d40757bef2d6af3c8bf2d28d42d1' # firefox-111.0.1-fdlibm.patch
  189. '2fb39374fd3d80eea9e346032a2a4b2bc2e357dee7380855b24bcf19b1335d06' # fix-i686-build-moz-1792159.patch
  190. 'c3ce181fbb0142055aa6dd17f3cda2ba6a1e54d7a689a8c6e9cce76aa40e6544') # fix-i686-xsimd-incomplete.patch
  191. b2sums=('6c356a4d34044825e86f712b959cbfa6ee27c989c74e42b0b276ee6b169ca84b467ed5ea82f850a517694b75be104362273075c2aa6019f9d30e1be4035b3dd6'
  192. 'SKIP'
  193. # $pkgname-symbolic.svg
  194. '49b4776b3ec8c70194a8f7c5a6467f71820c6a5d6e2033a519fe2742282c6dc141855c6213c67e34b4e0774227d3c15f9083e708c33e7cd6e4c3a982830fefdf' # $pkgname.desktop
  195. '80cf1f7644f9b509fe374cd51fea288ffcca73f735c7d4c8e2a22be7543aa7e0f3c84a619315e5fb4b82967f1cc7b2b4282658af859be1a08d2f29c39f2815d7') # nu.parabola.$pkgname.metainfo.xml
  196. b2sums+=('f3f344196d03499f3f0392d5dfc5310e131d8c85772edd340faf1df3f04ebf2931eb1dda1b7fe6870d61d498618f4d8ae9f1dd446acbe83e0ce324e04b38f3f9') # vendor.js.in
  197. b2sums_i686=('572bb35d7aee0ac847a864b4309f73390435f16b750b8fa3c78b986181d57cdad434bca006d7438c903b2fdc08385292d08fee1d68c87240af72688d60cb8657' # avoid-libxul-OOM-python-check.patch
  198. '05c7c9727201971650df4ca2e00539767fc9e159539835c641fccab5ec9577a7294e8f62f5d0670158316e5467ea121c03a36fd4ba153e1d60f3402f0430548d' # firefox-111.0.1-fdlibm.patch
  199. 'd20ce3eff595f85df86eaa0dfb665fc356f8987117a771f76adc4ac12046a7e82b0af182fa99f87ea1362a5026c9d0216c7b714649fef0c7294c61c8e8f4d790' # fix-i686-build-moz-1792159.patch
  200. '3e6fd4cebe0fd4c250ccf5b04e12b93e5f4cc2d139301316c987cc07a57b4b6b49b830d745520a82f5ac59da8d17f728a3ecce4dccf21804a2d6a256a6f76472') # fix-i686-xsimd-incomplete.patch
  201. # Google API keys (see http://www.chromium.org/developers/how-tos/api-keys)
  202. # Note: These are for Arch Linux use ONLY. For your own distribution, please
  203. # get your own set of keys. Feel free to contact foutrelis@archlinux.org for
  204. # more information.
  205. _google_api_key= # anti-feature
  206. ## parabola mksource over-rides ##
  207. _N_MKSOURCES=2 # number of sources=() to be isolated for mksource
  208. _N_MKKEYS=3 # number of validpgpkeys=() to be isolated for mksource
  209. mksource=( ${source[*]: 0:${_N_MKSOURCES}} )
  210. mksha256sums=( ${sha256sums[*]: 0:${_N_MKSOURCES}} )
  211. mkb2sums=( ${b2sums[*]: 0:${_N_MKSOURCES}} )
  212. mkvalidpgpkeys=( ${validpgpkeys[*]:0:${_N_MKKEYS}} )
  213. mksource+=( https://repo.parabola.nu/other/iceweasel/${pkgname}_${_brandingver}-${_brandingrel}.branding.tar.xz{,.sig}
  214. 9001-FSDG-sync-remote-settings-with-local-dump.patch
  215. 9002-FSDG-preference-defaults.patch
  216. 9003-FSDG-urihandlers.patch
  217. 9004-FSDG-misc.patch
  218. process-json-files.py )
  219. mksha256sums+=( 'c2f97b90795b9cc8fdb2ebb73cda38100529794ba8f4e358d4238fcc5293cee5' # *.branding.tar.xz
  220. 'SKIP'
  221. 'b9bb1e26b4f4ca4962be5a472f8965813ffb87354281934bbb9e2aa7b2a4a05e' # 9001-FSDG-sync-remote-settings-with-local-dump.patch
  222. 'e488677c244ecec60d5cf07d5a106807e35e71d19449280041944ef62325141b' # 9002-FSDG-preference-defaults.patch
  223. '02f8f09e30fab3ea1dd05fa3dcf58fe3e5204e2aa2ee53755fb3f2966b0e4a2e' # 9003-FSDG-urihandlers.patch
  224. '54be3c5ff632592f4db49911bc99a561aa6d5ba5e105b6f1109b884a4a3169c0' # 9004-FSDG-misc.patch
  225. 'd77624602d6064669e3c44dc4f45fb0ff12d2bf4bbe8e3d36be51a5ae94ca46e' ) # process-json-files.py
  226. mkb2sums+=( '3bdd96a8a398075651d4ea1d87fe58193a53d898a70dccc034d7c9d2c9ed13a17b7539bdc8de2925b55d76171b6583313ad6f75d373fc088f0a2a517bc33cb18' # *.branding.tar.xz
  227. 'SKIP'
  228. 'a3fb269470123df26d388dd05d46bca468c7bee14fec539c394df8b462f69d2d12f4b66f0a1ce3a70d25e8e82bfe55569fd1c4ff125f0ab0af46b4c146315b33' # 9001-FSDG-sync-remote-settings-with-local-dump.patchsettings-with-local-dump.patch
  229. '3c16edbcd7ec79530960097b49a9c72347ef108506bee9e51f06111035a5a09a8ea52bc66126a71e422a90ea0da67d34051568c6e9d0926cb9121281e33589fb' # 9002-FSDG-preference-defaults.patchefaults.patch
  230. '90a4676b9dfaf79f2265bfffa85251ac50423543a4ea6c113047293a36641f5efdac19a6aa753c91861b7ab0844a69c40fe01041d4f8c880c2332f0f79964c5e' # 9003-FSDG-urihandlers.patchpatch
  231. 'fb45647122c3af3a3c4fbdbb5175a05ef950cb47ad98af3deace3bc9fefa277e2ae57ccfbe5dfc0cb713e0d3a2faf47f5e61d22bd9d3568c310e6ea93116e901' # 9004-FSDG-misc.patch
  232. '123a23027f1bf5f0e1f7851de5c95b679d0a110b07f2fc7d2447290157963fce2bbb1f5ed46b0bfdcaf32927cf86cb0226965cafd85a2924be2b1812abb9d4b9' ) # process-json-files.py
  233. source=( https://repo.parabola.nu/other/${pkgname}/${pkgname}-${pkgver}.tar.zst{,.sig}
  234. ${source[*]:${_N_MKSOURCES}} )
  235. sha256sums=( 'db19d3dbcdacdcd9cdb622780d48068072851244187ba97ff1dc547bbfec99bc' # libre source-ball
  236. 'SKIP'
  237. ${sha256sums[*]:${_N_MKSOURCES}} )
  238. b2sums=( '8999c30b38f0f80b054e00ffb33b9246fbbd55c2ab467354cebdeebbf6e16b0e05369e25caa9d45796d84239bfe4a38c1f326c621bec06cff4fe4db1382b9910' # libre source-ball
  239. 'SKIP'
  240. ${b2sums[*]:${_N_MKSOURCES}} )
  241. validpgpkeys=( ${validpgpkeys[*]:${_N_MKKEYS}} )
  242. ## compiler and optimization tweaks ##
  243. # use GCC vs LLVM
  244. # one option or the other may resolve compiler/linker discrepancies for some releases
  245. # this option implies $_SKIP_PGO
  246. # ERROR: Cannot use cross-language PGO with GCC.
  247. readonly _USE_ALT_COMPILER=$(case "${CARCH}" in none) echo 1 ;; *) echo 0 ;; esac)
  248. # use 'bfd' linker vs 'lld'
  249. # most significantly, this also disables LTO and debugging
  250. # the final build with --enable-lto=cross,full requires >50GB RAM + swap
  251. # try one option or the other if during the final stage, the build freezes,
  252. # is killed, or chokes the host due to resource exhaustion
  253. readonly _USE_ALT_LINKER=$(case "${CARCH}" in i686) echo 1 ;; *) echo 0 ;; esac)
  254. # try hard to tell ld and rust not to use too much memory
  255. # this is mainly for x86_64, the combination of all explicit tweaks for armv7h and i686
  256. readonly _USE_LESS_MEMORY=$(case "${CARCH}" in none) echo 1 ;; *) echo 0 ;; esac)
  257. # disable PGO
  258. # PGO is said to afford some marginal performance gains at run-time
  259. # however, it doubles the build time and requires gobs of memory to build
  260. # building with less than 50GB combined RAM+swap available will need to $_SKIP_PGO
  261. # it is possible to build with less memory if the build chroot is on a ZRAM drive
  262. # (see this ticket for details https://pagure.io/abslibre/pull-request/89)
  263. # otherwise, try this if during the profiling stage, the build hangs indefinitely,
  264. # or as an alternative or supplement to $_USE_ALT_LINKER, to reduce memory usage
  265. # known past causes:
  266. # * resource exhaustion
  267. # * a test which misbehaves in environments without networking
  268. readonly _SKIP_PGO=$(case "${CARCH}" in armv7h|i686) echo 1 ;; *) echo $_USE_ALT_COMPILER ;; esac)
  269. # disable debug package
  270. # FIXME: problems with debug symbols - the first error may be due to resource exhaustion <32 GB RAM
  271. # debugedit: Warning, not replacing comp_dir ... encoded as DW_FORM_string. Replacement too large.
  272. # objcopy: ./usr/lib/iceweasel/libxul.so: debuglink section already exists
  273. readonly _NO_DEBUG=$(case "${CARCH}" in none) echo 1 ;; *) echo 0 ;; esac)
  274. (( _NO_DEBUG )) && options+=( !debug )
  275. (( _USE_ALT_LINKER )) && options+=( !debug !lto )
  276. (( _USE_LESS_MEMORY )) && options+=( !debug !lto )
  277. ## dependency tweaks ##
  278. depends+=( libicudata.so libicui18n.so libicuuc.so ) # --with-system-icu
  279. case "${CARCH}" in
  280. armv7h)
  281. makedepends=( ${makedepends[*]/wasi-*/} ) # armv7h has no wasi compiler
  282. makedepends=( ${makedepends[*]/nodejs/nodejs-lts-iron} ) # from archarm since v128 - the reason is not obvious
  283. # obj/dist/system_wrappers/new:3:15: fatal error: 'new' file not found
  284. if ! (( _USE_ALT_COMPILER ))
  285. then makedepends+=( libc++ ) ; export CXXFLAGS+=' -stdlib=libc++' ;
  286. fi
  287. # obj/dist/system_wrappers/aom/aomcx.h:3:15: fatal error: 'aom/aomcx.h' file not found
  288. makedepends+=( aom )
  289. ;;
  290. i686)
  291. # FIXME: disable wasm for i686 - 'wasi-compiler-rt' (in extra) supports only clang 18 (in staging)
  292. # DEBUG: | wasm-ld: error: cannot open /usr/lib/clang/15.0.7/lib/wasi/libclang_rt.builtins-wasm32.a: No such file or directory
  293. # DEBUG: | clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
  294. # ERROR: Cannot find wasi libraries or problem with the wasm linker. Please fix the problem. Or build with --without-wasm-sandboxed-libraries.
  295. makedepends=( ${makedepends[*]/wasi-*/} )
  296. ;;
  297. esac
  298. ## helpers ##
  299. _check_patching() {
  300. echo "Verifying libre patching..."
  301. pushd "${srcdir}"/firefox-${pkgver} > /dev/null
  302. # Remote Settings
  303. local settings_server_regex='firefox.settings.services.(mozilla|allizom).org'
  304. local settings_err_msg="ERROR: 9001-FSDG-sync-remote-settings-with-local-dump.patch needs reworking"
  305. ! grep -qrE $settings_server_regex || ! echo "${settings_err_msg}" || return 1
  306. # Model Hub
  307. local model_hub_server_regex='model-hub.(mozilla|allizom).org'
  308. local model_hub_err_msg="ERROR: 9002-FSDG-preference-defaults.patch needs reworking"
  309. ! grep -qrE $model_hub_server_regex || ! echo "${model_hub_err_msg}" || return 1
  310. # Merino
  311. local merino_server_regex='merino.services.(mozilla|allizom).com'
  312. local merino_err_msg="ERROR: 9002-FSDG-preference-defaults.patch needs reworking"
  313. ! grep -qrE $merino_server_regex || ! echo "${merino_err_msg}" || return 1
  314. # services.addons.mozilla.org API endpoint
  315. local amo_api_endpoint='services.addons.mozilla.org'
  316. local amo_err_msg="ERROR: 9002-FSDG-preference-defaults.patch needs reworking: AMO API endpoint hostname found in source tree"
  317. ! grep -qr $amo_api_endpoint || ! echo "${amo_err_msg}" || return 1
  318. # URI protocol handlers
  319. local uri_handlers=uriloader/exthandler/HandlerList.sys.mjs
  320. local webmails='google|yahoo'
  321. local misc_err_msg="ERROR: 9003-FSDG-urihandlers.patch needs reworking"
  322. grep 'name:' $uri_handlers | grep -q '"KiwiIRC",' &&
  323. ! grep 'name:' $uri_handlers | grep -qv '"KiwiIRC",' &&
  324. ! grep -Eq "($webmails)" $uri_handlers ||
  325. ! echo "${misc_err_msg}" || return 1
  326. popd > /dev/null
  327. echo "Verifying libre patching - OK"
  328. }
  329. _check_build_config() {
  330. # WIP: the check for unsupported/obsolete options does not quite work yet for ARM;
  331. # but i always build i686 and x86_64 first, so the other checks would probably pass on armv7h too
  332. [[ "${CARCH}" != armv7h ]] || return 0
  333. echo "Checking build configuration..."
  334. pushd "${srcdir}"/firefox-${pkgver} > /dev/null
  335. # Each of the [ARCH-SPECIFIC CONFIG] branches in prepare(), should have prepared a
  336. # $srcdir/mozconfig file with any arch-specific changes to the Arch x86_64 PKGBUILD.
  337. # Finally, that file should have been copied to $srcdir/firefox-$pkgver/.mozconfig
  338. [[ -f .mozconfig ]] ||
  339. ! echo "ERROR: cannot continue without a .mozconfig file" || return 1
  340. grep -q ' --with-distribution-id=nu.parabola' .mozconfig ||
  341. ! echo "ERROR: .mozconfig file is not properly re-branded" || return 1
  342. # `./mach configure` produces mozinfo.json, reflecting the current configuration.
  343. # See build/docs/mozinfo.rst
  344. local test_options=( --disable-eme ) # inject important options to detect their validity
  345. cp .mozconfig mozconfig-backup
  346. for opt in ${test_options[*]} ; do echo "ac_add_options ${opt}" >> .mozconfig ; done ;
  347. local was_configure_success=$(./mach configure > configure.log && echo 1 || echo 0)
  348. local obj_directory=$(./mach environment | sed -En '/object directory:/{n;s/^\s+//;p;}')
  349. echo "obj_directory is: ${obj_directory}"
  350. # ensure that DRM (aka: EME) is properly de-configured
  351. # and report failures due to unsupported/obsolete config options (cleanly)
  352. local invalid_opts="$(grep 'InvalidOptionError: ' configure.log | cut -d ' ' -f 3-)"
  353. local is_eme_opt_valid=$([[ "${invalid_opts}" =~ --disable-eme ]] && echo 0 || echo 1)
  354. local is_eme_disabled=$(grep -Eq '[^#]*ac_add_options --disable-eme' mozconfig-backup && echo 1 || echo 0)
  355. mv mozconfig-backup .mozconfig
  356. if (( ! is_eme_opt_valid && is_eme_disabled ))
  357. then echo "ERROR: '--disable-eme' should not be in .mozconfig" ; return 1 ;
  358. elif (( is_eme_opt_valid && ! is_eme_disabled ))
  359. then echo "ERROR: DRM (aka: EME) is not disabled in .mozconfig" ; return 1 ;
  360. elif (( ! was_configure_success ))
  361. then [[ -n "${invalid_opts}" ]] || cat configure.log
  362. echo -e "ERROR: \`./mach configure\` failed\n${invalid_opts}" ; return 1 ;
  363. else rm configure.log
  364. fi
  365. # In this test, jq collects values of the following keys of mozinfo.json into array,
  366. # and checks if any of them are not equal to false, in which case it returns "true".
  367. # E.g. if the value of any key is true or null (in case the key is missing from mozinfo.json),
  368. # that means the build configuration has to be reworked.
  369. local antifeature_keys=( .crashreporter .datareporting .healthreport .normandy .telemetry .updater )
  370. local antifeatures_enabled=()
  371. for key in ${antifeature_keys[*]}
  372. do if jq -e "${key} != false" "${obj_directory}"/mozinfo.json &> /dev/null
  373. then antifeatures_enabled+=( ${key} )
  374. fi
  375. done
  376. if (( ${#antifeatures_enabled[*]} ))
  377. then echo "ERROR: Some anti-features are not disabled - aborting:"
  378. printf " - %s is enabled\n" ${antifeatures_enabled[*]}
  379. return 1
  380. fi
  381. popd > /dev/null
  382. echo "Checking build configuration - READY"
  383. }
  384. ## FSDG patching ##
  385. mksource() {
  386. cd firefox-$pkgver
  387. # delete unused code, such as android build support
  388. echo "Removing unused code..."
  389. # rm -rfv mobile/ # TODO: lets try to prune this
  390. rm -v toolkit/crashreporter/tools/upload_symbols.py
  391. # Upstream tarball can contain some ignored cruft,
  392. # including binaries (for example, python3).
  393. echo "Removing files specified in .gitignore..."
  394. git init -b master && git clean -dfX \
  395. --exclude='!ipc/chromium/src/third_party/libevent/evconfig-private.h' \
  396. --exclude='!toolkit/crashreporter/google-breakpad/src/third_party/lss/' \
  397. --exclude='!third_party/python/**/*.egg-info/' \
  398. --exclude='!gfx/cairo/cairo/src/cairo-features.h'
  399. rm -rf .git/
  400. echo "removing pre-built bits"
  401. rm -frv third_party/rust/winapi-{i686,x86_64}-pc-windows-gnu/**/*.a | sed 's|/[^/]*\.a$|/*.a|' | sort -u
  402. find \( -iregex '.+test.+bundle\.js' -o -iregex '.+[_.]min\.js' -o -name 'minified.js' \) -exec rm -v {} \;
  403. sed -i '/mappings.wasm/d' devtools/client/shared/vendor/source-map/lib/moz.build
  404. find -name '*.wasm' -exec rm -v {} \;
  405. # Remove test-related networking dumps, because they contain code from
  406. # some Amazon webpage with no clear licensing, thus nonfree.
  407. # Also they interfere with checking of Remote Settings patching done later,
  408. # because communication with RS server has been captured in them too.
  409. rm python/mozperftest/mozperftest/system/example.zip
  410. rm testing/mozbase/mozproxy/tests/files/mitm5-linux-firefox-amazon.zip
  411. # Disable various components at the source level
  412. sed -i 's/;1/;0/' toolkit/components/telemetry/components.conf
  413. sed -Ei 's/((MOZ_SERVICES_HEALTHREPORT|MOZ_NORMANDY).+)True/\1False/' browser/moz.configure
  414. #sed -i 's/;1/;0/' browser/experiments/Experiments.manifest
  415. #sed -i '/pocket/d' browser/extensions/moz.build
  416. #sed -i '/activity-stream/d' browser/extensions/moz.build
  417. # Disable/neutralize Remote Settings (as best we can)
  418. local branding_srcdir="${srcdir}"/${pkgname}-${_brandingver}
  419. python ../process-json-files.py "${srcdir}"/firefox-${pkgver} "${branding_srcdir}"
  420. echo "applying 9001-FSDG-sync-remote-settings-with-local-dump.patch"
  421. patch -Np1 --no-backup-if-mismatch -i "${srcdir}"/9001-FSDG-sync-remote-settings-with-local-dump.patch
  422. # disable various phone-home/goelocation anti-featires
  423. echo "applying 9002-FSDG-preference-defaults.patch"
  424. patch -Np1 --no-backup-if-mismatch -i "${srcdir}"/9002-FSDG-preference-defaults.patch
  425. # over-ride/install default URI protocol handlers
  426. echo "applying 9003-FSDG-urihandlers.patch"
  427. patch -Np1 --no-backup-if-mismatch -i "${srcdir}"/9003-FSDG-urihandlers.patch
  428. # Remove remaining non-free bits
  429. echo "applying 9004-FSDG-misc.patch"
  430. patch -Np1 --no-backup-if-mismatch -i "${srcdir}"/9004-FSDG-misc.patch
  431. ## FSDG patching checks ##
  432. _check_patching
  433. }
  434. ## business ##
  435. prepare() {
  436. mkdir mozbuild
  437. cd firefox-$pkgver
  438. ## technical patching ##
  439. # Use system python-typing-extensions instead of the old vendored one to avoid
  440. # unresolvable dependency versions. They are probably downloaded when network
  441. # connectivity is enabled at built time, but that is not the case for Parabola.
  442. echo "deleting vendored 'python-typing-extensions'"
  443. rm -rfv third_party/python/typing_extensions | grep -Fq '' # de-vendoring
  444. # FTBS with LLVM:
  445. # intl/lwbrk/LineBreaker.cpp:453:3: error: static assertion failed due to requirement 'U_LB_COUNT == mozilla::ArrayLength(sUnicodeLineBreakToClass)': Gecko vs ICU LineBreak class mismatch
  446. # appears to be: https://bugzilla.mozilla.org/show_bug.cgi?id=1843007#c1
  447. # but --with-system-icu is still needed
  448. # crude fix, adapted from linuxfromscratch https://wiki.linuxfromscratch.org/blfs/ticket/18799
  449. for i in {43..47}; do
  450. sed '/ZWJ/s/}/,CLASS_CHARACTER&/' -i intl/lwbrk/LineBreaker.cpp
  451. done
  452. ## [ARCH-SPECIFIC PATCHING] ##
  453. case ${CARCH} in
  454. aarch64|armv7h)
  455. ;;
  456. i686)
  457. # readelf: Error: Unable to seek to 0x801db328 for section headers
  458. echo "applying avoid-libxul-OOM-python-check.patch"
  459. patch -p1 -i ../avoid-libxul-OOM-python-check.patch
  460. # https://bugzilla.mozilla.org/show_bug.cgi?id=1729459
  461. # modules/fdlibm/src/math_private.h:34:21: error: conflicting declaration ‘typedef __double_t double_t’
  462. # /usr/include/math.h:156:21: note: previous declaration as ‘typedef long double double_t’
  463. echo "applying firefox-111.0.1-fdlibm.patch"
  464. patch -p1 -i "$srcdir/firefox-111.0.1-fdlibm.patch"
  465. # js/src/jit/shared/AtomicOperations-shared-jit.cpp:88:9: error: ‘AtomicCopyByteUnsynchronized’ was not declared in this scope; did you mean ‘AtomicMemcpyUpUnsynchronized’?
  466. echo "applying fix-i686-build-moz-1792159.patch"
  467. patch -p1 -i "$srcdir/fix-i686-build-moz-1792159.patch"
  468. # https://bugs.archlinux32.org/index.php?do=details&task_id=332
  469. # dom/base/nsTextFragmentGeneric.h:38:16: error: ‘any’ is not a member of ‘xsimd’
  470. # dom/base/nsTextFragmentGeneric.h:16:70: error: incomplete type ‘xsimd::batch<short int, xsimd::sse2>’ used in nested name specifier
  471. # dom/base/nsTextFragmentGeneric.h:35:31: error: ‘xsimd::batch<short int, xsimd::sse2> vectmask’ has incomplete type
  472. # dom/base/nsTextFragmentGeneric.h:37:64: error: incomplete type ‘xsimd::batch<short int, xsimd::sse2>’ used in nested name specifier
  473. echo "applying fix-i686-xsimd-incomplete.patch"
  474. patch -p1 -i "$srcdir/fix-i686-xsimd-incomplete.patch"
  475. ;;
  476. x86_64)
  477. ;;
  478. esac
  479. ## general configuration ##
  480. echo -n "$_google_api_key" >google-api-key
  481. cat >../mozconfig <<END
  482. ac_add_options --enable-application=browser
  483. mk_add_options MOZ_OBJDIR=${PWD@Q}/obj
  484. ac_add_options --prefix=/usr
  485. ac_add_options --enable-release
  486. ac_add_options --enable-hardening
  487. ac_add_options --enable-optimize
  488. ac_add_options --enable-rust-simd
  489. ac_add_options --enable-linker=lld
  490. ac_add_options --disable-install-strip
  491. ac_add_options --disable-elf-hack
  492. ac_add_options --disable-bootstrap
  493. ac_add_options --with-wasi-sysroot=/usr/share/wasi-sysroot
  494. # Branding
  495. ac_add_options --disable-official-branding # branding over-ride
  496. ac_add_options --enable-update-channel=release
  497. ac_add_options --with-distribution-id=nu.parabola # branding over-ride
  498. ac_add_options --with-branding=browser/branding/${pkgname} # branding over-ride
  499. ac_add_options --with-app-name=${pkgname} # branding over-ride
  500. ac_add_options --with-app-basename=${pkgname} # branding over-ride
  501. ac_add_options --with-unsigned-addon-scopes=app,system
  502. ac_add_options --allow-addon-sideload
  503. # export MOZILLA_OFFICIAL=1 # branding over-ride
  504. export MOZ_APP_REMOTINGNAME=$pkgname
  505. export MOZ_TELEMETRY_REPORTING=
  506. export MOZ_REQUIRE_SIGNING=
  507. # Keys
  508. # ac_add_options --with-google-location-service-api-keyfile=${PWD@Q}/google-api-key # anti-feature
  509. # ac_add_options --with-google-safebrowsing-api-keyfile=${PWD@Q}/google-api-key # anti-feature
  510. # System libraries
  511. ac_add_options --with-system-nspr
  512. ac_add_options --with-system-nss
  513. # Features
  514. ac_add_options --enable-alsa
  515. ac_add_options --enable-jack
  516. ac_add_options --disable-crashreporter # anti-feature
  517. ac_add_options --disable-updater
  518. ac_add_options --disable-tests
  519. ac_add_options --disable-eme # anti-feature
  520. END
  521. # de-vendor system libs
  522. cat >> ../mozconfig <<EOF
  523. ac_add_options --with-system-ffi
  524. ac_add_options --with-system-icu
  525. ac_add_options --with-system-jpeg
  526. ac_add_options --with-system-libevent
  527. ac_add_options --with-system-libvpx
  528. ac_add_options --with-system-nspr
  529. ac_add_options --with-system-nss
  530. ac_add_options --with-system-pixman
  531. # ac_add_options --with-system-png # ERROR: --with-system-png won't work because the system's libpng doesn't have APNG support
  532. ac_add_options --with-system-webp
  533. ac_add_options --with-system-zlib
  534. EOF
  535. ## [ARCH-SPECIFIC CONFIG] ##
  536. case ${CARCH} in
  537. aarch64|armv7h)
  538. # archarm configuration #
  539. # archarm recipe has mozconfig over-rides under the 'general configuration' section
  540. # NOTE: '--disable-eme' is currently an invalid option for armv7h.
  541. # It must be deleted in order to compile.
  542. # If ever it becomes valid, it should not be deleted below.
  543. sed -i '
  544. /--enable-hardening/d
  545. /--enable-optimize/d
  546. /--enable-rust-simd/d
  547. s| --with-wasi-sysroot=.*| --without-wasm-sandboxed-libraries|
  548. /--disable-eme/d
  549. ' ../mozconfig
  550. if [[ $CARCH == "armv7h" ]]; then
  551. # `--disable-elf-hack` is handled oddly - rather than minimizing the diff against arch
  552. # as it does for the other deleted options above, the archarm PKGBUILD omits it from
  553. # the 'general configuration' section, then declares it here for armv7 only
  554. echo "ac_add_options --disable-elf-hack" >> .mozconfig
  555. # https://bugzilla.redhat.com/show_bug.cgi?id=1641623
  556. echo "ac_add_options --disable-av1" >> .mozconfig
  557. # reduce jobs due to RAM constraints
  558. MAKEFLAGS="-j1"
  559. export MAKEFLAGS="-j4" # NOTE: under libremakepkg, MAKEFLAGS (in prepare function) must be exported
  560. # archarm 'rust.mk' over-rides are under the '[ARCH-SPECIFIC BUILD CONFIG]' section
  561. # (also, for all arches, under the 'compiler and optimization tweaks' section)
  562. # webrtc on ARMv7 implies android, so disable it
  563. echo "ac_add_options --disable-webrtc" >> .mozconfig
  564. elif [[ $CARCH == "aarch64" ]]; then
  565. echo 'ac_add_options --enable-rust-simd' >> .mozconfig
  566. sed -i '/--disable-elf-hack/d' ../mozconfig
  567. fi
  568. echo 'ac_add_options --enable-optimize="-g0 -O2"' >> .mozconfig
  569. echo "mk_add_options MOZ_MAKE_FLAGS=\"${MAKEFLAGS}\"" >> .mozconfig
  570. # archarm `export` commands are under the '[ARCH-SPECIFIC BUILD ENV]' section
  571. # archarm patching is under the '[ARCH-SPECIFIC PATCHING]' section
  572. # NOTE: At this point in the recipe, the arch, arch32, and parabola PKGBUILDs
  573. # have prepared a temporary ${srcdir}/mozconfig; but the archarm PKGBUILD
  574. # writes directly to the final firefox-$pkgver/.mozconfig.
  575. # We allowed .mozconfig to be written above, only to minimize the diff against archarm.
  576. # For consistency across arches, we append those changes to ${srcdir}/mozconfig now.
  577. # Later, ${srcdir}/mozconfig will clobber firefox-$pkgver/.mozconfig during build().
  578. cat .mozconfig >> ../mozconfig
  579. ;;
  580. i686)
  581. # arch32 configuration #
  582. # FIXME: see note in 'dependency tweaks' section
  583. sed -i 's| --with-wasi-sysroot=.*| --without-wasm-sandboxed-libraries|' ../mozconfig
  584. # arch32 `export` commands are under the '[ARCH-SPECIFIC BUILD ENV]' section
  585. # arch32 toolchain.configure patching is under the '[ARCH-SPECIFIC BUILD ENV]' section
  586. # arch32 recipe has mozconfig over-rides in mozconfig-i686.patch
  587. cat >>../mozconfig <<END
  588. ac_add_options --disable-webrtc
  589. END
  590. # arch32 patching is under the '[ARCH-SPECIFIC PATCHING]' section
  591. ;;
  592. x86_64)
  593. ;;
  594. *) echo "no [ARCH-SPECIFIC CONFIG] for arch: ${CARCH}" ; return 1 ;
  595. ;;
  596. esac
  597. ## compiler and optimization tweaks ##
  598. if (( _USE_ALT_COMPILER ))
  599. then cat >> ../mozconfig <<END
  600. export CC=gcc
  601. export CXX=g++
  602. export AR=gcc-ar
  603. export NM=gcc-nm
  604. export RANLIB=gcc-ranlib
  605. END
  606. fi
  607. if (( _USE_ALT_LINKER ))
  608. then sed -i '/cargo_rustc_flags += -Clto/d' config/makefiles/rust.mk
  609. cat >> ../mozconfig <<END
  610. ac_add_options --disable-linker=lld
  611. ac_add_options --enable-linker=bfd
  612. ac_add_options --disable-lto
  613. ac_add_options --disable-rust-simd
  614. ac_add_options --disable-debug
  615. ac_add_options --disable-debug-symbols
  616. END
  617. fi
  618. if (( _USE_LESS_MEMORY ))
  619. then # reduce jobs due to RAM constraints
  620. export MAKEFLAGS+=' -j4'
  621. echo 'ac_add_options --enable-optimize="-g0 -O2"' >> ../mozconfig
  622. echo "mk_add_options MOZ_MAKE_FLAGS=\"${MAKEFLAGS}\"" >> ../mozconfig
  623. # disable hard-coded LTO
  624. sed -i '/cargo_rustc_flags += -Clto/d' config/makefiles/rust.mk
  625. sed -i '/RUSTFLAGS += -Cembed-bitcode=yes/d' config/makefiles/rust.mk
  626. # increase codegen-units due to RAM constraints
  627. sed -i 's/codegen-units=1/codegen-units=16/' config/makefiles/rust.mk
  628. # avoid excessive debug symbols in rust leading to out-of-memory situations
  629. sed -i "s/debug_info = '\''2'\''/debug_info = '\''0'\''/" build/moz.configure/toolchain.configure
  630. # try hard to tell ld and rust not to use too much memory (no lto, no debug info, etc.)
  631. export RUSTFLAGS+=" -Cdebuginfo=0 -Clto=off"
  632. export LDFLAGS+=" -Wl,--no-keep-memory "
  633. fi
  634. ## branding ##
  635. local branding_srcdir="${srcdir}"/${pkgname}-${_brandingver}
  636. local branding_destdir="${srcdir}"/firefox-${pkgver}/browser/branding/${pkgname}
  637. local tippytopdir="${srcdir}"/firefox-${pkgver}/browser/components/newtab/data/content/tippytop
  638. local blank_svg='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"></svg>' # TODO: branding package
  639. # apply branding
  640. echo "applying parabola branding"
  641. export QUILT_PATCHES="${branding_srcdir}"/patches
  642. export QUILT_REFRESH_ARGS='-p ab --no-timestamps --no-index'
  643. export QUILT_DIFF_ARGS='--no-timestamps'
  644. export QUILT_PC="${srcdir}"/.pc
  645. rm -rf -- "${branding_destdir}"
  646. cp -aT -- "${branding_srcdir}"/branding "${branding_destdir}"
  647. quilt push -av
  648. pushd "${branding_destdir}" > /dev/null
  649. # generate icons, logos, banners
  650. echo "generating branding images"
  651. for size in 16 22 24 32 48 64 128 256
  652. do rsvg-convert -w ${size} -h ${size} iceweasel_icon.svg -o default${size}.png
  653. done
  654. cp iceweasel_logo.svg content/aboutlogins.svg
  655. cp iceweasel_logo.svg content/about-logo.svg
  656. # cp iceweasel_logo.svg content/about-logo.svg # RuntimeError: File "about-logo.svg" not found in browser/branding/iceweasel/content
  657. rsvg-convert -a -w 192 iceweasel_logo.svg -o content/about-logo.png
  658. rsvg-convert -a -w 384 iceweasel_logo.svg -o content/about-logo@2x.png
  659. cp content/about-logo.png content/about-logo-private.png
  660. cp content/about-logo@2x.png content/about-logo-private@2x.png
  661. echo "${blank_svg}" > content/${pkgname}-symbolic.svg # TODO: branding package
  662. cp content/${pkgname}-symbolic.svg "${srcdir}"/${pkgname}-symbolic.svg # minimize diff (in package())
  663. cp ../unofficial/document.ico document.ico
  664. cp ../unofficial/content/document_pdf.svg content/document_pdf.svg
  665. popd > /dev/null
  666. # custom new tab page
  667. # FIXME: the newtab page (aka "Start Page") has changed significantly
  668. # the new upstream start page ('activity-streams') is an add-on now
  669. # it must be forked and customized externally, then copied into the browser tree
  670. # see: the branding-dev-build/ dir on the '68.0' branch of the branding git repo
  671. # some of the branding components above and commented out below may no longer be used
  672. # the following section aims to restore something similar
  673. # to the previous parabola-branded "start page"
  674. # once it is working well, all of these comments should be removed
  675. # and any unused branding components may be deleted from the branding package
  676. # Put "Start Page" branding images in the source code
  677. # install -m644 -t browser/base/content/abouthome -- \
  678. # "${branding_srcdir}"/branding/{drm-free,gnu_headshadow,parabola-banner}.png
  679. # install -m644 -t browser/extensions/onboarding/content/img -- \
  680. # "${branding_srcdir}"/branding/watermark.svg
  681. # process default Top Sites and their icons
  682. echo "deleting unused \"Top Sites\""
  683. find "${tippytopdir}" -type f \
  684. -not -name 'wikipedia-org*' \
  685. -not -name 'top_sites.json' \
  686. -exec rm {} \;
  687. [[ "${CARCH}" != armv7h ]] || export MAGICK_TIME_LIMIT=300 # magick: time limit exceeded
  688. for image in "${branding_srcdir}"/tippytop/*.svg; do
  689. local outname=$(basename -s .svg "${image}")
  690. local size=$(identify -format '%wx%h' "${tippytopdir}"/images/wikipedia-org@2x.png)
  691. local background=$( [[ "${outname}" == 'gnu' ]] && echo 'white' || echo 'none' )
  692. magick -density 300 ${image} \
  693. -gravity center -resize ${size} -extent ${size} \
  694. "${tippytopdir}"/images/${outname}@2x.png
  695. size=256x256
  696. magick -density 300 -background ${background} ${image} \
  697. -gravity center -resize ${size} -extent ${size} \
  698. -define icon:auto-resize=64,48,32,16 \
  699. "${tippytopdir}"/favicons/${outname}.ico
  700. done
  701. # misc branding
  702. sed -i "s|({ \$bits }-bit)|($CARCH)|" browser/locales/en-US/browser/aboutDialog.ftl
  703. ## search-engines ##
  704. pushd browser/components/search/extensions > /dev/null
  705. # Delete unused search engine configs
  706. echo "deleting unused search engine configs"
  707. find -mindepth 1 -maxdepth 1 \
  708. -not -name ddg \
  709. -not -name wikipedia \
  710. -exec rm -fr {} \;
  711. popd > /dev/null
  712. }
  713. build() {
  714. cd firefox-$pkgver
  715. ## build env ##
  716. export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system # parabola policy
  717. export MOZBUILD_STATE_PATH="$srcdir/mozbuild"
  718. export MOZ_BUILD_DATE="$(date -u${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH} +%Y%m%d%H%M%S)"
  719. export MOZ_NOSPAM=1
  720. # malloc_usable_size is used in various parts of the codebase
  721. CFLAGS="${CFLAGS/_FORTIFY_SOURCE=3/_FORTIFY_SOURCE=2}"
  722. CXXFLAGS="${CXXFLAGS/_FORTIFY_SOURCE=3/_FORTIFY_SOURCE=2}"
  723. # Breaks compilation since https://bugzilla.mozilla.org/show_bug.cgi?id=1896066
  724. CFLAGS="${CFLAGS/-fexceptions/}"
  725. CXXFLAGS="${CXXFLAGS/-fexceptions/}"
  726. # LTO needs more open files
  727. ulimit -n 4096
  728. if ! (( _USE_ALT_COMPILER ))
  729. then # clang-16: error: unknown argument: '-fvar-tracking-assignments'
  730. export CFLAGS="${CFLAGS/-fvar-tracking-assignments/}"
  731. export CXXFLAGS="${CXXFLAGS/-fvar-tracking-assignments/}"
  732. fi
  733. ## [ARCH-SPECIFIC BUILD ENV] ##
  734. case ${CARCH} in
  735. aarch64|armv7h)
  736. export MOZ_DEBUG_FLAGS=" "
  737. export CFLAGS+=" -g0"
  738. export CXXFLAGS+=" -g0"
  739. export LDFLAGS+=" -Wl,--no-keep-memory"
  740. # export RUSTFLAGS+=" -Cdebuginfo=0 -Clto=off"
  741. export RUSTFLAGS+=" -Cdebuginfo=0"
  742. # clang-16: warning: argument unused during compilation: '-fstack-clash-protection' [-Wunused-command-line-argument]
  743. if ! (( _USE_ALT_COMPILER ))
  744. then export CFLAGS+=' -Wno-unused-command-line-argument'
  745. export CXXFLAGS+=' -Wno-unused-command-line-argument'
  746. fi
  747. # ld.lld: error: version script assignment of <MANY> to symbol <MANY> failed: symbol not defined
  748. # this was supposedly fixed in LLVM 17 https://reviews.llvm.org/D135402
  749. # but could also be de to using a version of LLVM (18) other than rust's vendored version (17)
  750. # https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277075#c12
  751. (( _USE_ALT_LINKER )) || export LDFLAGS+=" -Wl,--undefined-version"
  752. ;;
  753. i686)
  754. # -fno-plt with cross-LTO -> LLVM ERROR: Function Import: link error
  755. CFLAGS="${CFLAGS/-fno-plt/}"
  756. CXXFLAGS="${CXXFLAGS/-fno-plt/}"
  757. # try hard to tell ld and rust not to use too much memory (no lto, no debug info, etc.)
  758. export RUSTFLAGS+=" -Cdebuginfo=0 -Clto=off"
  759. export LDFLAGS+=" -Wl,--no-keep-memory " # -Wl,--reduce-memory-overheads -Wl,--max-cache-size=16384000 "
  760. export MOZ_SOURCE_CHANGESET="DEVEDITION_${pkgver//./_}_RELEASE"
  761. # export MOZ_MAKE_FLAGS=-j2
  762. # libvpx has some hard-coded compiler flags for MMX, SSE, SSE2, use the correct one
  763. # per CARCH (75.0 uses an intrisic _mm_empty now, which required the corresponding
  764. # architecture flag to be preset - before it was merely embedding some assembly
  765. # code with EMMS
  766. export CFLAGS+=" -mmmx"
  767. export CXXFLAGS+=" -mmmx"
  768. ;;
  769. x86_64)
  770. ;;
  771. *) echo "no [ARCH-SPECIFIC BUILD ENV] for arch: ${CARCH}" ; return 1 ;
  772. ;;
  773. esac
  774. export CFLAGS
  775. export CXXFLAGS
  776. ## [ARCH-SPECIFIC BUILD CONFIG] ##
  777. case ${CARCH} in
  778. aarch64|armv7h)
  779. # disable hard-coded LTO
  780. sed -i '/cargo_rustc_flags += -Clto/d' config/makefiles/rust.mk
  781. sed -i '/RUSTFLAGS += -Cembed-bitcode=yes/d' config/makefiles/rust.mk
  782. # increase codegen-units due to RAM constraints
  783. sed -i 's/codegen-units=1/codegen-units=16/' config/makefiles/rust.mk
  784. ;;
  785. i686)
  786. # avoid excessive debug symbols in rust leading to out-of-memory situations
  787. sed -i "s/debug_info = '\''2'\''/debug_info = '\''0'\''/" build/moz.configure/toolchain.configure
  788. ;;
  789. x86_64)
  790. ;;
  791. *) echo "no [ARCH-SPECIFIC BUILD CONFIG] for arch: ${CARCH}" ; return 1 ;
  792. ;;
  793. esac
  794. ## PGO build ##
  795. if (( _SKIP_PGO ))
  796. then
  797. # skipping "3-tier PGO" "instrumented browser"; so the final .mozconfig is ready now
  798. cp ../mozconfig .mozconfig
  799. else
  800. # Do 3-tier PGO
  801. echo "Building instrumented browser..."
  802. cat >.mozconfig ../mozconfig - <<END
  803. ac_add_options --enable-profile-generate=cross
  804. END
  805. _check_build_config # FSDG check
  806. ./mach build --priority normal
  807. echo "Profiling instrumented browser..."
  808. ./mach package
  809. LLVM_PROFDATA=llvm-profdata JARLOG_FILE="$PWD/jarlog" \
  810. dbus-run-session \
  811. xvfb-run -s "-screen 0 1920x1080x24 -nolisten local" \
  812. ./mach python build/pgo/profileserver.py
  813. stat -c "Profile data found (%s bytes)" merged.profdata
  814. test -s merged.profdata
  815. stat -c "Jar log found (%s bytes)" jarlog
  816. test -s jarlog
  817. echo "Removing instrumented browser..."
  818. ./mach clobber objdir
  819. echo "Building optimized browser..."
  820. cat >.mozconfig ../mozconfig - <<END
  821. ac_add_options --enable-lto=cross,full
  822. ac_add_options --enable-profile-use=cross
  823. ac_add_options --with-pgo-profile-path=${PWD@Q}/merged.profdata
  824. ac_add_options --with-pgo-jarlog=${PWD@Q}/jarlog
  825. END
  826. fi # _SKIP_PGO
  827. ## FSDG config checks ##
  828. _check_build_config
  829. ## main build ##
  830. (( ! _SKIP_PGO )) ||
  831. echo "Building optimized browser..."
  832. ./mach build --priority normal
  833. }
  834. package() {
  835. export MOZBUILD_STATE_PATH="$srcdir/mozbuild" # needed for `{libre,}makepkg -R`
  836. export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system # needed for `{libre,}makepkg -R`
  837. cd firefox-$pkgver
  838. DESTDIR="$pkgdir" ./mach install
  839. local vendorjs="$pkgdir/usr/lib/$pkgname/browser/defaults/preferences/vendor.js"
  840. install -Dvm644 /dev/stdin "$vendorjs" <<END
  841. // Use LANG environment variable to choose locale
  842. pref("intl.locale.requested", "");
  843. // Use system-provided dictionaries
  844. pref("spellchecker.dictionary_path", "/usr/share/hunspell");
  845. // Disable default browser checking.
  846. pref("browser.shell.checkDefaultBrowser", false);
  847. // Don't disable extensions in the application directory
  848. pref("extensions.autoDisableScopes", 11);
  849. // Enable GNOME Shell search provider
  850. pref("browser.gnome-search-provider.enabled", true);
  851. END
  852. cat "${srcdir}"/vendor.js.in >> "${vendorjs}" # Parabola additions to vendor.js
  853. local distini="$pkgdir/usr/lib/$pkgname/distribution/distribution.ini"
  854. install -Dvm644 /dev/stdin "$distini" <<END
  855. [Global]
  856. id=parabola
  857. version=(${_brandingver}-${_brandingrel} branding)
  858. about=${pkgname^} for Parabola GNU/Linux-libre
  859. about.en-US=${pkgname^} for Parabola GNU/Linux-libre
  860. about.eo=${pkgname^} por Parabola GNU/Linux-libre
  861. about.es-ES=${pkgname^} para Parabola GNU/Linux-libre
  862. about.gl=${pkgname^} para Parabola GNU/Linux-libre
  863. about.pt-BR=${pkgname^} para Parabola GNU/Linux-libre
  864. [Preferences]
  865. app.distributor=parabola
  866. app.distributor.channel=$pkgname
  867. app.partner.parabola=parabola
  868. END
  869. local i theme=official
  870. theme=$pkgname # NOTE: browser/branding/$theme is $branding_destdir in prepare()
  871. for i in 16 22 24 32 48 64 128 256; do
  872. install -Dvm644 browser/branding/$theme/default$i.png \
  873. "$pkgdir/usr/share/icons/hicolor/${i}x${i}/apps/$pkgname.png"
  874. done
  875. install -Dvm644 browser/branding/$theme/content/about-logo.png \
  876. "$pkgdir/usr/share/icons/hicolor/192x192/apps/$pkgname.png"
  877. install -Dvm644 browser/branding/$theme/content/about-logo@2x.png \
  878. "$pkgdir/usr/share/icons/hicolor/384x384/apps/$pkgname.png"
  879. install -Dvm644 browser/branding/$theme/content/about-logo.svg \
  880. "$pkgdir/usr/share/icons/hicolor/scalable/apps/$pkgname.svg"
  881. install -Dvm644 ../$pkgname-symbolic.svg -t "$pkgdir/usr/share/icons/hicolor/symbolic/apps"
  882. install -Dvm644 ../$pkgname.desktop -t "$pkgdir/usr/share/applications"
  883. install -Dvm644 ../nu.parabola.$pkgname.metainfo.xml -t "$pkgdir/usr/share/metainfo" # branding over-ride
  884. # Install a wrapper to avoid confusion about binary path
  885. install -Dvm755 /dev/stdin "$pkgdir/usr/bin/$pkgname" <<END
  886. #!/bin/sh
  887. exec /usr/lib/$pkgname/firefox "\$@"
  888. END
  889. sed -i "s|/firefox |/${pkgname} |" "$pkgdir/usr/bin/$pkgname" # minimize diff
  890. ## [ARCH-SPECIFIC INSTALL] ##
  891. case ${CARCH} in
  892. aarch64|armv7h)
  893. ;;
  894. i686)
  895. # libxul.so cannot find it's libraries
  896. install -dm 755 "${pkgdir}/etc/ld.so.conf.d"
  897. echo "/usr/lib/${pkgname}" > "${pkgdir}"/etc/ld.so.conf.d/${pkgname}.conf
  898. ;;
  899. x86_64)
  900. ;;
  901. *) echo "no [ARCH-SPECIFIC INSTALL] for arch: ${CARCH}" ; return 1 ;
  902. ;;
  903. esac
  904. # Replace duplicate binary with wrapper
  905. # https://bugzilla.mozilla.org/show_bug.cgi?id=658850
  906. ln -srfv "$pkgdir/usr/bin/$pkgname" "$pkgdir/usr/lib/$pkgname/firefox-bin"
  907. mv "$pkgdir/usr/lib/$pkgname/firefox-bin" "$pkgdir/usr/lib/$pkgname/$pkgname-bin" # minimize diff
  908. # Use system certificates
  909. local nssckbi="$pkgdir/usr/lib/$pkgname/libnssckbi.so"
  910. if [[ -e $nssckbi ]]; then
  911. ln -srfv "$pkgdir/usr/lib/libnssckbi.so" "$nssckbi"
  912. fi
  913. # Configure GNOME Shell search provider
  914. local sprovider="$pkgdir/usr/share/gnome-shell/search-providers/$pkgname.search-provider.ini"
  915. install -Dvm644 /dev/stdin "$sprovider" <<END
  916. [Shell Search Provider]
  917. DesktopId=$pkgname.desktop
  918. BusName=org.mozilla.${pkgname//-/_}.SearchProvider
  919. ObjectPath=/org/mozilla/${pkgname//-/_}/SearchProvider
  920. Version=2
  921. END
  922. }