gtk/firefox-kde/PKGBUILD
2018-07-24 15:27:33 +02:00

314 lines
11 KiB
Bash

pkgname=firefox-kde
pkgver=61.0.1
pkgrel=5
pkgdesc="Standalone web browser from mozilla.org with OpenSUSE patch, integrate better with KDE"
arch=('x86_64')
license=('MPL' 'GPL' 'LGPL')
url="https://www.mozilla.org/firefox/"
depends=(gtk3 mozilla-common libxt startup-notification mime-types dbus-glib alsa-lib ffmpeg
libvpx libevent hunspell libproxy nss nspr pixman
kio knotifications kwindowsystem ki18n)
makedepends=(unzip zip diffutils python2 yasm mesa imake libpulse inetutils xorg-server-xvfb
autoconf2.13 gtk2 gobject-introspection jack rust gconf
cmake extra-cmake-modules llvm clang)
optdepends=('networkmanager: Location detection via available WiFi networks'
'libnotify: Notification integration'
'upower: Battery API'
'firefox-i18n: for multilanguage support')
options=(!emptydirs !strip)
screenshot="http://img864.imageshack.us/img864/5116/firefoxm.png"
provides=("firefox=${pkgver}" "kmozillahelper")
conflicts=('kmozillahelper')
replaces=('kmozillahelper')
#
# For whom want to update this package
#
# Notes on mercurial release revision
# http://releases.mozilla.org/pub/mozilla.org/firefox/releases/${pkgver}/SOURCE
# This URL uses CDN so it's faster, but maybe out of date when new firefox release comes out.
#
# Find Firefox KDE related patch:
# patch http://www.rosenauer.org/hg/mozilla/
# patch https://build.opensuse.org/package/show?package=MozillaFirefox&project=mozilla%3AFactory
#
# Usually, we also port non-openSUSE specific patch together.
#
_patchrev=a0c915e59e05
_kmozillahelper_commit=2ca28e0 #v5.0.2
_patchurl=http://www.rosenauer.org/hg/mozilla/raw-file/$_patchrev
source=("https://releases.mozilla.org/pub/firefox/releases/${pkgver}/source/${pkgname%%-kde}-${pkgver}.source.tar.xz"
"git://github.com/openSUSE/kmozillahelper#commit=${_kmozillahelper_commit}"
'firefox.desktop' 'ddg.xml'
'pgo-fix-missing-kdejs.patch'
# Firefox patchset
"$_patchurl/firefox-kde.patch"
"$_patchurl/firefox-branded-icons.patch"
# Gecko/toolkit patchset
"$_patchurl/mozilla-nongnome-proxies.patch"
"$_patchurl/mozilla-kde.patch"
"$_patchurl/mozilla-openaes-decl.patch"
"$_patchurl/mozilla-enable-csd.patch"
# Gentoo patch
1004_fix_pie_detection.patch
1005_fix_fortify_sources.patch
2000_system_harfbuzz.patch
2001_system_graphite2.patch
2003_nICER_implicit_decls.patch
2004_fix_lto_builds.patch
# Ubuntu patch
unity-menubar.patch
# Useless patchset
#"$_patchurl/gecko-lockdown.patch"
#"$_patchurl/mozilla-idldir.patch"
#$_patchurl/firefox-ui-lockdown.patch
#"$_patchurl/toolkit-ui-lockdown.patch"
#"$_patchurl/mozilla-bmo1088588.patch" # Specify for ARM and PPC
#"$_patchurl/toolkit-download-folder.patch"
#"$_patchurl/mozilla-language.patch" # making use of LANGUAGE= env var which isn't part of our standard
#"$_patchurl/mozilla-prefer_plugin_pref.patch" removed from opensuse. reason: dropped mozilla-prefer_plugin_pref.patch as this feature is likely not worth maintaining further
#"$_patchurl/mozilla-shared-nss-db.patch" shared by default now
)
sha256sums=('708f4dc39fdf105fe9d3ee6b52412a1c7548fd7d34e14c29f840064de3fe8a28'
'SKIP'
'6c2ea431c36afef67710547ae67e81975254309e9e1c82d8312f765caa950fe5'
'1190f251471305f4c96a313b32aa66ee1549125300d7ce385356f45bd8ebcb3d'
'7c3b3079e587fb5c7fd8725b4677efb270355c03c8d16513bbe619903038381e'
'336706c48f2a39eb3515227e97323a4933362d4f3b8f2d499f6e1ff843e1a18b'
'29acfc63f366510f471e395cc7a3815108072abda5851c48b64fdb894550408c'
'ef0f90c9134ef05b950f06a3ffbd699c2e5a5f99a4cdf9868e799534d68c204f'
'a18680f62e07c3a217dcbd31d2b974db4a38eae8561bc1de65a5d725c1c42f9e'
'be7aa94f682dcb0feec3dd7c277d5d19e3c56fe3d4940203c942bbbefad6ed70'
'ca1602c69f22ee1bd1000cebb883895eeb19b0e1647dfe4ca00422f39ed215aa'
'2b813ba66a3904b3e745d199479967dafc9b23e69db2238a932e013cdc21b91d'
'e5d8f0410ecd05119119e2d44a88fb5f1eb67a5b1035fd0a66b8cf167fb81c5d'
'a850e98166d89f6541f04ac188c4bbdf075f2be601d3d6e88b17d20048ae5243'
'6d9a7d3059d9017c1d3c28b38f257fe99b48ebcb1d829d427db59f80826fdc89'
'c39d22c4223c99181e1e828c1d6ba3bde035f497744ad423c60da91425ac4942'
'd199e00089a407f1a08e1d547c822279afd1abbffa361fb471990413eeeb2862'
'47b9c634e511ec384e6984575428d50f2b6c31100f0f09b896d2602f7bd7d370')
# Google API keys (see http://www.chromium.org/developers/how-tos/api-keys)
# Note: These are for Chakra Linux use ONLY. For your own distribution, please
# get your own set of keys. Feel free to contact totte@chakralinux.org for
# more information.
_google_api_key=AIzaSyDjyg8EmaRUIsewzdjZXFZ0O8N5ARDUDGU
# Mozilla API keys (see https://location.services.mozilla.com/api)
# Note: These are for Chakra Linux use ONLY. For your own distribution, please
# get your own set of keys. Feel free to contact totte@chakralinux.org for
# more information.
_mozilla_api_key=bf05f841-e0bd-4644-81f5-3c132755f2e9
prepare() {
mkdir path
ln -s /usr/bin/python2 path/python
#cd ${srcdir}/mozilla-release-${_changeset}
cd ${srcdir}/${pkgname%%-kde}-${pkgver}
echo -n "$_google_api_key" > google-api-key
echo -n "$_mozilla_api_key" > mozilla-api-key
msg 'Generating kde.js'
cat >kde.js <<END
pref("browser.preferences.instantApply", false);
pref("browser.backspace_action", 0);
END
msg 'Generating mozconfig'
# There multiple default mozconfigs in the soruce tree with references across directories
# $topsrcdir/build/unix/mozconfig.gtk
# $topsrcdir/build/unix/mozconfig.linux
# $topsrcdir/build/mozconfig.common
# $topsrcdir/browser/config/mozconfigs/linux64/release
# $topsrcdir/browser/config/mozconfigs/linux64/common-opt
# $topsrcdir/browser/config/mozconfig
# $topsrcdir/build/mozconfig.rust
# But we intend to mantain our own mozconfig without reference to any of the mozilla upstream configuration to keep it simple
# This mozconfig would inlcude most of the configurations listed above into one file
cat >.mozconfig <<END
ac_add_options --prefix=/usr
ac_add_options --enable-release
ac_add_options --enable-pie
ac_add_options --enable-gold
ac_add_options --enable-optimize="-O2"
ac_add_options --enable-rust-simd
# Release branding
ac_add_options --enable-application=browser
ac_add_options --enable-official-branding
ac_add_options --enable-update-channel=release
ac_add_options --with-distribution-id=org.chakralinux
ac_add_options --enable-default-toolkit=cairo-gtk3
export MOZILLA_OFFICIAL=1
export MOZ_TELEMETRY_REPORTING=1
export MOZ_ADDON_SIGNING=1
export MOZ_REQUIRE_SIGNING=1
# Keys
ac_add_options --with-google-api-keyfile=${PWD@Q}/google-api-key
ac_add_options --with-mozilla-api-keyfile=${PWD@Q}/mozilla-api-key
# System libraries
ac_add_options --with-system-jpeg
ac_add_options --with-system-zlib
ac_add_options --with-system-bz2
ac_add_options --with-system-libevent
ac_add_options --with-system-libvpx
ac_add_options --with-system-nss
ac_add_options --with-system-nspr
ac_add_options --with-system-icu
ac_add_options --with-system-png
ac_add_options --enable-system-pixman
#ac_add_options --enable-system-hunspell
#ac_add_options --enable-system-sqlite
ac_add_options --enable-system-ffi
ac_add_options --enable-libproxy
# Features
ac_add_options --enable-startup-notification
ac_add_options --enable-jack
ac_add_options --enable-alsa
ac_add_options --enable-gconf
ac_add_options --disable-updater
ac_add_options --enable-crashreporter
# PGO
mk_add_options MOZ_MAKE_FLAGS="-j9"
STRIP_FLAGS="--strip-debug"
END
msg "Gecko/toolkit patchset"
patch -Np1 -i "$srcdir/mozilla-nongnome-proxies.patch"
patch -Np1 -i "$srcdir/mozilla-kde.patch"
patch -Np1 -i "$srcdir/mozilla-openaes-decl.patch"
# ToDo the CSD is now enabled upstream?
#patch -Np1 -i "$srcdir/mozilla-enable-csd.patch"
msg "Firefox patchset"
patch -Np1 -i "$srcdir/firefox-kde.patch"
patch -Np1 -i "$srcdir/firefox-branded-icons.patch"
patch -Np0 -i "$srcdir/pgo-fix-missing-kdejs.patch"
msg "Gentoo Patchset"
patch -Np1 -i $srcdir/1004_fix_pie_detection.patch
patch -Np1 -i $srcdir/1005_fix_fortify_sources.patch
patch -Np1 -i $srcdir/2000_system_harfbuzz.patch
patch -Np1 -i $srcdir/2001_system_graphite2.patch
patch -Np1 -i $srcdir/2003_nICER_implicit_decls.patch
patch -Np1 -i $srcdir/2004_fix_lto_builds.patch
msg "Ubuntu Patchset"
patch -Np1 -i $srcdir/unity-menubar.patch
}
build() {
msg "build_kmozillahelper"
build_kmozillahelper
msg "build_firefox"
build_firefox
}
build_kmozillahelper() {
cd $srcdir/
mkdir -p kmozillahelper-build
cd kmozillahelper-build
cmake -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release ../kmozillahelper
make
}
build_firefox() {
cd $srcdir/${pkgname%%-kde}-${pkgver}
# _FORTIFY_SOURCE causes configure failures
CPPFLAGS+=" -O2"
export PATH="$srcdir/path:$PATH"
export SHELL=/bin/bash
# Do PGO
# xvfb-run -a -n 95 -s "-extension GLX -screen 0 1280x1024x24" \
./mach build
./mach buildsymbols
#make -f client.mk build
}
package() {
msg "package() kmozillahelper"
cd $srcdir/kmozillahelper-build
make DESTDIR=$pkgdir install
msg "package() Firefox"
#cd "$srcdir/mozilla-release-${_changeset}"
cd $srcdir/${pkgname%%-kde}-${pkgver}
export SHELL=/bin/bash
DESTDIR="$pkgdir" ./mach install
find . -name '*crashreporter-symbols-full.zip' -exec cp -fvt "$startdir" {} +
_vendorjs="$pkgdir/usr/lib/firefox/browser/defaults/preferences/vendor.js"
install -Dm644 /dev/stdin "$_vendorjs" <<END
// Use LANG environment variable to choose locale
pref("intl.locale.requested", "");
// Use system-provided dictionaries
pref("spellchecker.dictionary_path", "/usr/share/hunspell");
// Disable default browser checking.
pref("browser.shell.checkDefaultBrowser", false);
// Don't disable our bundled extensions in the application directory
pref("extensions.autoDisableScopes", 11);
pref("extensions.shownSelectionUI", true);
END
install -Dm644 kde.js "$pkgdir/usr/lib/firefox/browser/defaults/preferences/kde.js"
msg 'Chakra branding'
_distini="$pkgdir/usr/lib/firefox/distribution/distribution.ini"
install -Dm644 /dev/stdin "$_distini" <<END
[Global]
id=chakralinux
version=1.0
about=Mozilla Firefox compiled by Chakra GNU/Linux
[Preferences]
app.distributor=chakralinux
app.distributor.channel=firefox
app.partner.chakralinux=chakralinux
END
install -Dm644 $srcdir/ddg.xml $pkgdir/usr/lib/firefox/distribution/searchplugins/common/ddg-chakra.xml
for i in 16 22 24 32 48 64 128 256; do
install -Dm644 browser/branding/official/default$i.png \
"$pkgdir/usr/share/icons/hicolor/${i}x${i}/apps/firefox.png"
done
install -Dm644 browser/branding/official/content/about-logo.png \
"$pkgdir/usr/share/icons/hicolor/192x192/apps/firefox.png"
install -Dm644 browser/branding/official/content/about-logo@2x.png \
"$pkgdir/usr/share/icons/hicolor/384x384/apps/firefox.png"
install -Dm644 ../firefox.desktop \
"$pkgdir/usr/share/applications/firefox.desktop"
# Install a wrapper to avoid confusion about binary path
install -Dm755 /dev/stdin "$pkgdir/usr/bin/firefox" <<END
#!/bin/sh
exec /usr/lib/firefox/firefox "\$@"
END
# Replace duplicate binary with wrapper
# https://bugzilla.mozilla.org/show_bug.cgi?id=658850
ln -srf "$pkgdir/usr/bin/firefox" \
"$pkgdir/usr/lib/firefox/firefox-bin"
}