db-move: moved firefox from [testing] to [extra] (x86_64)
[arch-packages.git] / firefox / trunk / PKGBUILD
bloba6bbb941c6d44fc366668afaefc4e2255a0f26b2
1 # Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
2 # Contributor: Ionut Biru <ibiru@archlinux.org>
3 # Contributor: Jakub Schmidtke <sjakub@gmail.com>
5 pkgname=firefox
6 pkgver=113.0
7 pkgrel=1
8 pkgdesc="Standalone web browser from mozilla.org"
9 url="https://www.mozilla.org/firefox/"
10 arch=(x86_64)
11 license=(
12   GPL
13   LGPL
14   MPL
16 depends=(
17   dbus-glib
18   ffmpeg
19   gtk3
20   libpulse
21   libxt
22   mime-types
23   nss
24   ttf-font
26 makedepends=(
27   cbindgen
28   clang
29   diffutils
30   dump_syms
31   imake
32   inetutils
33   jack
34   lld
35   llvm
36   mesa
37   nasm
38   nodejs
39   python
40   rust
41   unzip
42   wasi-compiler-rt
43   wasi-libc
44   wasi-libc++
45   wasi-libc++abi
46   xorg-server-xvfb
47   yasm
48   zip
50 optdepends=(
51   'hunspell-en_US: Spell checking, American English'
52   'libnotify: Notification integration'
53   'networkmanager: Location detection via available WiFi networks'
54   'pulseaudio: Audio support'
55   'speech-dispatcher: Text-to-Speech'
56   'xdg-desktop-portal: Screensharing with Wayland'
58 options=(
59   !debug
60   !emptydirs
61   !lto
62   !makeflags
63   !strip
65 source=(
66   https://archive.mozilla.org/pub/firefox/releases/$pkgver/source/firefox-$pkgver.source.tar.xz{,.asc}
67   $pkgname.desktop
68   identity-icons-brand.svg
69   0001-Bug-1831691-Use-the-vendored-glean_parser-for-all-of.patch
71 validpgpkeys=(
72   '14F26682D0916CDD81E37B6D61B7B526D98F0353'  # Mozilla Software Releases <release@mozilla.com>
74 sha256sums=('7a266044cb9d0c63079b3453507ea0c80a23389f4cbf6a4f6fd15146c6072627'
75             'SKIP'
76             '298eae9de76ec53182f38d5c549d0379569916eebf62149f9d7f4a7edef36abf'
77             'a9b8b4a0a1f4a7b4af77d5fc70c2686d624038909263c795ecc81e0aec7711e9'
78             '1976c0c5e98b0f67e83de778a4fd7729de9b140efa47b77b5879ea2e907987e9')
79 b2sums=('1506901352ea84b8016080aa81a0f431b8620c64c0c54364ec56d1878b6413ad965c2d9f39a9bb06d2356c206702283400918b4fb0fa3dac380360f54e60b146'
80         'SKIP'
81         'e18f2c22e394ca3b6758bc130245b254947e4d15921be3da443d6d7c3c4b0d22ead1b39fbc10a4f896edd19e2a1dffbd1cbb34dc4beb0621a6ddb70ccc53b3a7'
82         '63a8dd9d8910f9efb353bed452d8b4b2a2da435857ccee083fc0c557f8c4c1339ca593b463db320f70387a1b63f1a79e709e9d12c69520993e26d85a3d742e34'
83         '4ac97b908afb915911212686e41c09137bfa909023dc6fa0808cb6cb12f2dcef9597f0d679c98ad1a6b110d11a92025435cd30dd7b87194428b693c555e2bae7')
85 # Google API keys (see http://www.chromium.org/developers/how-tos/api-keys)
86 # Note: These are for Arch Linux use ONLY. For your own distribution, please
87 # get your own set of keys. Feel free to contact foutrelis@archlinux.org for
88 # more information.
89 _google_api_key=AIzaSyDwr302FpOSkGRpLlUpPThNTDPbXcIn_FM
91 # Mozilla API keys (see https://location.services.mozilla.com/api)
92 # Note: These are for Arch Linux use ONLY. For your own distribution, please
93 # get your own set of keys. Feel free to contact heftig@archlinux.org for
94 # more information.
95 _mozilla_api_key=e05d56db0a694edc8b5aaebda3f2db6a
97 prepare() {
98   mkdir mozbuild
99   cd firefox-$pkgver
101   # https://bugzilla.mozilla.org/show_bug.cgi?id=1831691
102   patch -Np1 -i ../0001-Bug-1831691-Use-the-vendored-glean_parser-for-all-of.patch
104   echo -n "$_google_api_key" >google-api-key
105   echo -n "$_mozilla_api_key" >mozilla-api-key
107   cat >../mozconfig <<END
108 ac_add_options --enable-application=browser
109 mk_add_options MOZ_OBJDIR=${PWD@Q}/obj
111 ac_add_options --prefix=/usr
112 ac_add_options --enable-release
113 ac_add_options --enable-hardening
114 ac_add_options --enable-optimize
115 ac_add_options --enable-rust-simd
116 ac_add_options --enable-linker=lld
117 ac_add_options --disable-elf-hack
118 ac_add_options --disable-bootstrap
119 ac_add_options --with-wasi-sysroot=/usr/share/wasi-sysroot
121 # Branding
122 ac_add_options --enable-official-branding
123 ac_add_options --enable-update-channel=release
124 ac_add_options --with-distribution-id=org.archlinux
125 ac_add_options --with-unsigned-addon-scopes=app,system
126 ac_add_options --allow-addon-sideload
127 export MOZILLA_OFFICIAL=1
128 export MOZ_APP_REMOTINGNAME=${pkgname//-/}
130 # Keys
131 ac_add_options --with-google-location-service-api-keyfile=${PWD@Q}/google-api-key
132 ac_add_options --with-google-safebrowsing-api-keyfile=${PWD@Q}/google-api-key
133 ac_add_options --with-mozilla-api-keyfile=${PWD@Q}/mozilla-api-key
135 # System libraries
136 ac_add_options --with-system-nspr
137 ac_add_options --with-system-nss
139 # Features
140 ac_add_options --enable-alsa
141 ac_add_options --enable-jack
142 ac_add_options --enable-crashreporter
143 ac_add_options --disable-updater
144 ac_add_options --disable-tests
148 build() {
149   cd firefox-$pkgver
151   export MOZ_NOSPAM=1
152   export MOZBUILD_STATE_PATH="$srcdir/mozbuild"
153   export MOZ_ENABLE_FULL_SYMBOLS=1
154   export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=pip
156   # LTO needs more open files
157   ulimit -n 4096
159   # Do 3-tier PGO
160   echo "Building instrumented browser..."
161   cat >.mozconfig ../mozconfig - <<END
162 ac_add_options --enable-profile-generate=cross
164   ./mach build
166   echo "Profiling instrumented browser..."
167   ./mach package
168   LLVM_PROFDATA=llvm-profdata \
169     JARLOG_FILE="$PWD/jarlog" \
170     xvfb-run -s "-screen 0 1920x1080x24 -nolisten local" \
171     ./mach python build/pgo/profileserver.py
173   stat -c "Profile data found (%s bytes)" merged.profdata
174   test -s merged.profdata
176   stat -c "Jar log found (%s bytes)" jarlog
177   test -s jarlog
179   echo "Removing instrumented browser..."
180   ./mach clobber
182   echo "Building optimized browser..."
183   cat >.mozconfig ../mozconfig - <<END
184 ac_add_options --enable-lto=cross
185 ac_add_options --enable-profile-use=cross
186 ac_add_options --with-pgo-profile-path=${PWD@Q}/merged.profdata
187 ac_add_options --with-pgo-jarlog=${PWD@Q}/jarlog
189   ./mach build
191   echo "Building symbol archive..."
192   ./mach buildsymbols
195 package() {
196   cd firefox-$pkgver
197   DESTDIR="$pkgdir" ./mach install
199   local vendorjs="$pkgdir/usr/lib/$pkgname/browser/defaults/preferences/vendor.js"
200   install -Dvm644 /dev/stdin "$vendorjs" <<END
201 // Use LANG environment variable to choose locale
202 pref("intl.locale.requested", "");
204 // Use system-provided dictionaries
205 pref("spellchecker.dictionary_path", "/usr/share/hunspell");
207 // Disable default browser checking.
208 pref("browser.shell.checkDefaultBrowser", false);
210 // Don't disable extensions in the application directory
211 pref("extensions.autoDisableScopes", 11);
214   local distini="$pkgdir/usr/lib/$pkgname/distribution/distribution.ini"
215   install -Dvm644 /dev/stdin "$distini" <<END
216 [Global]
217 id=archlinux
218 version=1.0
219 about=Mozilla Firefox for Arch Linux
221 [Preferences]
222 app.distributor=archlinux
223 app.distributor.channel=$pkgname
224 app.partner.archlinux=archlinux
227   local i theme=official
228   for i in 16 22 24 32 48 64 128 256; do
229     install -Dvm644 browser/branding/$theme/default$i.png \
230       "$pkgdir/usr/share/icons/hicolor/${i}x${i}/apps/$pkgname.png"
231   done
232   install -Dvm644 browser/branding/$theme/content/about-logo.png \
233     "$pkgdir/usr/share/icons/hicolor/192x192/apps/$pkgname.png"
234   install -Dvm644 browser/branding/$theme/content/about-logo@2x.png \
235     "$pkgdir/usr/share/icons/hicolor/384x384/apps/$pkgname.png"
236   install -Dvm644 browser/branding/$theme/content/about-logo.svg \
237     "$pkgdir/usr/share/icons/hicolor/scalable/apps/$pkgname.svg"
238   install -Dvm644 ../identity-icons-brand.svg \
239     "$pkgdir/usr/share/icons/hicolor/symbolic/apps/$pkgname-symbolic.svg"
241   install -Dvm644 ../$pkgname.desktop \
242     "$pkgdir/usr/share/applications/$pkgname.desktop"
244   # Install a wrapper to avoid confusion about binary path
245   install -Dvm755 /dev/stdin "$pkgdir/usr/bin/$pkgname" <<END
246 #!/bin/sh
247 exec /usr/lib/$pkgname/firefox "\$@"
250   # Replace duplicate binary with wrapper
251   # https://bugzilla.mozilla.org/show_bug.cgi?id=658850
252   ln -srfv "$pkgdir/usr/bin/$pkgname" "$pkgdir/usr/lib/$pkgname/firefox-bin"
254   # Use system certificates
255   local nssckbi="$pkgdir/usr/lib/$pkgname/libnssckbi.so"
256   if [[ -e $nssckbi ]]; then
257     ln -srfv "$pkgdir/usr/lib/libnssckbi.so" "$nssckbi"
258   fi
260   export SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE="$startdir/.crash-stats-api.token"
261   if [[ -f $SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE ]]; then
262     make -C obj uploadsymbols
263   else
264     cp -fvt "$startdir" obj/dist/*crashreporter-symbols-full.tar.zst
265   fi
268 # vim:set sw=2 sts=-1 et: