archrelease: copy trunk to extra-x86_64
[arch-packages.git] / firefox / trunk / PKGBUILD
blobcc367401b0541e337242d15b9cfeffbcaf399fe4
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=103.0.2
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-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 !lto !debug)
24 source=(https://archive.mozilla.org/pub/firefox/releases/$pkgver/source/firefox-$pkgver.source.tar.xz{,.asc}
25         zstandard-0.18.0.diff arc4random.diff
26         $pkgname.desktop identity-icons-brand.svg)
27 sha256sums=('766183e8e39c17a84305a85da3237919ffaeb018c6c9d97a7324aea51bd453aa'
28             'SKIP'
29             'a6857ad2f2e2091c6c4fdcde21a59fbeb0138914c0e126df64b50a5af5ff63be'
30             '714ca50b2ce0cac470dbd5a60e9a0101b28072f08a5e7a9bba94fef2058321c4'
31             '298eae9de76ec53182f38d5c549d0379569916eebf62149f9d7f4a7edef36abf'
32             'a9b8b4a0a1f4a7b4af77d5fc70c2686d624038909263c795ecc81e0aec7711e9')
33 validpgpkeys=('14F26682D0916CDD81E37B6D61B7B526D98F0353') # Mozilla Software Releases <release@mozilla.com>
35 # Google API keys (see http://www.chromium.org/developers/how-tos/api-keys)
36 # Note: These are for Arch Linux use ONLY. For your own distribution, please
37 # get your own set of keys. Feel free to contact foutrelis@archlinux.org for
38 # more information.
39 _google_api_key=AIzaSyDwr302FpOSkGRpLlUpPThNTDPbXcIn_FM
41 # Mozilla API keys (see https://location.services.mozilla.com/api)
42 # Note: These are for Arch Linux use ONLY. For your own distribution, please
43 # get your own set of keys. Feel free to contact heftig@archlinux.org for
44 # more information.
45 _mozilla_api_key=e05d56db0a694edc8b5aaebda3f2db6a
47 prepare() {
48   mkdir mozbuild
49   cd firefox-$pkgver
51   # Unbreak build with python-zstandard 0.18.0
52   patch -Np1 -i ../zstandard-0.18.0.diff
54   # Unbreak build with glibc 2.36
55   patch -Np1 -i ../arc4random.diff
57   echo -n "$_google_api_key" >google-api-key
58   echo -n "$_mozilla_api_key" >mozilla-api-key
60   cat >../mozconfig <<END
61 ac_add_options --enable-application=browser
62 mk_add_options MOZ_OBJDIR=${PWD@Q}/obj
64 ac_add_options --prefix=/usr
65 ac_add_options --enable-release
66 ac_add_options --enable-hardening
67 ac_add_options --enable-optimize
68 ac_add_options --enable-rust-simd
69 ac_add_options --enable-linker=lld
70 ac_add_options --disable-elf-hack
71 ac_add_options --disable-bootstrap
72 ac_add_options --with-wasi-sysroot=/usr/share/wasi-sysroot
74 # Branding
75 ac_add_options --enable-official-branding
76 ac_add_options --enable-update-channel=release
77 ac_add_options --with-distribution-id=org.archlinux
78 ac_add_options --with-unsigned-addon-scopes=app,system
79 ac_add_options --allow-addon-sideload
80 export MOZILLA_OFFICIAL=1
81 export MOZ_APP_REMOTINGNAME=${pkgname//-/}
83 # Keys
84 ac_add_options --with-google-location-service-api-keyfile=${PWD@Q}/google-api-key
85 ac_add_options --with-google-safebrowsing-api-keyfile=${PWD@Q}/google-api-key
86 ac_add_options --with-mozilla-api-keyfile=${PWD@Q}/mozilla-api-key
88 # System libraries
89 ac_add_options --with-system-nspr
90 ac_add_options --with-system-nss
92 # Features
93 ac_add_options --enable-alsa
94 ac_add_options --enable-jack
95 ac_add_options --enable-crashreporter
96 ac_add_options --disable-updater
97 ac_add_options --disable-tests
98 END
101 build() {
102   cd firefox-$pkgver
104   export MOZ_NOSPAM=1
105   export MOZBUILD_STATE_PATH="$srcdir/mozbuild"
106   export MOZ_ENABLE_FULL_SYMBOLS=1
107   export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system
109   # LTO needs more open files
110   ulimit -n 4096
112   # Do 3-tier PGO
113   echo "Building instrumented browser..."
114   cat >.mozconfig ../mozconfig - <<END
115 ac_add_options --enable-profile-generate=cross
117   ./mach build
119   echo "Profiling instrumented browser..."
120   ./mach package
121   LLVM_PROFDATA=llvm-profdata \
122     JARLOG_FILE="$PWD/jarlog" \
123     xvfb-run -s "-screen 0 1920x1080x24 -nolisten local" \
124     ./mach python build/pgo/profileserver.py
126   stat -c "Profile data found (%s bytes)" merged.profdata
127   test -s merged.profdata
129   stat -c "Jar log found (%s bytes)" jarlog
130   test -s jarlog
132   echo "Removing instrumented browser..."
133   ./mach clobber
135   echo "Building optimized browser..."
136   cat >.mozconfig ../mozconfig - <<END
137 ac_add_options --enable-lto=cross
138 ac_add_options --enable-profile-use=cross
139 ac_add_options --with-pgo-profile-path=${PWD@Q}/merged.profdata
140 ac_add_options --with-pgo-jarlog=${PWD@Q}/jarlog
142   ./mach build
144   echo "Building symbol archive..."
145   ./mach buildsymbols
148 package() {
149   cd firefox-$pkgver
150   DESTDIR="$pkgdir" ./mach install
152   local vendorjs="$pkgdir/usr/lib/$pkgname/browser/defaults/preferences/vendor.js"
153   install -Dvm644 /dev/stdin "$vendorjs" <<END
154 // Use LANG environment variable to choose locale
155 pref("intl.locale.requested", "");
157 // Use system-provided dictionaries
158 pref("spellchecker.dictionary_path", "/usr/share/hunspell");
160 // Disable default browser checking.
161 pref("browser.shell.checkDefaultBrowser", false);
163 // Don't disable extensions in the application directory
164 pref("extensions.autoDisableScopes", 11);
167   local distini="$pkgdir/usr/lib/$pkgname/distribution/distribution.ini"
168   install -Dvm644 /dev/stdin "$distini" <<END
169 [Global]
170 id=archlinux
171 version=1.0
172 about=Mozilla Firefox for Arch Linux
174 [Preferences]
175 app.distributor=archlinux
176 app.distributor.channel=$pkgname
177 app.partner.archlinux=archlinux
180   local i theme=official
181   for i in 16 22 24 32 48 64 128 256; do
182     install -Dvm644 browser/branding/$theme/default$i.png \
183       "$pkgdir/usr/share/icons/hicolor/${i}x${i}/apps/$pkgname.png"
184   done
185   install -Dvm644 browser/branding/$theme/content/about-logo.png \
186     "$pkgdir/usr/share/icons/hicolor/192x192/apps/$pkgname.png"
187   install -Dvm644 browser/branding/$theme/content/about-logo@2x.png \
188     "$pkgdir/usr/share/icons/hicolor/384x384/apps/$pkgname.png"
189   install -Dvm644 browser/branding/$theme/content/about-logo.svg \
190     "$pkgdir/usr/share/icons/hicolor/scalable/apps/$pkgname.svg"
191   install -Dvm644 ../identity-icons-brand.svg \
192     "$pkgdir/usr/share/icons/hicolor/symbolic/apps/$pkgname-symbolic.svg"
194   install -Dvm644 ../$pkgname.desktop \
195     "$pkgdir/usr/share/applications/$pkgname.desktop"
197   # Install a wrapper to avoid confusion about binary path
198   install -Dvm755 /dev/stdin "$pkgdir/usr/bin/$pkgname" <<END
199 #!/bin/sh
200 exec /usr/lib/$pkgname/firefox "\$@"
203   # Replace duplicate binary with wrapper
204   # https://bugzilla.mozilla.org/show_bug.cgi?id=658850
205   ln -srfv "$pkgdir/usr/bin/$pkgname" "$pkgdir/usr/lib/$pkgname/firefox-bin"
207   # Use system certificates
208   local nssckbi="$pkgdir/usr/lib/$pkgname/libnssckbi.so"
209   if [[ -e $nssckbi ]]; then
210     ln -srfv "$pkgdir/usr/lib/libnssckbi.so" "$nssckbi"
211   fi
213   export SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE="$startdir/.crash-stats-api.token"
214   if [[ -f $SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE ]]; then
215     make -C obj uploadsymbols
216   else
217     cp -fvt "$startdir" obj/dist/*crashreporter-symbols-full.tar.zst
218   fi
221 # vim:set sw=2 et: