PKGBUILD 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  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. # NOTE: icecat (60.7 < V <= current) are not complete upstream releases.
  25. # Upstream releases normally have $_upstream_ver ending in '-gnu<N>'.
  26. # Those builds are based on gnuzilla VCS development sources
  27. # with parabola patches applied (offered upstream).
  28. # https://git.parabola.nu/~bill-auger/icecat.git/log/?h=parabola
  29. # NOTE: Occasionally (v102.4.0), a versioned source-ball is published.
  30. # However, like the upstream VCS, they are denoted as 'testing' and are not signed.
  31. # We should still prefer the versioned source-balls. Besides the usually reason
  32. # (always prefer versioned source-balls to VCS builds), they are a significant
  33. # reduction in workload; because gnuzilla can not be compiled from VCS. We first
  34. # need to run the makeicecat.sh script to prepare the source-ball, then sign it and
  35. # publish it, which takes hours. If versioned source-balls become the norm again,
  36. # these NOTEs can be deleted, along with the LOCs commented with "(VCS builds)".
  37. # Until then, whenever building from an upstream source-ball, any un-merged patches
  38. # should be re-implemented in abslibre (eg: 'enable-sync.patch')m and deleted
  39. # again (and 'dummy-sig'), if building from VCS again.
  40. # NOTE: This PKGBUILD is kept in-sync, as closely as possible,
  41. # with arch{,arm,32} (firefox), and parabola {iceweasel,icecat},
  42. # for the sake of documentation and cleaner diffs.
  43. # That also helps to identify which changes were made by Parabola vs upstream.
  44. # Therefore, this PKGBUILD may declare blacklisted dependencies, non-free sources,
  45. # or include code for anti-features; but those will be filtered-out subsequently.
  46. # Any code which implements an anti-feature should be commented-out;
  47. # and include an 'anti-feature' comment, for clarity.
  48. # Any blacklisted dependencies and non-free sources should be filtered,
  49. # and include a 'non-free' comment, for clarity.
  50. # Without those over-rides, the resulting program may not be FSDG-fit.
  51. # Do not circumvent those over-rides, if compiling for the Parabola repos.
  52. pkgname=icecat
  53. _upstream_ver=115.3.1-gnu1
  54. _upstream_ver=${_upstream_ver/-gnu[0-9]/-pre1} # (VCS builds)
  55. pkgver=${_upstream_ver//-/_}
  56. pkgrel=1
  57. pkgdesc="the GNU web browser, derived from Mozilla Firefox ESR"
  58. url=http://www.gnu.org/software/gnuzilla/
  59. arch=(x86_64)
  60. arch+=(
  61. armv7h
  62. i686)
  63. license=(
  64. GPL
  65. LGPL
  66. MPL
  67. )
  68. depends=(
  69. dbus-glib
  70. ffmpeg
  71. gtk3
  72. libpulse
  73. libxt
  74. mime-types
  75. nss
  76. ttf-font
  77. )
  78. makedepends=(
  79. cbindgen
  80. clang
  81. diffutils
  82. dump_syms
  83. imake
  84. inetutils
  85. jack
  86. lld
  87. llvm
  88. mesa
  89. nasm
  90. nodejs
  91. python
  92. rust
  93. unzip
  94. wasi-compiler-rt
  95. wasi-libc
  96. wasi-libc++
  97. wasi-libc++abi
  98. xorg-server-xvfb
  99. yasm
  100. zip
  101. )
  102. makedepends+=(
  103. python-typing_extensions
  104. )
  105. optdepends=(
  106. 'hunspell-en_US: Spell checking, American English'
  107. 'libnotify: Notification integration'
  108. 'networkmanager: Location detection via available WiFi networks'
  109. 'pulseaudio: Audio support'
  110. 'speech-dispatcher: Text-to-Speech'
  111. 'xdg-desktop-portal: Screensharing with Wayland'
  112. )
  113. options=(
  114. !debug
  115. !emptydirs
  116. !lto
  117. !makeflags
  118. !strip
  119. )
  120. source=(https://repo.parabola.nu/other/${pkgname}/${pkgname}-${_upstream_ver}.tar.bz2{,.sig} # (VCS builds)
  121. )
  122. source+=(
  123. icecat.desktop
  124. icecat-safe.desktop
  125. vendor.js.in
  126. zstandard-0.21.0.diff
  127. )
  128. source_i686=(
  129. avoid-libxul-OOM-python-check.patch
  130. rust-static-disable-network-test-on-static-libraries.patch
  131. firefox-111.0.1-fdlibm.patch
  132. fix-i686-build-moz-1792159.patch
  133. fix-i686-xsimd-incomplete.patch
  134. )
  135. validpgpkeys+=('3954A7AB837D0EA9CFA9798925DB7D9B5A8D4B40') # bill-auger (VCS builds)
  136. sha256sums=('44a39b0364da3dfed1f2bad5d7bbf353e7b4c506d8ec8e27a89dec0ef161066e'
  137. 'SKIP'
  138. )
  139. sha256sums+=('e00dbf01803cdd36fd9e1c0c018c19bb6f97e43016ea87062e6134bdc172bc7d'
  140. '33dd309eeb99ec730c97ba844bf6ce6c7840f7d27da19c82389cdefee8c20208'
  141. '8e113fd2730be3fd11b2a24918dd62e8741513cf4dce9819d8eae358c5411adc'
  142. 'aa663d899e924f4979114584cad671dad3b93dd9b0dfe28bb1cf11ddf92e6d47') # zstandard-0.21.0.diff
  143. sha256sums_i686=('2f0c81a38c4578f68f5456b618fe84a78974072821488173eb55e0e72287e353'
  144. '10c5276eab2e87f400a6ec15d7ffbef3b0407ee888dea36f1128927ca55b9041'
  145. 'ed3bb281697af7c4353a34067ffb4b18a971d40757bef2d6af3c8bf2d28d42d1'
  146. '2fb39374fd3d80eea9e346032a2a4b2bc2e357dee7380855b24bcf19b1335d06'
  147. 'c3ce181fbb0142055aa6dd17f3cda2ba6a1e54d7a689a8c6e9cce76aa40e6544')
  148. ## compiler and optimization tweaks ##
  149. # disable PGO
  150. # try this if the build hangs indefinitely - known past causes:
  151. # * resource exhaustion
  152. # * a test which misbehaves in environments without networking
  153. readonly _SKIP_PGO=$(case "${CARCH}" in armv7h|i686) echo 1 ;; *) echo 0 ;; esac)
  154. # use GCC vs LLVM
  155. # trying one or the other, may resolve sporadic compiler/linker discrepancies
  156. readonly _USE_ALT_COMPILER=$(case "${CARCH}" in armv7h) echo 1 ;; *) echo 0 ;; esac)
  157. # use 'bfd' linker vs 'lld'
  158. # most significantly, this also disables LTO and debugging
  159. # try this if the build freezes or crashes due to resource exhaustion
  160. # FIXME: x86_64 FTBS with LTO due to resource exhaustion
  161. # luke added a swapfile to beefcake, because this build crashed the server
  162. # apparently, a measly 32GB RAM is no longer sufficient to contain this beast
  163. # the system no longer crashes now; but the build process gets killed instead
  164. # > clang-15: error: unable to execute command: Killed
  165. readonly _USE_ALT_LINKER=$(case "${CARCH}" in i686|x86_64) echo 1 ;; *) echo 0 ;; esac)
  166. ## dependency tweaks ##
  167. case "${CARCH}" in
  168. armv7h)
  169. makedepends=( ${makedepends[*]/wasi-*/} ) # armv7h has no wasi compiler
  170. depends+=( libicudata.so libicui18n.so libicuuc.so ) # --with-system-icu
  171. ;;
  172. i686)
  173. # checking for nodejs... /usr/bin/node: error while loading shared libraries: libicui18n.so.72
  174. makedepends+=( icu72 )
  175. # wasm-ld: error: cannot open /usr/lib/clang/15.0.7/lib/wasi/libclang_rt.builtins-wasm32.a: No such file or directory
  176. makedepends=( ${makedepends[*]/wasi-compiler-rt/wasi-compiler-rt=15.0.7} ) # dustbin
  177. ;;
  178. esac
  179. ## helpers ##
  180. _check_build_config() {
  181. pushd "${srcdir}"/${pkgname}-${pkgver%%_*} > /dev/null
  182. echo "Checking build configuration..."
  183. # Each of the [ARCH-SPECIFIC CONFIG] branches in prepare(), should have prepared a
  184. # $srcdir/mozconfig file with any arch-specific changes to the Arch x86_64 PKGBUILD.
  185. # Finally, that file should have been copied to $srcdir/firefox-$pkgver/.mozconfig
  186. grep '^ac_add_options --with-distribution-id=nu.parabola' .mozconfig &> /dev/null || \
  187. ! echo "cannot continue without a .mozconfig file" || return 1
  188. if ! [[ "${CARCH}" =~ ^(aarch64|armv7h)$ ]] # ARM has no --disable-eme option
  189. then grep '^ac_add_options --disable-eme' .mozconfig &> /dev/null || \
  190. ! echo ".mozconfig file was not properly treated per the FSDG" || return 1
  191. fi
  192. # Configure produces mozinfo.json that reflects current configuration.
  193. # See build/docs/mozinfo.rst
  194. ./mach configure
  195. # In this test, jq collects values of the following keys of mozinfo.json into array,
  196. # and checks if any of them are not equal to false, in which case it returns "true".
  197. # E.g. if the value of any key is true or null (in case the key is missing from mozinfo.json),
  198. # that means the build configuration has to be reworked.
  199. local obj_directory=$(./mach environment | sed -En '/object directory:/{n;s/^\s+//;p;}')
  200. local antifeature_keys=(.crashreporter .datareporting .healthreport .normandy .telemetry .updater)
  201. local antifeatures=()
  202. echo "obj_directory is: ${obj_directory}"
  203. for key in ${antifeature_keys[@]}
  204. do if jq -e "${key} != false" "${obj_directory}"/mozinfo.json &> /dev/null
  205. then antifeatures+=(${key})
  206. fi
  207. done
  208. if (( ${#antifeatures[@]} ))
  209. then echo "Some anti-features are not disabled in build configuration files - aborting:"
  210. printf " - %s is enabled\n" ${antifeatures[*]}
  211. return 1
  212. fi
  213. popd > /dev/null
  214. }
  215. _check_patching() {
  216. return 0 # let's assume that icecat is already FSDG-fit upstream
  217. }
  218. ## business ##
  219. prepare() {
  220. mkdir mozbuild
  221. cd "$srcdir/$pkgname-${pkgver%%_*}"
  222. ## technical patching ##
  223. # Unbreak build with python-zstandard 0.21.0
  224. echo "applying zstandard-0.21.0.diff"
  225. patch -Np1 -i ../zstandard-0.21.0.diff
  226. # Use system python-typing-extensions instead of the old vendored one to avoid
  227. # unresolvable dependency versions. They are probably downloaded when network
  228. # connectivity is enabled at built time, but that is not the case for Parabola.
  229. rm -rfv third_party/python/typing_extensions
  230. # arch-specific technical patching
  231. case ${CARCH} in
  232. aarch64|armv7h)
  233. # Error: immediate expression requires a # prefix -- `pld [r0,1792]'
  234. # mozilla #1787405 and #1791267
  235. sed -i "s|# 'LIBYUV_DISABLE_NEON',|'LIBYUV_DISABLE_NEON',|" media/libyuv/libyuv/libyuv.gyp
  236. ! grep "# 'LIBYUV_DISABLE_NEON'," media/libyuv/libyuv/libyuv.gyp || ! echo "error patching media/libyuv/libyuv/libyuv.gyp" || exit 1
  237. # FIXME: armv7h FTBS
  238. # ld.lld: error: undefined hidden symbol: I422ToARGBRow_Any_NEON
  239. # also: I422ToARGBRow_NEON I444ToARGBRow_Any_NEON I444ToARGBRow_NEON
  240. # referenced by Unified_cpp_gfx_ycbcr0.cpp
  241. # toolkit/library/build/../../../gfx/ycbcr/Unified_cpp_gfx_ycbcr0.o:(YUVBuferIter_Init)
  242. # ld.lld: error: undefined hidden symbol: ScaleARGBCols_NEON
  243. # also: InterpolateRow_NEON ScaleARGBFilterCols_NEON ScaleARGBRowDownEven_NEON
  244. # ScaleARGBCols_Any_NEON InterpolateRow_Any_NEON ScaleARGBFilterCols_Any_NEON
  245. # ScaleARGBRowDown2_Any_NEON ScaleARGBRowDownEvenBox_NEON
  246. # ScaleARGBRowDownEven_Any_NEON ScaleARGBRowDown2Box_NEON
  247. # ScaleARGBRowDownEvenBox_Any_NEON ScaleARGBRowDown2_NEON
  248. # ScaleARGBRowDown2Box_Any_NEON ScaleARGBRowDown2Linear_Any_NEON
  249. # ScaleARGBRowDown2Linear_NEON
  250. # obj/toolkit/library/build/../../../gfx/ycbcr/Unified_cpp_gfx_ycbcr0.o:(YUVToARGBScale)
  251. ;;
  252. i686)
  253. # readelf: Error: Unable to seek to 0x801db328 for section headers
  254. echo "applying avoid-libxul-OOM-python-check.patch"
  255. patch -p1 -i ../avoid-libxul-OOM-python-check.patch
  256. # test failure in rust code (complaining about network functions) when PGO is used,
  257. # see https://bugzilla.mozilla.org/show_bug.cgi?id=1565757
  258. echo "applying rust-static-disable-network-test-on-static-libraries.patch"
  259. patch -p1 -i ../rust-static-disable-network-test-on-static-libraries.patch
  260. # FIXME: this patch is probably temporary - it comes from mozilla
  261. # https://bugzilla.mozilla.org/show_bug.cgi?id=1729459
  262. # /build/iceweasel/src/firefox-96.0.1/modules/fdlibm/src/math_private.h:34:21:
  263. # error: conflicting declaration ‘typedef __double_t double_t’
  264. # /usr/include/math.h:156:21: note: previous declaration as ‘typedef long double double_t’
  265. echo "applying firefox-111.0.1-fdlibm.patch"
  266. patch -p1 -i "$srcdir/firefox-111.0.1-fdlibm.patch"
  267. # js/src/jit/shared/AtomicOperations-shared-jit.cpp:88:9: error: ‘AtomicCopyByteUnsynchronized’ was not declared in this scope; did you mean ‘AtomicMemcpyUpUnsynchronized’?
  268. echo "applying fix-i686-build-moz-1792159.patch"
  269. patch -p1 -i "$srcdir/fix-i686-build-moz-1792159.patch"
  270. # https://bugs.archlinux32.org/index.php?do=details&task_id=332
  271. # dom/base/nsTextFragmentGeneric.h:38:16: error: ‘any’ is not a member of ‘xsimd’
  272. # dom/base/nsTextFragmentGeneric.h:16:70: error: incomplete type ‘xsimd::batch<short int, xsimd::sse2>’ used in nested name specifier
  273. # dom/base/nsTextFragmentGeneric.h:35:31: error: ‘xsimd::batch<short int, xsimd::sse2> vectmask’ has incomplete type
  274. # dom/base/nsTextFragmentGeneric.h:37:64: error: incomplete type ‘xsimd::batch<short int, xsimd::sse2>’ used in nested name specifier
  275. echo "applying fix-i686-xsimd-incomplete.patch"
  276. patch -p1 -i "$srcdir/fix-i686-xsimd-incomplete.patch"
  277. ;;
  278. x86_64)
  279. ;;
  280. esac
  281. ## general configuration ##
  282. # echo -n "$_google_api_key" >google-api-key # anti-feature
  283. # echo -n "$_mozilla_api_key" >mozilla-api-key # anti-feature
  284. cat >../mozconfig <<END
  285. ac_add_options --enable-application=browser
  286. mk_add_options MOZ_OBJDIR=${PWD@Q}/obj
  287. ac_add_options --prefix=/usr
  288. ac_add_options --enable-release
  289. ac_add_options --enable-hardening
  290. ac_add_options --enable-optimize
  291. ac_add_options --enable-rust-simd
  292. ac_add_options --enable-linker=lld
  293. ac_add_options --disable-elf-hack
  294. ac_add_options --disable-bootstrap
  295. ac_add_options --with-wasi-sysroot=/usr/share/wasi-sysroot
  296. # Branding
  297. ac_add_options --enable-official-branding # icecat branding
  298. ac_add_options --enable-update-channel=release
  299. ac_add_options --with-distribution-id=nu.parabola # branding over-ride
  300. # --with-branding= n/a for icecat
  301. ac_add_options --with-app-name=${pkgname} # branding over-ride
  302. ac_add_options --with-app-basename=${pkgname} # branding over-ride
  303. ac_add_options --with-unsigned-addon-scopes=app,system
  304. ac_add_options --allow-addon-sideload
  305. # export MOZILLA_OFFICIAL=1 # branding over-ride
  306. export MOZ_APP_REMOTINGNAME=${pkgname//-/}
  307. export MOZ_TELEMETRY_REPORTING=
  308. export MOZ_REQUIRE_SIGNING=
  309. # Keys
  310. # ac_add_options --with-google-location-service-api-keyfile=${PWD@Q}/google-api-key # anti-feature
  311. # ac_add_options --with-google-safebrowsing-api-keyfile=${PWD@Q}/google-api-key # anti-feature
  312. # ac_add_options --with-mozilla-api-keyfile=${PWD@Q}/mozilla-api-key # anti-feature
  313. # System libraries
  314. ac_add_options --with-system-nspr
  315. ac_add_options --with-system-nss
  316. # Features
  317. ac_add_options --enable-alsa
  318. ac_add_options --enable-jack
  319. ac_add_options --disable-crashreporter # anti-feature
  320. ac_add_options --disable-updater
  321. ac_add_options --disable-tests
  322. ac_add_options --disable-eme # anti-feature
  323. END
  324. ## [ARCH-SPECIFIC CONFIG] ##
  325. if (( _USE_ALT_COMPILER ))
  326. then cat >> ../mozconfig <<END
  327. export CC=gcc
  328. export CXX=g++
  329. export AR=gcc-ar
  330. export NM=gcc-nm
  331. export RANLIB=gcc-ranlib
  332. END
  333. fi
  334. if (( _USE_ALT_LINKER ))
  335. then sed -i '/cargo_rustc_flags += -Clto/d' config/makefiles/rust.mk
  336. cat >> ../mozconfig <<END
  337. ac_add_options --disable-linker=lld
  338. ac_add_options --enable-linker=bfd
  339. ac_add_options --disable-lto
  340. ac_add_options --disable-rust-simd
  341. ac_add_options --disable-debug
  342. ac_add_options --disable-debug-symbols
  343. END
  344. fi
  345. case ${CARCH} in
  346. aarch64|armv7h)
  347. # experimental/version-specific hacks #
  348. # ld.lld: error: undefined hidden symbol: std::type_info::operator==(std::type_info const&) const
  349. echo 'ac_add_options --with-system-icu' >> ../mozconfig
  350. # archarm configuration #
  351. # archarm recipe has mozconfig over-rides under the 'general configuration' section
  352. # NOTE: '--disable-eme' is currently an invalid option for armv7h.
  353. # It must be deleted in order to compile.
  354. # If ever it becomes valid, it should not be deleted below.
  355. sed -i '
  356. /--enable-hardening/d
  357. /--enable-optimize/d
  358. /--enable-rust-simd/d
  359. s| --with-wasi-sysroot=.*| --without-wasm-sandboxed-libraries|
  360. /--disable-eme/d
  361. ' ../mozconfig
  362. if [[ $CARCH == "armv7h" ]]; then
  363. echo "ac_add_options --disable-elf-hack" >> .mozconfig
  364. # https://bugzilla.redhat.com/show_bug.cgi?id=1641623
  365. echo "ac_add_options --disable-av1" >> .mozconfig
  366. # reduce jobs due to RAM constraints
  367. MAKEFLAGS="-j4"
  368. # disable hard-coded LTO
  369. sed -i '/cargo_rustc_flags += -Clto/d' config/makefiles/rust.mk
  370. sed -i '/RUSTFLAGS += -Cembed-bitcode=yes/d' config/makefiles/rust.mk
  371. # increase codegen-units due to RAM constraints
  372. sed -i 's/codegen-units=1/codegen-units=16/' config/makefiles/rust.mk
  373. # webrtc on ARMv7 implies android, so disable it
  374. echo "ac_add_options --disable-webrtc" >> .mozconfig
  375. elif [[ $CARCH == "aarch64" ]]; then
  376. echo 'ac_add_options --enable-rust-simd' >> .mozconfig
  377. fi
  378. echo 'ac_add_options --enable-optimize="-g0 -O2"' >> .mozconfig
  379. echo "mk_add_options MOZ_MAKE_FLAGS=\"${MAKEFLAGS}\"" >> .mozconfig
  380. # archarm `export` commands are under the '[ARCH-SPECIFIC BUILD ENV]' section
  381. # archarm patching is under the 'technical patching' section
  382. # At this point in the recipe, the arch, arch32, and parabola PKGBUILDs
  383. # have prepared a temporary ${srcdir}/mozconfig; but the archarm PKGBUILD
  384. # writes directly to the final firefox-$pkgver/.mozconfig.
  385. # We allowed .mozconfig to be written above, only to minimize the diff against archarm.
  386. # For consistency across arches, we append those changes to ${srcdir}/mozconfig now.
  387. # ${srcdir}/mozconfig will clobber firefox-$pkgver/.mozconfig later, during build().
  388. cat .mozconfig >> ../mozconfig
  389. ;;
  390. i686)
  391. # experimental/version-specific hacks #
  392. # arch32 configuration #
  393. # arch32 `export` commands are under the '[ARCH-SPECIFIC BUILD ENV]' section
  394. # arch32 recipe has mozconfig over-rides in mozconfig-i686.patch
  395. # in this recipe, the '_USE_ALT_LINKER' block includes most of them
  396. cat >>../mozconfig <<END
  397. ac_add_options --disable-webrtc
  398. END
  399. # arch32 patching is under the 'technical patching' section
  400. ;;
  401. x86_64)
  402. ;;
  403. *) echo "no [ARCH-SPECIFIC CONFIG] for arch: ${CARCH}" ; return 1 ;
  404. ;;
  405. esac
  406. ## search-engines ##
  407. # let's use icecat's default search-engines
  408. ## libre patching ##
  409. # let's assume that icecat is already FSDG-fit upstream
  410. ## patching sanity checks ##
  411. _check_patching
  412. }
  413. build() {
  414. cd "$srcdir/$pkgname-${pkgver%%_*}"
  415. ## build env ##
  416. export MOZ_NOSPAM=1
  417. export MOZBUILD_STATE_PATH="$srcdir/mozbuild"
  418. # export MOZ_ENABLE_FULL_SYMBOLS=1 # anti-feature
  419. export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system # parabola policy
  420. # LTO needs more open files
  421. ulimit -n 4096
  422. ## [ARCH-SPECIFIC BUILD ENV] ##
  423. case ${CARCH} in
  424. aarch64|armv7h)
  425. export MOZ_DEBUG_FLAGS=" "
  426. export CFLAGS+=" -g0"
  427. export CXXFLAGS+=" -g0"
  428. export LDFLAGS+=" -Wl,--no-keep-memory"
  429. export RUSTFLAGS="-Cdebuginfo=0"
  430. ;;
  431. i686)
  432. # -fno-plt with cross-LTO -> LLVM ERROR: Function Import: link error
  433. CFLAGS="${CFLAGS/-fno-plt/}"
  434. CXXFLAGS="${CXXFLAGS/-fno-plt/}"
  435. # try hard to tell ld and rust not to use too much memory (no lto, no debug info, etc.)
  436. export RUSTFLAGS+=" -Cdebuginfo=0 -Clto=off"
  437. export LDFLAGS+=" -Wl,--no-keep-memory " # -Wl,--reduce-memory-overheads -Wl,--max-cache-size=16384000 "
  438. export MOZ_SOURCE_CHANGESET="DEVEDITION_${pkgver//./_}_RELEASE"
  439. # export MOZ_MAKE_FLAGS=-j2
  440. # libvpx has some hard-coded compiler flags for MMX, SSE, SSE2, use the correct one
  441. # per CARCH (75.0 uses an intrisic _mm_empty now, which required the corresponding
  442. # architecture flag to be preset - before it was merely embedding some assembly
  443. # code with EMMS
  444. export CFLAGS+=" -mmmx"
  445. export CXXFLAGS+=" -mmmx"
  446. ;;
  447. x86_64)
  448. ;;
  449. *) echo "no [ARCH-SPECIFIC BUILD ENV] for arch: ${CARCH}" ; return 1 ;
  450. ;;
  451. esac
  452. export CFLAGS
  453. export CXXFLAGS
  454. ## [ARCH-SPECIFIC BUILD CONFIG] ##
  455. case ${CARCH} in
  456. aarch64|armv7h)
  457. ;;
  458. i686)
  459. # avoid excessive debug symbols in rust leading to out-of-memory situations
  460. sed -i "s/debug_info = '\''2'\''/debug_info = '\''0'\''/" build/moz.configure/toolchain.configure
  461. ;;
  462. x86_64)
  463. ;;
  464. *) echo "no [ARCH-SPECIFIC BUILD CONFIG] for arch: ${CARCH}" ; return 1 ;
  465. ;;
  466. esac
  467. ## PGO build ##
  468. if (( _SKIP_PGO ))
  469. then
  470. # skipping "3-tier PGO" "instrumented browser"; so the final .mozconfig is ready now
  471. cp ../mozconfig .mozconfig
  472. else
  473. # Do 3-tier PGO
  474. echo "Building instrumented browser..."
  475. cat >.mozconfig ../mozconfig - <<END
  476. ac_add_options --enable-profile-generate=cross
  477. END
  478. _check_build_config
  479. ./mach build
  480. echo "Profiling instrumented browser..."
  481. ./mach package
  482. LLVM_PROFDATA=llvm-profdata \
  483. JARLOG_FILE="$PWD/jarlog" \
  484. xvfb-run -s "-screen 0 1920x1080x24 -nolisten local" \
  485. ./mach python build/pgo/profileserver.py
  486. stat -c "Profile data found (%s bytes)" merged.profdata
  487. test -s merged.profdata
  488. stat -c "Jar log found (%s bytes)" jarlog
  489. test -s jarlog
  490. echo "Removing instrumented browser..."
  491. ./mach clobber
  492. echo "Building optimized browser..."
  493. cat >.mozconfig ../mozconfig - <<END
  494. ac_add_options --enable-lto=cross
  495. ac_add_options --enable-profile-use=cross
  496. ac_add_options --with-pgo-profile-path=${PWD@Q}/merged.profdata
  497. ac_add_options --with-pgo-jarlog=${PWD@Q}/jarlog
  498. END
  499. fi # _SKIP_PGO
  500. ## sanity checks ##
  501. _check_build_config
  502. ## main build ##
  503. (( ! _SKIP_PGO )) || echo "Building optimized browser..."
  504. ./mach build
  505. # echo "Building symbol archive..." # anti-feature
  506. # ./mach buildsymbols # anti-feature
  507. }
  508. package() {
  509. export MOZBUILD_STATE_PATH="$srcdir/mozbuild" # needed for `libremakepkg -R`
  510. export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system # needed for `libremakepkg -R`
  511. cd "$srcdir/$pkgname-${pkgver%%_*}"
  512. DESTDIR="$pkgdir" ./mach install
  513. local vendorjs="$pkgdir/usr/lib/$pkgname/browser/defaults/preferences/vendor.js"
  514. install -Dvm644 /dev/stdin "$vendorjs" <<END
  515. // Use LANG environment variable to choose locale
  516. pref("intl.locale.requested", "");
  517. // Use system-provided dictionaries
  518. pref("spellchecker.dictionary_path", "/usr/share/hunspell");
  519. // Disable default browser checking.
  520. pref("browser.shell.checkDefaultBrowser", false);
  521. // Don't disable extensions in the application directory
  522. pref("extensions.autoDisableScopes", 11);
  523. // Enable GNOME Shell search provider
  524. pref("browser.gnome-search-provider.enabled", true);
  525. END
  526. # Parabola additions to vendor.js
  527. cat "${srcdir}"/vendor.js.in >> "${vendorjs}"
  528. local distini="$pkgdir/usr/lib/$pkgname/distribution/distribution.ini"
  529. install -Dvm644 /dev/stdin "$distini" <<END
  530. [Global]
  531. id=parabola
  532. version=${_upstream_ver}
  533. about=${pkgname^} for Parabola GNU/Linux-libre
  534. about.en-US=${pkgname^} for Parabola GNU/Linux-libre
  535. about.eo=${pkgname^} por Parabola GNU/Linux-libre
  536. about.es-ES=${pkgname^} para Parabola GNU/Linux-libre
  537. about.gl=${pkgname^} para Parabola GNU/Linux-libre
  538. about.pt-BR=${pkgname^} para Parabola GNU/Linux-libre
  539. [Preferences]
  540. app.distributor=parabola
  541. app.distributor.channel=$pkgname
  542. app.partner.parabola=parabola
  543. END
  544. local i theme=official
  545. for i in 16 22 24 32 48 64 128 256; do
  546. install -Dvm644 browser/branding/$theme/default$i.png \
  547. "$pkgdir/usr/share/icons/hicolor/${i}x${i}/apps/$pkgname.png"
  548. done
  549. install -Dvm644 browser/branding/$theme/content/about-logo.png \
  550. "$pkgdir/usr/share/icons/hicolor/192x192/apps/$pkgname.png"
  551. install -Dvm644 browser/branding/$theme/content/about-logo@2x.png \
  552. "$pkgdir/usr/share/icons/hicolor/384x384/apps/$pkgname.png"
  553. install -Dvm644 browser/branding/$theme/content/about-wordmark.svg \
  554. "$pkgdir/usr/share/icons/hicolor/scalable/apps/$pkgname.svg"
  555. install -Dvm644 browser/branding/$theme/content/identity-icons-brand.svg \
  556. "$pkgdir/usr/share/icons/hicolor/symbolic/apps/$pkgname-symbolic.svg"
  557. install -Dvm644 browser/branding/official/default48.png \
  558. "$pkgdir/usr/share/pixmaps/icecat.png"
  559. install -Dvm644 ../$pkgname.desktop \
  560. "$pkgdir/usr/share/applications/$pkgname.desktop"
  561. # Install a wrapper to avoid confusion about binary path
  562. install -Dvm755 /dev/stdin "$pkgdir/usr/bin/$pkgname" <<END
  563. #!/bin/sh
  564. exec /usr/lib/$pkgname/$pkgname "\$@"
  565. END
  566. ## [ARCH-SPECIFIC INSTALL] ##
  567. case ${CARCH} in
  568. aarch64|armv7h)
  569. ;;
  570. i686)
  571. # libxul.so cannot find it's libraries
  572. install -dm 755 "${pkgdir}/etc/ld.so.conf.d"
  573. echo "/usr/lib/${pkgname}" > "${pkgdir}"/etc/ld.so.conf.d/${pkgname}.conf
  574. ;;
  575. x86_64)
  576. ;;
  577. *) echo "no [ARCH-SPECIFIC INSTALL] for arch: ${CARCH}" ; return 1 ;
  578. ;;
  579. esac
  580. # Replace duplicate binary with wrapper
  581. # https://bugzilla.mozilla.org/show_bug.cgi?id=658850
  582. ln -srfv "$pkgdir/usr/bin/$pkgname" "$pkgdir/usr/lib/$pkgname/$pkgname-bin"
  583. # Use system certificates
  584. local nssckbi="$pkgdir/usr/lib/$pkgname/libnssckbi.so"
  585. if [[ -e $nssckbi ]]; then
  586. ln -srfv "$pkgdir/usr/lib/libnssckbi.so" "$nssckbi"
  587. fi
  588. # Configure GNOME Shell search provider
  589. local sprovider="$pkgdir/usr/share/gnome-shell/search-providers/$pkgname.search-provider.ini"
  590. install -Dvm644 /dev/stdin "$sprovider" <<END
  591. [Shell Search Provider]
  592. DesktopId=$pkgname.desktop
  593. BusName=org.mozilla.${pkgname//-/}.SearchProvider
  594. ObjectPath=/org/mozilla/${pkgname//-/}/SearchProvider
  595. Version=2
  596. END
  597. # export SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE="$startdir/.crash-stats-api.token" # anti-feature
  598. # if [[ -f $SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE ]]; then # anti-feature
  599. # make -C obj uploadsymbols # anti-feature
  600. # else # anti-feature
  601. # cp -fvt "$startdir" obj/dist/*crashreporter-symbols-full.tar.zst # anti-feature
  602. # fi
  603. }