# Maintainer: Thaodan # Contributor: Weng Xuetian # For common issues regarding GCC and firefox see: # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45375 # enable this if you run out of memory during linking #_lowmem=true # build with PGO _pgo=true _pkgname=firefox pkgname=$_pkgname-kde-opensuse pkgver=106.0.5 pkgrel=1 pkgdesc="Standalone web browser from mozilla.org with OpenSUSE patch, integrate better with KDE" arch=('i686' 'x86_64') license=('MPL' 'GPL' 'LGPL') url="https://github.com/openSUSE/firefox-maintenance" depends=('libxt' 'mime-types' 'dbus-glib' 'hicolor-icon-theme' 'libevent' 'nss>=3.28.3' 'nspr>=4.10.6' 'hunspell' 'sqlite' 'kmozillahelper' 'ffmpeg' ) makedepends=('unzip' 'zip' 'diffutils' 'yasm' 'mesa' 'imake' 'xorg-server-xvfb' 'libpulse' 'inetutils' 'autoconf2.13' 'cargo' 'mercurial' 'llvm' 'clang' 'rust' 'jack' 'nodejs' 'cbindgen' 'nasm' 'xz' 'python' 'python-zstandard' 'dump_syms' # system av1 'dav1d' 'aom' # system harfbuzz 'harfbuzz' # system graphite 'graphite' # system webp 'libwebp' # system libevent 'libevent' # system icu 'icu' # system libvpx 'libvpx' # gtk 'gtk3' 'libnotify' 'libpulse' ) # https://bugs.gentoo.org/792705 # needs fixes from GCC 11.2 makedepends+=('gcc>=11.2.0') optdepends=('networkmanager: Location detection via available WiFi networks' 'speech-dispatcher: Text-to-Speech' 'pulseaudio: Audio support' 'libnotify: Notification integration' 'xdg-desktop-portal: Screensharing with Wayland') provides=("firefox=${pkgver}") conflicts=('firefox') _patchrev=22b224bf3e8c1431d2d9d961ca351cf3c50fdc15 options=('!emptydirs' !lto) _patchurl=https://raw.githubusercontent.com/openSUSE/firefox-maintenance/$_patchrev _repo=https://hg.mozilla.org/mozilla-unified source=("hg+$_repo#tag=FIREFOX_${pkgver//./_}_RELEASE" mozconfig firefox.desktop vendor.js kde.js # Firefox patchset firefox-branded-icons-$_patchrev.patch::$_patchurl/firefox/firefox-branded-icons.patch firefox-kde-$_patchrev.patch::$_patchurl/firefox/firefox-kde.patch # Gecko/toolkit patchset mozilla-kde-$_patchrev.patch::$_patchurl/mozilla-kde.patch mozilla-nongnome-proxies-$_patchrev.patch::$_patchurl/mozilla-nongnome-proxies.patch # globalmenu patch: # to support globalmenu a patch from ubuntu is applied # source: # http://bazaar.launchpad.net/~mozillateam/firefox/firefox-trunk.head # /view/head:/debian/patches/unity-menubar.patch unity-menubar.patch # end add_missing_pgo_rule.patch pgo_fix_missing_kdejs.patch # use system harfbuzz 0004-bmo-847568-Support-system-harfbuzz.patch # use system graphite2 0005-bmo-847568-Support-system-graphite2.patch # use sytem av1 0006-bmo-1559213-Support-system-av1.patch # reenable system sqlite 5022efe33088.patch # Force disable elfhack to fix build errors build-disable-elfhack.patch # patches from gentoo: # https://dev.gentoo.org/~whissi/mozilla/patchsets/firefox-89-patches-01.tar.xz 0020-Make-PGO-use-toolchain.patch # Fix MOZILLA#1516803 # https://bugzilla.mozilla.org/show_bug.cgi?id=1516803 0022-bmo-1516803-force-one-LTO-partition-for-sandbox-when.patch # PGO/LTO GCC patches 0024-Fix-building-with-PGO-when-using-GCC.patch 0027-LTO-Only-enable-LTO-for-Rust-when-complete-build-use.patch # end # Fix CSD when globalmenu is active #8 fix_csd_window_buttons.patch # Workaround #14 fix-wayland-build.patch # WebRTC - screen cast sync for Wayland # MOZILLLA#1672944 https://src.fedoraproject.org/rpms/firefox/raw/f0029706cee042f03f836e10d51bb2245e9fa392/f/libwebrtc-screen-cast-sync.patch # Unbreak build with python-zstandard 0.18.0 #23 bump-pypip-zstandard-0.18.diff # end ) # Google API keys (see http://www.chromium.org/developers/how-tos/api-keys) # Note: These are for Arch Linux use ONLY. For your own distribution, please # get your own set of keys. Feel free to contact foutrelis@archlinux.org for # more information. _google_api_key=AIzaSyDwr302FpOSkGRpLlUpPThNTDPbXcIn_FM _google_default_client_id=413772536636.apps.googleusercontent.com _google_default_client_secret=0ZChLK6AxeA3Isu96MkwqDR4 # Mozilla API keys (see https://location.services.mozilla.com/api) # Note: These are for Arch Linux use ONLY. For your own distribution, please # get your own set of keys. Feel free to contact heftig@archlinux.org for # more information. _mozilla_api_key=e05d56db0a694edc8b5aaebda3f2db6a prepare() { cd mozilla-unified cp "$srcdir/mozconfig" .mozconfig echo -n "$_google_api_key" >google-api-key echo "ac_add_options --with-google-location-service-api-keyfile=\"$PWD/google-api-key\"" >>.mozconfig echo -n "$_google_default_client_id $_google_default_client_secret" >google-oauth-api-key echo "ac_add_options --with-google-safebrowsing-api-keyfile=\"$PWD/google-oauth-api-key\"" >>.mozconfig echo -n "$_mozilla_api_key" >mozilla-api-key echo "ac_add_options --with-mozilla-api-keyfile=\"$PWD/mozilla-api-key\"" >>.mozconfig msg "Patching for KDE" patch -Np1 -i "$srcdir/mozilla-nongnome-proxies-$_patchrev.patch" patch -Np1 -i "$srcdir/mozilla-kde-$_patchrev.patch" patch -Np1 -i "$srcdir/firefox-kde-$_patchrev.patch" patch -Np1 -i "$srcdir/firefox-branded-icons-$_patchrev.patch" # Add globalmenu support patch -Np1 -i "$srcdir/unity-menubar.patch" # use system harfbuzz patch -Np1 -i "$srcdir"/0004-bmo-847568-Support-system-harfbuzz.patch # use system graphite2 patch -Np1 -i "$srcdir"/0005-bmo-847568-Support-system-graphite2.patch # use sytem av1 patch -Np1 -i "$srcdir"/0006-bmo-1559213-Support-system-av1.patch # reenable system sqlite patch -p1 -i "$srcdir"/5022efe33088.patch # Force disable elfhack to fix build errors patch -Np1 -i "$srcdir"/build-disable-elfhack.patch # Fix CSD when globalmenu is active #8 patch -Np1 -i "$srcdir"/fix_csd_window_buttons.patch # Workaround #14 patch -Np1 -i "$srcdir"/fix-wayland-build.patch # WebRTC - screen cast sync for Wayland patch -Np1 -i "$srcdir"/libwebrtc-screen-cast-sync.patch # Unbreak build with python-zstandard 0.18.0 #23 patch -Np1 -i "$srcdir"/bump-pypip-zstandard-0.18.diff if [ $_pgo ] ; then # Fix MOZILLA#1516803 # sandbox needs to be built with --param lto-partitions=1 when # GCC LTO is enabled patch -Np1 -i "$srcdir"/0022-bmo-1516803-force-one-LTO-partition-for-sandbox-when.patch # PGO/LTO GCC patches patch -Np1 -i "$srcdir"/0020-Make-PGO-use-toolchain.patch patch -Np1 -i "$srcdir"/0024-Fix-building-with-PGO-when-using-GCC.patch patch -Np1 -i "$srcdir"/0027-LTO-Only-enable-LTO-for-Rust-when-complete-build-use.patch # add missing rule for pgo builds patch -Np1 -i "$srcdir"/add_missing_pgo_rule.patch # add missing file Makefile for pgo builds patch -Np1 -i "$srcdir"/pgo_fix_missing_kdejs.patch echo "ac_add_options --enable-lto" >> .mozconfig fi } build() { #export CXXFLAGS="${CFLAGS}" cd mozilla-unified export MOZ_SOURCE_REPO="$_repo" export MOZBUILD_STATE_PATH="$srcdir/mozbuild" export MOZ_APP_REMOTINGNAME=$pkgname export CARGO_HOME="$srcdir"/.cargo export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system # LTO needs more open files ulimit -n 4096 export CC=gcc export CXX=g++ export AR="gcc-ar" export NM="gcc-nm" export RANLIB="gcc-ranlib" export MOZ_MAKE_FLAGS="$MAKEFLAGS" export MOZ_SMP_FLAGS="$MAKEFLAGS" export STRIP=/bin/true if [[ -n $_lowmem || $CARCH == i686 ]]; then LDFLAGS+=" -Xlinker --no-keep-memory" fi if [[ -n $_pgo ]]; then export DISPLAY=:99 export MOZ_PGO=1 export TMPDIR="$srcdir/tmp" mkdir -p "$TMPDIR" xvfb-run \ -a \ -s "-extension GLX -screen 0 1280x1024x24" \ ./mach build else ./mach build fi ./mach buildsymbols } package() { # The .so dependencies have to be added here so # pacman doesn't try to install the build time dependencies # by trying to resolve so names. # Doing so makes pacman ask for which have to be installed even thou # they are already specificied in makedepends depends+=( # system av1 'libdav1d.so' 'libaom.so' # system harfbuzz 'libharfbuzz.so' # system icu 'libicuuc.so' 'libicui18n.so' # system vpx 'libvpx.so' # gtk 'libgtk-3.so' ) cd mozilla-unified [[ "$CARCH" == "i686" ]] && cp "$srcdir/kde.js" obj-i686-pc-linux-gnu/dist/bin/defaults/pref [[ "$CARCH" == "x86_64" ]] && cp "$srcdir/kde.js" obj-x86_64-pc-linux-gnu/dist/bin/defaults/pref DESTDIR="$pkgdir" ./mach install install -Dm644 "$srcdir/vendor.js" "$pkgdir/usr/lib/firefox/browser/defaults/preferences/vendor.js" install -Dm644 "$srcdir/kde.js" "$pkgdir/usr/lib/firefox/browser/defaults/preferences/kde.js" _distini="$pkgdir/usr/lib/firefox/distribution/distribution.ini" install -Dm644 /dev/stdin "$_distini" <