PKGBUILD 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. # Maintainer (arch): Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
  2. # Contributor: Ionut Biru <ibiru@archlinux.org>
  3. # Contributor: Jakub Schmidtke <sjakub@gmail.com>
  4. # Contributor: Figue <ffigue at gmail>
  5. # Contributor: fauno <fauno@kiwwwi.com.ar>
  6. # Contributor: evr <evanroman at gmail>
  7. # Contributor: Muhammad 'MJ' Jassim <UnbreakableMJ@gmail.com>
  8. # Contributor: vando <facundo@esdebian.org>
  9. # Contributor: André Silva <emulatorman@hyperbola.info>
  10. # Contributor: Henry Jensen <hjensen@connochaetos.org>
  11. # Contributor: Luke Shumaker <lukeshu@parabola.nu>
  12. # Contributor: Márcio Silva <coadde@hyperbola.info>
  13. # Maintainer: Andreas Grapentin <andreas@grapentin.org>
  14. # Contributor: bill-auger <bill-auger@programmer.net>
  15. # Contributor: grizzlyuser <grizzlyuser@protonmail.com>
  16. # NOTE: icecat (60.7 < V <= 78.10) are not upstream releases
  17. # upstream releases would normally have '-gnu' appended to $_upstream_ver
  18. # this build is based on gnuzilla VCS developement sources
  19. # rev: b72c22186cf381d7b1f93be550c9da30865d03b4
  20. pkgname=icecat
  21. _upstream_ver=78.10.0-pre2 # -gnu1
  22. pkgver=${_upstream_ver//-/_}
  23. pkgrel=1
  24. pkgdesc="the GNU web browser, based on Mozilla Firefox ESR"
  25. arch=(x86_64 i686 armv7h)
  26. license=(MPL GPL LGPL)
  27. url=http://www.gnu.org/software/gnuzilla/
  28. depends=(gtk3 libxt mime-types dbus-glib ffmpeg nss ttf-font libpulse)
  29. makedepends=(m4 unzip zip diffutils python2-setuptools yasm mesa imake inetutils
  30. xorg-server-xvfb autoconf2.13 rust clang llvm jack gtk2
  31. python nodejs python2-psutil cbindgen nasm)
  32. makedepends+=(mozilla-searchplugins jq)
  33. if [[ "${CARCH}" == 'i686' ]]
  34. then makedepends=(${makedepends[*]/llvm/llvm10}) # FIXME: i686 configure fails with LLVM11
  35. # rustup: error while loading shared libraries: libLLVM-10.so
  36. makedepends=(${makedepends[*]/rust/rust=1:1.47.0}) # FIXME: Sandbox: seccomp sandbox violation
  37. else makedepends=(${makedepends[*]/rust/rust=1:1.49.0}) # https://lists.gnu.org/archive/html/gnuzilla-dev/2021-04/msg00000.html
  38. fi
  39. optdepends=('networkmanager: Location detection via available WiFi networks'
  40. 'libnotify: Notification integration'
  41. 'pulseaudio: Audio support'
  42. 'speech-dispatcher: Text-to-Speech'
  43. 'hunspell-en_US: Spell checking, American English')
  44. options=(!emptydirs !makeflags !strip)
  45. source=(https://repo.parabola.nu/other/${pkgname}/${pkgname}-${_upstream_ver}.tar.bz2{,.sig}
  46. icecat.desktop icecat-safe.desktop
  47. 0001-Use-remoting-name-for-GDK-application-names.patch
  48. rust_1.48.patch.gz)
  49. source+=(searchplugins_list.json
  50. 9003-misc-libre.patch)
  51. source_i686=('rust-static-disable-network-test-on-static-libraries.patch')
  52. sha256sums=('f4334ab97a30bf8e8fe400c55ed00fcea1d44536dc6df1c7f65fec8eae1664a3'
  53. 'SKIP'
  54. 'e00dbf01803cdd36fd9e1c0c018c19bb6f97e43016ea87062e6134bdc172bc7d'
  55. '33dd309eeb99ec730c97ba844bf6ce6c7840f7d27da19c82389cdefee8c20208'
  56. 'e0eaec8ddd24bbebf4956563ebc6d7a56f8dada5835975ee4d320dd3d0c9c442'
  57. 'c7f867ccee684939c9f0a9c30ea69127077bbe43af545a03f09dfbbdc02545a9')
  58. sha256sums+=('3edb4add450f94c579f2df7c16ac4d9bd9f5c6acf3fbd8a05ce24c21c317257d'
  59. '28029afa3201e1be8138be06f741c59d64869edf0c9e90dbb05cfa6b5fff4ecd')
  60. sha256sums_i686=('068efe37a99561490e6ec7b70a3cd4dd84e89e6bdf19f04a475d06c78fd28920')
  61. validpgpkeys=('318C679D94F17700CC847DE646A70073E4E50D4E') # Ruben Rodriguez
  62. validpgpkeys+=('3954A7AB837D0EA9CFA9798925DB7D9B5A8D4B40') # bill-auger (VCS builds)
  63. # PGO requires networking
  64. _should_skip_pgo_armv7h=1 # disable for armv7h - always
  65. _should_skip_pgo_i686=1 # disable for i686 - always
  66. _should_skip_pgo_x86_64=0 # disable for x86_64 - libremakepkg
  67. eval "_should_skip_pgo=\$_should_skip_pgo_${CARCH}"
  68. _check_build_config() {
  69. pushd "${srcdir}"/${pkgname}-${pkgver%_*} > /dev/null
  70. echo "Checking build configuration..."
  71. # Configure produces mozinfo.json that reflects current configuration.
  72. # See build/docs/mozinfo.rst
  73. ./mach configure
  74. # In this test, jq collects values of the following keys of mozinfo.json into array,
  75. # and checks if any of them are not equal to false, in which case it returns "true".
  76. # E.g. if the value of any key is true or null (in case the key is missing from mozinfo.json),
  77. # that means the build configuration has to be reworked.
  78. local obj_directory=$(./mach environment | sed -En '/object directory:/{n;s/^\s+//;p;}')
  79. local mozinfo_json="${obj_directory}"/mozinfo.json
  80. local antifeature_keys=('.crashreporter' '.datareporting' '.healthreport' '.normandy' '.telemetry' '.updater')
  81. local antifeatures=()
  82. local jq_cmd=( jq -e "${key} != false" "${mozinfo_json}" )
  83. printf "\$mozinfo_json %s - obj_directory is: %s\n" \
  84. "$( [[ -f "${mozinfo_json}" ]] || printf "not " )found" \
  85. "${obj_directory}"
  86. for key in ${antifeature_keys[@]} ; do ${jq_cmd[@]} && antifeatures+=(${key}); done ;
  87. if (( ${#antifeatures[@]} ))
  88. then echo "Some anti-features are not disabled in build configuration files, aborting:"
  89. for key in ${antifeature_keys[@]}
  90. do echo "${key} - $( ${jq_cmd[@]} || echo "not " )detected\n"
  91. done
  92. # return 1 # FIXME: .datareporting is detected
  93. fi
  94. popd > /dev/null
  95. }
  96. prepare() {
  97. mkdir -p mozbuild
  98. cd "$srcdir/$pkgname-${pkgver%_*}"
  99. # https://bugzilla.mozilla.org/show_bug.cgi?id=1530052
  100. patch -Np1 -i ../0001-Use-remoting-name-for-GDK-application-names.patch
  101. # https://bugzilla.mozilla.org/show_bug.cgi?id=1667736
  102. patch -Np1 -i ../rust_1.48.patch
  103. cat >../mozconfig <<END
  104. ac_add_options --enable-application=browser
  105. ac_add_options --prefix=/usr
  106. ac_add_options --enable-release
  107. ac_add_options --enable-hardening
  108. ac_add_options --enable-optimize
  109. ac_add_options --enable-rust-simd
  110. export CC='clang --target=x86_64-unknown-linux-gnu'
  111. export CXX='clang++ --target=x86_64-unknown-linux-gnu'
  112. export AR=llvm-ar
  113. export NM=llvm-nm
  114. export RANLIB=llvm-ranlib
  115. # Branding
  116. ac_add_options --enable-official-branding
  117. ac_add_options --enable-update-channel=release
  118. ac_add_options --with-distribution-id=nu.parabola
  119. ac_add_options --with-unsigned-addon-scopes=app,system
  120. ac_add_options --allow-addon-sideload
  121. export MOZ_APP_NAME=${pkgname}
  122. export MOZ_APP_REMOTINGNAME=${pkgname}
  123. export MOZ_TELEMETRY_REPORTING=
  124. export MOZ_REQUIRE_SIGNING=
  125. ac_add_options --with-app-basename=${pkgname}
  126. ac_add_options --with-app-name=${pkgname}
  127. # System libraries
  128. ac_add_options --with-system-nspr
  129. ac_add_options --with-system-nss
  130. # Features
  131. ac_add_options --enable-alsa
  132. ac_add_options --enable-jack
  133. ac_add_options --disable-crashreporter
  134. ac_add_options --disable-updater
  135. ac_add_options --disable-tests
  136. ac_add_options --disable-eme
  137. END
  138. ## [ARCH-SPECIFIC CONFIG] ##
  139. case "${CARCH}" in
  140. armv7h)
  141. # TODO: re-work for armv7h
  142. # sed -i '/--enable-linker=gold/d' ../mozconfig
  143. # sed -i '/--enable-rust-simd/d' ../mozconfig
  144. #
  145. # # https://bugzilla.mozilla.org/show_bug.cgi?id=1463035
  146. # patch -Np1 -i "$srcdir"/mozilla-1463035.patch
  147. #
  148. # cat >> ../mozconfig <<END
  149. #ac_add_options --enable-optimize="-g -O2 -fno-schedule-insns"
  150. #ac_add_options --disable-elf-hack
  151. #ac_add_options --disable-webrtc
  152. #ac_add_options --disable-av1
  153. #END
  154. ;;
  155. i686)
  156. # sed -i '/--enable-linker=gold/d' ../mozconfig
  157. sed -i '/--enable-rust-simd/d' ../mozconfig
  158. # test failure in rust code (complaining about network functions) when PGO is used,
  159. # TEST-UNEXPECTED-FAIL | check_networking | libgkrust.a | Identified 7 networking function(s) being imported in the rust static library (accept,connect,getsockname,getsockopt,listen,recv,send)
  160. # see https://bugzilla.mozilla.org/show_bug.cgi?id=1565757
  161. echo "applying rust-static-disable-network-test-on-static-libraries.patch"
  162. patch -Np0 -i ../rust-static-disable-network-test-on-static-libraries.patch
  163. ;;
  164. x86_64)
  165. ;;
  166. *) echo "no [ARCH-SPECIFIC CONFIG] for arch: ${CARCH}" ; return 1 ;
  167. ;;
  168. esac
  169. ## searchengines ##
  170. pushd browser/components/search/extensions > /dev/null
  171. # Patch search-engines configs
  172. cp "${srcdir}"/searchplugins_list.json list.json
  173. sed -i 's|https://duckduckgo.com/|https://html.duckduckgo.com/html/|' ddg/manifest.json
  174. # Removing URL parameters that let DuckDuckGo know the place in UI
  175. # the search was ran from (like address bar, context menu, etc.)
  176. local jq_cmd='del(.chrome_settings_overrides.search_provider.params)'
  177. jq "${jq_cmd}" ddg/manifest.json > manifest.json.tmp
  178. ! diff manifest.json.tmp ddg/manifest.json > /dev/null
  179. mv manifest.json.tmp ddg/manifest.json
  180. # Delete unused search engine configs
  181. cp -rv /usr/share/mozilla/searchplugins/* .
  182. find -mindepth 1 -maxdepth 1 \
  183. -not -name ddg \
  184. -not -name duckduckgo-html \
  185. -not -name duckduckgo-lite \
  186. -not -name internet-archive \
  187. -not -name parabola-labs \
  188. -not -name parabola-packages \
  189. -not -name parabola-wiki \
  190. -not -name searx \
  191. -not -name wikipedia \
  192. -not -name yacy \
  193. -not -name list.json \
  194. -exec rm -rf {} \;
  195. # Sanity-check search-engines patching
  196. local engines_err_msg="search-engines patching needs re-working"
  197. jq < list.json || ! echo "${engines_err_msg}"
  198. popd > /dev/null
  199. ## libre patching ##
  200. # Remove remaining non-free bits
  201. echo "applying 9003-misc-libre.patch"
  202. patch -Np1 --no-backup-if-mismatch -i "${srcdir}"/9003-misc-libre.patch
  203. }
  204. build() {
  205. cd "$srcdir/$pkgname-${pkgver%_*}"
  206. ## build env ##
  207. export MOZ_NOSPAM=1
  208. export MOZBUILD_STATE_PATH="$srcdir/mozbuild"
  209. export MACH_USE_SYSTEM_PYTHON=1
  210. # LTO needs more open files
  211. ulimit -n 4096
  212. # clang-{9,10,11} -> error: unknown argument: '-fvar-tracking-assignments'
  213. CFLAGS="${CFLAGS/-fvar-tracking-assignments/}"
  214. CXXFLAGS="${CXXFLAGS/-fvar-tracking-assignments/}"
  215. ## [ARCH-SPECIFIC BUILD ENV] ##
  216. case "${CARCH}" in
  217. armv7h)
  218. # TODO: re-work for armv7h
  219. # export RUSTFLAGS+=" -Cdebuginfo=0 -Clto=off"
  220. # export LDFLAGS+=" -Wl,--no-keep-memory -Wl,--reduce-memory-overheads"
  221. ;;
  222. i686)
  223. # -fno-plt with cross-LTO -> LLVM ERROR: Function Import: link error
  224. CFLAGS="${CFLAGS/-fno-plt/}"
  225. CXXFLAGS="${CXXFLAGS/-fno-plt/}"
  226. # disable LTO (clang has issues on IA32)
  227. export RUSTFLAGS+=" -Cdebuginfo=0 -Clto=off"
  228. export LDFLAGS+=" -Wl,--no-keep-memory -Wl,--reduce-memory-overheads"
  229. ;;
  230. x86_64)
  231. ;;
  232. *) echo "no [ARCH-SPECIFIC BUILD ENV] for arch: ${CARCH}" ; return 1 ;
  233. ;;
  234. esac
  235. export CFLAGS
  236. export CXXFLAGS
  237. ## [ARCH-SPECIFIC BUILD CONFIG] ##
  238. case ${CARCH} in
  239. armv7h)
  240. # TODO: re-work for armv7h
  241. ;;
  242. i686)
  243. # avoid excessive debug symbols in rust leading to out-of-memory situations
  244. sed -i "s/debug_info = '\''2'\''/debug_info = '\''0'\''/" build/moz.configure/toolchain.configure
  245. ;;
  246. x86_64)
  247. ;;
  248. *) echo "no [ARCH-SPECIFIC BUILD CONFIG] for arch: ${CARCH}" ; return 1 ;
  249. ;;
  250. esac
  251. ## PGO build ##
  252. if (( $_should_skip_pgo ))
  253. then
  254. # skipping "3-tier PGO" "instrumented browser", to avoid OOM problems;
  255. # so we have the final .mozconfig now
  256. cp ../mozconfig .mozconfig
  257. else
  258. # Do 3-tier PGO
  259. echo "Building instrumented browser..."
  260. cat >.mozconfig ../mozconfig - <<END
  261. ac_add_options --enable-profile-generate=cross
  262. END
  263. _check_build_config
  264. ./mach build
  265. echo "Profiling instrumented browser..."
  266. ./mach package
  267. LLVM_PROFDATA=llvm-profdata \
  268. JARLOG_FILE="$PWD/jarlog" \
  269. xvfb-run -s "-screen 0 1920x1080x24 -nolisten local" \
  270. ./mach python build/pgo/profileserver.py
  271. if [[ ! -s merged.profdata ]]; then
  272. echo "No profile data produced."
  273. return 1
  274. fi
  275. if [[ ! -s jarlog ]]; then
  276. echo "No jar log produced."
  277. return 1
  278. fi
  279. echo "Removing instrumented browser..."
  280. ./mach clobber
  281. cat >.mozconfig ../mozconfig - <<END
  282. ac_add_options --enable-lto=cross
  283. ac_add_options --enable-profile-use=cross
  284. ac_add_options --with-pgo-profile-path=${PWD@Q}/merged.profdata
  285. ac_add_options --with-pgo-jarlog=${PWD@Q}/jarlog
  286. END
  287. fi # $_should_skip_pgo
  288. ## sanity checks ##
  289. # each of the [ARCH-SPECIFIC BUILD CONFIG] branches above should have created .mozconfig
  290. [[ ! -f .mozconfig ]] && echo ".mozconfig file not found in source root" && return 1
  291. _check_build_config
  292. ## main build ##
  293. echo "Building optimized browser..."
  294. ./mach build
  295. }
  296. package() {
  297. cd "$srcdir/$pkgname-${pkgver%_*}"
  298. DESTDIR="$pkgdir" ./mach install
  299. local vendorjs="$pkgdir/usr/lib/$pkgname/browser/defaults/preferences/vendor.js"
  300. install -Dvm644 /dev/stdin "$vendorjs" <<END
  301. // Use LANG environment variable to choose locale
  302. pref("intl.locale.requested", "");
  303. // Use system-provided dictionaries
  304. pref("spellchecker.dictionary_path", "/usr/share/hunspell");
  305. // Disable default browser checking.
  306. pref("browser.shell.checkDefaultBrowser", false);
  307. // Don't disable extensions in the application directory
  308. pref("extensions.autoDisableScopes", 11);
  309. END
  310. local distini="$pkgdir/usr/lib/$pkgname/distribution/distribution.ini"
  311. install -Dvm644 /dev/stdin "$distini" <<END
  312. [Global]
  313. id=parabola
  314. version=1.0
  315. about=Icecat for Parabola GNU/Linux-libre
  316. [Preferences]
  317. app.distributor=parabola
  318. app.distributor.channel=$pkgname
  319. app.partner.parabola=parabola
  320. END
  321. install -m755 -d ${pkgdir}/usr/share/applications
  322. install -m755 -d ${pkgdir}/usr/share/pixmaps
  323. local i
  324. for i in 16 32 48; do
  325. install -Dm644 browser/branding/official/default${i}.png \
  326. "$pkgdir/usr/share/icons/hicolor/${i}x${i}/apps/${pkgname}.png"
  327. done
  328. install -Dm644 browser/branding/official/default48.png "${pkgdir}"/usr/share/pixmaps/icecat.png
  329. install -Dm644 "${srcdir}"/icecat.desktop "${pkgdir}"/usr/share/applications/
  330. install -Dm644 "${srcdir}"/icecat-safe.desktop "${pkgdir}"/usr/share/applications/
  331. # Install a wrapper to avoid confusion about binary path
  332. install -Dvm755 /dev/stdin "$pkgdir/usr/bin/$pkgname" <<END
  333. #!/bin/sh
  334. exec /usr/lib/$pkgname/$pkgname "\$@"
  335. END
  336. ## [ARCH-SPECIFIC INSTALL] ##
  337. case ${CARCH} in
  338. armv7h)
  339. # TODO: re-work for armv7h
  340. ;;
  341. i686)
  342. ;;
  343. x86_64)
  344. ;;
  345. *) echo "no [ARCH-SPECIFIC INSTALL] for arch: ${CARCH}" ; return 1 ;
  346. ;;
  347. esac
  348. # Replace duplicate binary with wrapper
  349. # https://bugzilla.mozilla.org/show_bug.cgi?id=658850
  350. ln -srfv "$pkgdir/usr/bin/$pkgname" "$pkgdir/usr/lib/$pkgname/$pkgname-bin"
  351. # Use system certificates
  352. local nssckbi="$pkgdir/usr/lib/$pkgname/libnssckbi.so"
  353. if [[ -e $nssckbi ]]; then
  354. ln -srfv "$pkgdir/usr/lib/libnssckbi.so" "$nssckbi"
  355. fi
  356. }