archrelease: copy trunk to extra-x86_64
[arch-packages.git] / firefox / trunk / PKGBUILD
blobd61aee385e0922322adb6c91ebeb96166652658d
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=95.0
7 pkgrel=1
8 pkgdesc="Standalone web browser from mozilla.org"
9 arch=(x86_64)
10 license=(MPL GPL LGPL)
11 url="https://www.mozilla.org/firefox/"
12 depends=(gtk3 libxt mime-types dbus-glib ffmpeg nss ttf-font libpulse)
13 makedepends=(unzip zip diffutils yasm mesa imake inetutils xorg-server-xvfb
14              autoconf2.13 rust clang llvm jack nodejs cbindgen nasm
15              python-setuptools python-psutil python-zstandard lld dump_syms
16              wasi-compiler-rt wasi-libc wasi-libc++ wasi-libc++abi)
17 optdepends=('networkmanager: Location detection via available WiFi networks'
18             'libnotify: Notification integration'
19             'pulseaudio: Audio support'
20             'speech-dispatcher: Text-to-Speech'
21             'hunspell-en_US: Spell checking, American English'
22             'xdg-desktop-portal: Screensharing with Wayland')
23 options=(!emptydirs !makeflags !strip)
24 source=(https://archive.mozilla.org/pub/firefox/releases/$pkgver/source/firefox-$pkgver.source.tar.xz{,.asc}
25         0001-Use-remoting-name-for-GDK-application-names.patch
26         $pkgname.desktop identity-icons-brand.svg)
27 sha256sums=('7fa3e43f6ec710b2ebba0e99db713a56d13d85f1f23c4a1399bb594fd74864de'
28             'SKIP'
29             'a7a5ea4680c0a4c6eb5a5f99970008f5ad3e2f29f0d6d050aa651bce8c713718'
30             '298eae9de76ec53182f38d5c549d0379569916eebf62149f9d7f4a7edef36abf'
31             'a9b8b4a0a1f4a7b4af77d5fc70c2686d624038909263c795ecc81e0aec7711e9')
32 validpgpkeys=('14F26682D0916CDD81E37B6D61B7B526D98F0353') # Mozilla Software Releases <release@mozilla.com>
34 # Google API keys (see http://www.chromium.org/developers/how-tos/api-keys)
35 # Note: These are for Arch Linux use ONLY. For your own distribution, please
36 # get your own set of keys. Feel free to contact foutrelis@archlinux.org for
37 # more information.
38 _google_api_key=AIzaSyDwr302FpOSkGRpLlUpPThNTDPbXcIn_FM
40 # Mozilla API keys (see https://location.services.mozilla.com/api)
41 # Note: These are for Arch Linux use ONLY. For your own distribution, please
42 # get your own set of keys. Feel free to contact heftig@archlinux.org for
43 # more information.
44 _mozilla_api_key=e05d56db0a694edc8b5aaebda3f2db6a
46 prepare() {
47   mkdir mozbuild
48   cd firefox-$pkgver
50   # https://bugzilla.mozilla.org/show_bug.cgi?id=1530052
51   patch -Np1 -i ../0001-Use-remoting-name-for-GDK-application-names.patch
53   echo -n "$_google_api_key" >google-api-key
54   echo -n "$_mozilla_api_key" >mozilla-api-key
56   cat >../mozconfig <<END
57 ac_add_options --enable-application=browser
58 mk_add_options MOZ_OBJDIR=${PWD@Q}/obj
60 ac_add_options --prefix=/usr
61 ac_add_options --enable-release
62 ac_add_options --enable-hardening
63 ac_add_options --enable-optimize
64 ac_add_options --enable-rust-simd
65 ac_add_options --enable-linker=lld
66 ac_add_options --disable-elf-hack
67 ac_add_options --disable-bootstrap
68 ac_add_options --with-wasi-sysroot=/usr/share/wasi-sysroot
70 # Branding
71 ac_add_options --enable-official-branding
72 ac_add_options --enable-update-channel=release
73 ac_add_options --with-distribution-id=org.archlinux
74 ac_add_options --with-unsigned-addon-scopes=app,system
75 ac_add_options --allow-addon-sideload
76 export MOZILLA_OFFICIAL=1
77 export MOZ_APP_REMOTINGNAME=${pkgname//-/}
79 # Keys
80 ac_add_options --with-google-location-service-api-keyfile=${PWD@Q}/google-api-key
81 ac_add_options --with-google-safebrowsing-api-keyfile=${PWD@Q}/google-api-key
82 ac_add_options --with-mozilla-api-keyfile=${PWD@Q}/mozilla-api-key
84 # System libraries
85 ac_add_options --with-system-nspr
86 ac_add_options --with-system-nss
88 # Features
89 ac_add_options --enable-alsa
90 ac_add_options --enable-jack
91 ac_add_options --enable-crashreporter
92 ac_add_options --disable-updater
93 ac_add_options --disable-tests
94 END
97 build() {
98   cd firefox-$pkgver
100   export MOZ_NOSPAM=1
101   export MOZBUILD_STATE_PATH="$srcdir/mozbuild"
102   export MOZ_ENABLE_FULL_SYMBOLS=1
103   export MACH_USE_SYSTEM_PYTHON=1
105   # LTO needs more open files
106   ulimit -n 4096
108   # Do 3-tier PGO
109   echo "Building instrumented browser..."
110   cat >.mozconfig ../mozconfig - <<END
111 ac_add_options --enable-profile-generate=cross
113   ./mach build
115   echo "Profiling instrumented browser..."
116   ./mach package
117   LLVM_PROFDATA=llvm-profdata \
118     JARLOG_FILE="$PWD/jarlog" \
119     xvfb-run -s "-screen 0 1920x1080x24 -nolisten local" \
120     ./mach python build/pgo/profileserver.py
122   stat -c "Profile data found (%s bytes)" merged.profdata
123   test -s merged.profdata
125   stat -c "Jar log found (%s bytes)" jarlog
126   test -s jarlog
128   echo "Removing instrumented browser..."
129   ./mach clobber
131   echo "Building optimized browser..."
132   cat >.mozconfig ../mozconfig - <<END
133 ac_add_options --enable-lto=cross
134 ac_add_options --enable-profile-use=cross
135 ac_add_options --with-pgo-profile-path=${PWD@Q}/merged.profdata
136 ac_add_options --with-pgo-jarlog=${PWD@Q}/jarlog
138   ./mach build
140   echo "Building symbol archive..."
141   ./mach buildsymbols
144 package() {
145   cd firefox-$pkgver
146   DESTDIR="$pkgdir" ./mach install
148   local vendorjs="$pkgdir/usr/lib/$pkgname/browser/defaults/preferences/vendor.js"
149   install -Dvm644 /dev/stdin "$vendorjs" <<END
150 // Use LANG environment variable to choose locale
151 pref("intl.locale.requested", "");
153 // Use system-provided dictionaries
154 pref("spellchecker.dictionary_path", "/usr/share/hunspell");
156 // Disable default browser checking.
157 pref("browser.shell.checkDefaultBrowser", false);
159 // Don't disable extensions in the application directory
160 pref("extensions.autoDisableScopes", 11);
163   local distini="$pkgdir/usr/lib/$pkgname/distribution/distribution.ini"
164   install -Dvm644 /dev/stdin "$distini" <<END
165 [Global]
166 id=archlinux
167 version=1.0
168 about=Mozilla Firefox for Arch Linux
170 [Preferences]
171 app.distributor=archlinux
172 app.distributor.channel=$pkgname
173 app.partner.archlinux=archlinux
176   local i theme=official
177   for i in 16 22 24 32 48 64 128 256; do
178     install -Dvm644 browser/branding/$theme/default$i.png \
179       "$pkgdir/usr/share/icons/hicolor/${i}x${i}/apps/$pkgname.png"
180   done
181   install -Dvm644 browser/branding/$theme/content/about-logo.png \
182     "$pkgdir/usr/share/icons/hicolor/192x192/apps/$pkgname.png"
183   install -Dvm644 browser/branding/$theme/content/about-logo@2x.png \
184     "$pkgdir/usr/share/icons/hicolor/384x384/apps/$pkgname.png"
185   install -Dvm644 browser/branding/$theme/content/about-logo.svg \
186     "$pkgdir/usr/share/icons/hicolor/scalable/apps/$pkgname.svg"
187   install -Dvm644 ../identity-icons-brand.svg \
188     "$pkgdir/usr/share/icons/hicolor/symbolic/apps/$pkgname-symbolic.svg"
190   install -Dvm644 ../$pkgname.desktop \
191     "$pkgdir/usr/share/applications/$pkgname.desktop"
193   # Install a wrapper to avoid confusion about binary path
194   install -Dvm755 /dev/stdin "$pkgdir/usr/bin/$pkgname" <<END
195 #!/bin/sh
196 exec /usr/lib/$pkgname/firefox "\$@"
199   # Replace duplicate binary with wrapper
200   # https://bugzilla.mozilla.org/show_bug.cgi?id=658850
201   ln -srfv "$pkgdir/usr/bin/$pkgname" "$pkgdir/usr/lib/$pkgname/firefox-bin"
203   # Use system certificates
204   local nssckbi="$pkgdir/usr/lib/$pkgname/libnssckbi.so"
205   if [[ -e $nssckbi ]]; then
206     ln -srfv "$pkgdir/usr/lib/libnssckbi.so" "$nssckbi"
207   fi
209   export SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE="$startdir/.crash-stats-api.token"
210   if [[ -f $SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE ]]; then
211     make -C obj uploadsymbols
212   else
213     cp -fvt "$startdir" obj/dist/*crashreporter-symbols-full.tar.zst
214   fi
217 # vim:set sw=2 et: