1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
5 VIRTUALX_REQUIRED="pgo"
9 PYTHON_COMPAT=( python3_{6,7} )
10 PYTHON_REQ_USE='ncurses,sqlite,ssl,threads(+)'
12 # This list can be updated with scripts/get_langs.sh from the mozilla overlay
13 MOZ_LANGS=(ach af an ar ast az be bg bn br bs ca cak cs cy da de dsb el en en-CA
14 en-GB en-US eo es-AR es-CL es-ES es-MX et eu fa ff fi fr fy-NL ga-IE gd gl gn gu-IN
15 he hi-IN hr hsb hu hy-AM ia id is it ja ka kab kk km kn ko lij lt lv mk mr ms my
16 nb-NO nl nn-NO oc pa-IN pl pt-BR pt-PT rm ro ru si sk sl son sq sr sv-SE ta te
17 th tr uk ur uz vi xh zh-CN zh-TW )
19 # Convert the ebuild version to the upstream mozilla version, used by mozlinguas
20 MOZ_PV="${PV/_alpha/a}" # Handle alpha for SRC_URI
21 MOZ_PV="${MOZ_PV/_beta/b}" # Handle beta for SRC_URI
22 MOZ_PV="${MOZ_PV%%_rc*}" # Handle rc for SRC_URI
24 if [[ ${MOZ_ESR} == 1 ]] ; then
25 # ESR releases have slightly different version numbers
30 PATCH="${PN}-68.0-patches-12"
32 MOZ_HTTP_URI="https://archive.mozilla.org/pub/${PN}/releases"
33 MOZ_SRC_URI="${MOZ_HTTP_URI}/${MOZ_PV}/source/firefox-${MOZ_PV}.source.tar.xz"
35 if [[ "${PV}" == *_rc* ]]; then
36 MOZ_HTTP_URI="https://archive.mozilla.org/pub/${PN}/candidates/${MOZ_PV}-candidates/build${PV##*_rc}"
37 MOZ_LANGPACK_PREFIX="linux-i686/xpi/"
38 MOZ_SRC_URI="${MOZ_HTTP_URI}/source/${PN}-${MOZ_PV}.source.tar.xz -> $P.tar.xz"
43 inherit check-reqs eapi7-ver flag-o-matic toolchain-funcs eutils \
44 gnome2-utils llvm mozcoreconf-v6 pax-utils xdg-utils \
45 autotools mozlinguas-v2 multiprocessing virtualx
47 DESCRIPTION="Firefox Web Browser"
48 HOMEPAGE="https://www.mozilla.com/firefox"
50 KEYWORDS="amd64 arm64 ~ppc64 x86"
53 LICENSE="MPL-2.0 GPL-2 LGPL-2.1"
54 IUSE="bindist clang cpu_flags_x86_avx2 dbus debug eme-free geckodriver
55 +gmp-autoupdate hardened hwaccel jack lto cpu_flags_arm_neon
56 pgo pulseaudio +screenshot selinux startup-notification +system-av1
57 +system-harfbuzz +system-icu +system-jpeg +system-libevent
58 +system-sqlite +system-libvpx +system-webp test wayland wifi"
60 REQUIRED_USE="pgo? ( lto )
63 RESTRICT="!bindist? ( bindist )
66 PATCH_URIS=( https://dev.gentoo.org/~{anarchy,axs,polynomial-c,whissi}/mozilla/patchsets/${PATCH}.tar.xz )
76 >=x11-libs/cairo-1.10[X]
77 >=x11-libs/gtk+-2.18:2
78 >=x11-libs/gtk+-3.4.0:3[X]
80 >=x11-libs/pango-1.22.0
81 >=media-libs/libpng-1.6.35:0=[apng]
82 >=media-libs/mesa-10.2:*
84 >=media-libs/freetype-2.4.10
85 kernel_linux? ( !pulseaudio? ( media-libs/alsa-lib ) )
86 virtual/freedesktop-icon-theme
87 dbus? ( >=sys-apps/dbus-0.60
88 >=dev-libs/dbus-glib-0.72 )
89 startup-notification? ( >=x11-libs/startup-notification-0.8 )
90 >=x11-libs/pixman-0.19.2
91 >=dev-libs/glib-2.26:2
93 >=virtual/libffi-3.0.10:=
96 x11-libs/libXcomposite
103 >=media-libs/dav1d-0.3.0:=
104 >=media-libs/libaom-1.0.0:=
106 system-harfbuzz? ( >=media-libs/harfbuzz-2.4.0:0= >=media-gfx/graphite2-1.3.13 )
107 system-icu? ( >=dev-libs/icu-63.1:= )
108 system-jpeg? ( >=media-libs/libjpeg-turbo-1.2.1 )
109 system-libevent? ( >=dev-libs/libevent-2.0:0=[threads] )
110 system-libvpx? ( =media-libs/libvpx-1.7*:0=[postproc] )
111 system-sqlite? ( >=dev-db/sqlite-3.28.0:3[secure-delete,debug=] )
112 system-webp? ( >=media-libs/libwebp-1.0.2:0= )
113 wifi? ( kernel_linux? ( >=sys-apps/dbus-0.60
114 >=dev-libs/dbus-glib-0.72
115 net-misc/networkmanager ) )
116 jack? ( virtual/jack )
117 selinux? ( sec-policy/selinux-mozilla )"
120 jack? ( virtual/jack )
121 pulseaudio? ( || ( media-sound/pulseaudio
122 >=media-sound/apulse-0.1.9 ) )
123 selinux? ( sec-policy/selinux-mozilla )"
128 >=dev-util/cbindgen-0.8.7
129 >=net-libs/nodejs-8.11.0
130 >=sys-devel/binutils-2.30
135 !clang? ( sys-devel/llvm:10 )
138 sys-devel/llvm:10[gold]
139 pgo? ( =sys-libs/compiler-rt-sanitizers-10*[profile] )
144 !clang? ( sys-devel/llvm:9 )
147 sys-devel/llvm:9[gold]
148 pgo? ( =sys-libs/compiler-rt-sanitizers-9*[profile] )
153 !clang? ( sys-devel/llvm:8 )
156 sys-devel/llvm:8[gold]
157 pgo? ( =sys-libs/compiler-rt-sanitizers-8*[profile] )
162 !clang? ( sys-devel/llvm:7 )
165 sys-devel/llvm:7[gold]
166 pgo? ( =sys-libs/compiler-rt-sanitizers-7*[profile] )
170 pulseaudio? ( media-sound/pulseaudio )
171 >=virtual/rust-1.34.0
172 wayland? ( >=x11-libs/gtk+-3.11:3[wayland] )
173 amd64? ( >=dev-lang/yasm-1.1 virtual/opengl )
174 x86? ( >=dev-lang/yasm-1.1 virtual/opengl )
176 amd64? ( >=dev-lang/nasm-2.13 )
177 x86? ( >=dev-lang/nasm-2.13 )
180 S="${WORKDIR}/firefox-${PV%_*}"
182 QA_PRESTRIPPED="usr/lib*/${PN}/firefox"
184 BUILD_OBJ_DIR="${S}/ff"
186 # allow GMP_PLUGIN_LIST to be set in an eclass or
187 # overridden in the enviromnent (advanced hackers only)
188 if [[ -z $GMP_PLUGIN_LIST ]] ; then
189 GMP_PLUGIN_LIST=( gmp-gmpopenh264 gmp-widevinecdm )
193 local value_to_move=${1}
194 local new_path path_value
195 IFS=:; local -a path_values=( ${PATH} )
196 for path_value in "${path_values[@]}" ; do
197 if [[ ${path_value} == *"${value_to_move}"* ]] ; then
198 new_path="${path_value}${new_path:+:}${new_path}"
200 new_path+="${new_path:+:}${path_value}"
208 if ! has_version --host-root "sys-devel/clang:${LLVM_SLOT}" ; then
209 ewarn "sys-devel/clang:${LLVM_SLOT} is missing! Cannot use LLVM slot ${LLVM_SLOT} ..." >&2
214 if ! has_version --host-root "=sys-devel/lld-${LLVM_SLOT}*" ; then
215 ewarn "=sys-devel/lld-${LLVM_SLOT}* is missing! Cannot use LLVM slot ${LLVM_SLOT} ..." >&2
220 if ! has_version --host-root "=sys-libs/compiler-rt-sanitizers-${LLVM_SLOT}*" ; then
221 ewarn "=sys-libs/compiler-rt-sanitizers-${LLVM_SLOT}* is missing! Cannot use LLVM slot ${LLVM_SLOT} ..." >&2
227 einfo "Will use LLVM slot ${LLVM_SLOT}!" >&2
232 if ! has usersandbox $FEATURES ; then
233 die "You must enable usersandbox as X server can not run as root!"
237 # Ensure we have enough disk space to compile
238 if use pgo || use lto || use debug || use test ; then
239 CHECKREQS_DISK_BUILD="8G"
241 CHECKREQS_DISK_BUILD="4G"
244 check-reqs_pkg_pretend
250 # Ensure we have enough disk space to compile
251 if use pgo || use lto || use debug || use test ; then
252 CHECKREQS_DISK_BUILD="8G"
254 CHECKREQS_DISK_BUILD="4G"
259 # Avoid PGO profiling problems due to enviroment leakage
260 # These should *always* be cleaned up anyway
261 unset DBUS_SESSION_BUS_ADDRESS \
269 if ! use bindist ; then
271 elog "You are enabling official branding. You may not redistribute this build"
272 elog "to any users on your network or the internet. Doing so puts yourself into"
273 elog "a legal problem with Mozilla Foundation."
274 elog "You can disable it by emerging ${PN} _with_ the bindist USE-flag."
277 addpredict /proc/self/oom_score_adj
281 # Workaround for #627726
282 if has ccache ${FEATURES} ; then
283 einfo "Fixing PATH for FEATURES=ccache ..."
284 PATH=$(fix_path 'ccache/bin')
285 elif has distcc ${FEATURES} ; then
286 einfo "Fixing PATH for FEATURES=distcc ..."
287 PATH=$(fix_path 'distcc/bin')
294 # Unpack language packs
295 mozlinguas_src_unpack
299 rm "${WORKDIR}"/firefox/2013_avoid_noinline_on_GCC_with_skcms.patch
300 rm "${WORKDIR}"/firefox/2015_fix_cssparser.patch
301 eapply "${WORKDIR}/firefox"
303 # Allow user to apply any additional patches without modifing ebuild
306 # Make LTO respect MAKEOPTS
308 -e "s/multiprocessing.cpu_count()/$(makeopts_jobs)/" \
309 "${S}"/build/moz.configure/toolchain.configure \
310 || die "sed failed to set num_cores"
312 # Enable gnomebreakpad
314 sed -i -e "s:GNOME_DISABLE_CRASH_DIALOG=1:GNOME_DISABLE_CRASH_DIALOG=0:g" \
315 "${S}"/build/unix/run-mozilla.sh || die "sed failed!"
318 # Drop -Wl,--as-needed related manipulation for ia64 as it causes ld sefgaults, bug #582432
321 -e '/^OS_LIBS += no_as_needed/d' \
322 -e '/^OS_LIBS += as_needed/d' \
323 "${S}"/widget/gtk/mozgtk/gtk2/moz.build \
324 "${S}"/widget/gtk/mozgtk/gtk3/moz.build \
325 || die "sed failed to drop --as-needed for ia64"
328 # Fix sandbox violations during make clean, bug 372817
329 sed -e "s:\(/no-such-file\):${T}\1:g" \
330 -i "${S}"/config/rules.mk \
331 -i "${S}"/nsprpub/configure{.in,} \
334 # Don't exit with error when some libs are missing which we have in
336 sed '/^MOZ_PKG_FATAL_WARNINGS/s@= 1@= 0@' \
337 -i "${S}"/browser/installer/Makefile.in || die
339 # Don't error out when there's no files to be removed:
340 sed 's@\(xargs rm\)$@\1 -f@' \
341 -i "${S}"/toolkit/mozapps/installer/packager.mk || die
343 # Keep codebase the same even if not using official branding
344 sed '/^MOZ_DEV_EDITION=1/d' \
345 -i "${S}"/browser/branding/aurora/configure.sh || die
347 # rustfmt, a tool to format Rust code, is optional and not required to build Firefox.
348 # However, when available, an unsupported version can cause problems, bug #669548
349 sed -i -e "s@check_prog('RUSTFMT', add_rustup_path('rustfmt')@check_prog('RUSTFMT', add_rustup_path('rustfmt_do_not_use')@" \
350 "${S}"/build/moz.configure/rust.configure || die
352 # Autotools configure is now called old-configure.in
353 # This works because there is still a configure.in that happens to be for the
354 # shell wrapper configure script
355 eautoreconf old-configure.in
357 # Must run autoconf in js/src
358 cd "${S}"/js/src || die
359 eautoconf old-configure.in
363 MEXTENSIONS="default"
364 # Google API keys (see http://www.chromium.org/developers/how-tos/api-keys)
365 # Note: These are for Gentoo Linux use ONLY. For your own distribution, please
366 # get your own set of keys.
367 _google_api_key=AIzaSyDEAOvatFo0eTgsV_ZlEzx0ObmepsMzfAc
369 # Add information about TERM to output (build.log) to aid debugging
371 if [[ -n "${TERM}" ]] ; then
372 einfo "TERM is set to: \"${TERM}\""
374 einfo "TERM is unset."
377 if use clang && ! tc-is-clang ; then
379 einfo "Enforcing the use of clang due to USE=clang ..."
382 strip-unsupported-flags
383 elif ! use clang && ! tc-is-gcc ; then
385 einfo "Enforcing the use of gcc due to USE=-clang ..."
388 strip-unsupported-flags
391 ####################################
393 # mozconfig, CFLAGS and CXXFLAGS setup
395 ####################################
398 # common config components
399 mozconfig_annotate 'system_libs' \
403 # Must pass release in order to properly select linker
404 mozconfig_annotate 'Enable by Gentoo' --enable-release
407 if ! has userpriv $FEATURES ; then
408 eerror "Building firefox with USE=pgo and FEATURES=-userpriv is not supported!"
412 # Don't let user's LTO flags clash with upstream's flags
416 local show_old_compiler_warning=
419 # At this stage CC is adjusted and the following check will
421 if [[ $(clang-major-version) -lt 7 ]] ; then
422 show_old_compiler_warning=1
425 # Upstream only supports lld when using clang
426 mozconfig_annotate "forcing ld=lld due to USE=clang and USE=lto" --enable-linker=lld
428 if [[ $(gcc-major-version) -lt 8 ]] ; then
429 show_old_compiler_warning=1
433 append-cxxflags -flto
435 if ! use cpu_flags_x86_avx2 ; then
436 local _gcc_version_with_ipa_cdtor_fix="8.3"
437 local _current_gcc_version="$(gcc-major-version).$(gcc-minor-version)"
439 if ver_test "${_current_gcc_version}" -lt "${_gcc_version_with_ipa_cdtor_fix}" ; then
440 # due to a GCC bug, GCC will produce AVX2 instructions
441 # even if the CPU doesn't support AVX2, https://gcc.gnu.org/ml/gcc-patches/2018-12/msg01142.html
442 einfo "Disable IPA cdtor due to bug in GCC and missing AVX2 support -- triggered by USE=lto"
443 append-ldflags -fdisable-ipa-cdtor
445 einfo "No GCC workaround required, GCC version is already patched!"
448 einfo "No GCC workaround required, system supports AVX2"
451 # Linking only works when using ld.gold when LTO is enabled
452 mozconfig_annotate "forcing ld=gold due to USE=lto" --enable-linker=gold
455 if [[ -n "${show_old_compiler_warning}" ]] ; then
456 # Checking compiler's major version uses CC variable. Because we allow
457 # user to control used compiler via USE=clang flag, we cannot use
458 # initial value. So this is the earliest stage where we can do this check
459 # because pkg_pretend is not called in the main phase function sequence
460 # environment saving is not guaranteed so we don't know if we will have
461 # correct compiler until now.
463 ewarn "USE=lto requires up-to-date compiler (>=gcc-8 or >=clang-7)."
464 ewarn "You are on your own -- expect build failures. Don't file bugs using that unsupported configuration!"
469 mozconfig_annotate '+lto' --enable-lto=thin
472 mozconfig_annotate '+pgo' MOZ_PGO=1
475 # Avoid auto-magic on linker
477 # This is upstream's default
478 mozconfig_annotate "forcing ld=lld due to USE=clang" --enable-linker=lld
479 elif tc-ld-is-gold ; then
480 mozconfig_annotate "linker is set to gold" --enable-linker=gold
482 mozconfig_annotate "linker is set to bfd" --enable-linker=bfd
486 # It doesn't compile on alpha without this LDFLAGS
487 use alpha && append-ldflags "-Wl,--no-relax"
489 # Add full relro support for hardened
490 if use hardened ; then
491 append-ldflags "-Wl,-z,relro,-z,now"
492 mozconfig_use_enable hardened hardening
495 # Modifications to better support ARM, bug 553364
496 if use cpu_flags_arm_neon ; then
497 mozconfig_annotate '' --with-fpu=neon
499 if ! tc-is-clang ; then
500 # thumb options aren't supported when using clang, bug 666966
501 mozconfig_annotate '' --with-thumb=yes
502 mozconfig_annotate '' --with-thumb-interwork=no
506 if [[ ${CHOST} == armv*h* ]] ; then
507 mozconfig_annotate '' --with-float-abi=hard
508 if ! use system-libvpx ; then
509 sed -i -e "s|softfp|hard|" \
510 "${S}"/media/libvpx/moz.build
514 mozconfig_use_enable !bindist official-branding
516 mozconfig_use_enable debug
517 mozconfig_use_enable debug tests
518 if ! use debug ; then
519 mozconfig_annotate 'disabled by Gentoo' --disable-debug-symbols
521 mozconfig_annotate 'enabled by Gentoo' --enable-debug-symbols
523 # These are enabled by default in all mozilla applications
524 mozconfig_annotate '' --with-system-nspr --with-nspr-prefix="${SYSROOT}${EPREFIX}"/usr
525 mozconfig_annotate '' --with-system-nss --with-nss-prefix="${SYSROOT}${EPREFIX}"/usr
526 mozconfig_annotate '' --x-includes="${SYSROOT}${EPREFIX}"/usr/include \
527 --x-libraries="${SYSROOT}${EPREFIX}"/usr/$(get_libdir)
528 mozconfig_annotate '' --prefix="${EPREFIX}"/usr
529 mozconfig_annotate '' --libdir="${EPREFIX}"/usr/$(get_libdir)
530 mozconfig_annotate '' --disable-crashreporter
531 mozconfig_annotate 'Gentoo default' --with-system-png
532 mozconfig_annotate '' --enable-system-ffi
533 mozconfig_annotate '' --disable-gconf
534 mozconfig_annotate '' --with-intl-api
535 mozconfig_annotate '' --enable-system-pixman
536 # Instead of the standard --build= and --host=, mozilla uses --host instead
537 # of --build, and --target intstead of --host.
538 # Note, mozilla also has --build but it does not do what you think it does.
539 # Set both --target and --host as mozilla uses python to guess values otherwise
540 mozconfig_annotate '' --target="${CHOST}"
541 mozconfig_annotate '' --host="${CBUILD:-${CHOST}}"
542 if use system-libevent ; then
543 mozconfig_annotate '' --with-system-libevent="${SYSROOT}${EPREFIX}"/usr
546 if ! use x86 && [[ ${CHOST} != armv*h* ]] ; then
547 mozconfig_annotate '' --enable-rust-simd
550 # use the gtk3 toolkit (the only one supported at this point)
551 # TODO: Will this result in automagic dependency on x11-libs/gtk+[wayland]?
552 if use wayland ; then
553 mozconfig_annotate '' --enable-default-toolkit=cairo-gtk3-wayland
555 mozconfig_annotate '' --enable-default-toolkit=cairo-gtk3
558 mozconfig_use_enable startup-notification
559 mozconfig_use_enable system-sqlite
560 mozconfig_use_with system-av1
561 mozconfig_use_with system-harfbuzz
562 mozconfig_use_with system-harfbuzz system-graphite2
563 mozconfig_use_with system-icu
564 mozconfig_use_with system-jpeg
565 mozconfig_use_with system-libvpx
566 mozconfig_use_with system-webp
567 mozconfig_use_enable pulseaudio
568 # force the deprecated alsa sound code if pulseaudio is disabled
569 if use kernel_linux && ! use pulseaudio ; then
570 mozconfig_annotate '-pulseaudio' --enable-alsa
573 # Disable built-in ccache support to avoid sandbox violation, #665420
574 # Use FEATURES=ccache instead!
575 mozconfig_annotate '' --without-ccache
576 sed -i -e 's/ccache_stats = None/return None/' \
577 python/mozbuild/mozbuild/controller/building.py || \
578 die "Failed to disable ccache stats call"
580 mozconfig_use_enable dbus
582 mozconfig_use_enable wifi necko-wifi
584 mozconfig_use_enable geckodriver
586 # enable JACK, bug 600002
587 mozconfig_use_enable jack
589 # Enable/Disable eme support
590 use eme-free && mozconfig_annotate '+eme-free' --disable-eme
592 # Setup api key for location services and safebrowsing, https://bugzilla.mozilla.org/show_bug.cgi?id=1531176#c34
593 echo -n "${_google_api_key}" > "${S}"/google-api-key
594 mozconfig_annotate '' --with-google-location-service-api-keyfile="${S}/google-api-key"
595 mozconfig_annotate '' --with-google-safebrowsing-api-keyfile="${S}/google-api-key"
597 mozconfig_annotate '' --enable-extensions="${MEXTENSIONS}"
599 # allow elfhack to work in combination with unstripped binaries
600 # when they would normally be larger than 2GiB.
601 append-ldflags "-Wl,--compress-debug-sections=zlib"
603 if use clang && ! use arm64; then
604 # https://bugzilla.mozilla.org/show_bug.cgi?id=1482204
605 # https://bugzilla.mozilla.org/show_bug.cgi?id=1483822
606 mozconfig_annotate 'elf-hack is broken when using Clang' --disable-elf-hack
609 echo "mk_add_options MOZ_OBJDIR=${BUILD_OBJ_DIR}" >> "${S}"/.mozconfig
610 echo "mk_add_options XARGS=/usr/bin/xargs" >> "${S}"/.mozconfig
612 # Finalize and report settings
615 mkdir -p "${S}"/third_party/rust/libloading/.deps
617 # workaround for funky/broken upstream configure...
618 SHELL="${SHELL:-${EPREFIX}/bin/bash}" MOZ_NOSPAM=1 \
619 ./mach configure || die
627 # Reset and cleanup environment variables used by GNOME/XDG
628 gnome2_environment_reset
631 addpredict /etc/gconf
635 MOZ_MAKE_FLAGS="${MAKEOPTS} -O" \
636 SHELL="${SHELL:-${EPREFIX}/bin/bash}" \
639 ./mach build --verbose \
644 cd "${BUILD_OBJ_DIR}" || die
646 # Pax mark xpcshell for hardened support, only used for startupcache creation.
647 pax-mark m "${BUILD_OBJ_DIR}"/dist/bin/xpcshell
649 # Add our default prefs for firefox
650 cp "${FILESDIR}"/gentoo-default-prefs.js-3 \
651 "${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js" \
654 # set dictionary path, to use system hunspell
655 echo "pref(\"spellchecker.dictionary_path\", \"${EPREFIX}/usr/share/myspell\");" \
656 >>"${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js" || die
658 # force the graphite pref if system-harfbuzz is enabled, since the pref cant disable it
659 if use system-harfbuzz ; then
660 echo "sticky_pref(\"gfx.font_rendering.graphite.enabled\",true);" \
661 >>"${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js" || die
664 # force cairo as the canvas renderer on platforms without skia support
665 if [[ $(tc-endian) == "big" ]] ; then
666 echo "sticky_pref(\"gfx.canvas.azure.backends\",\"cairo\");" \
667 >>"${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js" || die
668 echo "sticky_pref(\"gfx.content.azure.backends\",\"cairo\");" \
669 >>"${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js" || die
672 # Augment this with hwaccel prefs
673 if use hwaccel ; then
674 cat "${FILESDIR}"/gentoo-hwaccel-prefs.js-1 >> \
675 "${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js" \
679 if ! use screenshot ; then
680 echo "pref(\"extensions.screenshots.disabled\", true);" >> \
681 "${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js" \
685 echo "pref(\"extensions.autoDisableScopes\", 3);" >> \
686 "${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js" \
690 use gmp-autoupdate || use eme-free || for plugin in "${GMP_PLUGIN_LIST[@]}" ; do
691 echo "pref(\"media.${plugin}.autoupdate\", false);" >> \
692 "${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js" \
697 MOZ_MAKE_FLAGS="${MAKEOPTS}" SHELL="${SHELL:-${EPREFIX}/bin/bash}" MOZ_NOSPAM=1 \
698 DESTDIR="${D}" ./mach install || die
700 if use geckodriver ; then
701 cp "${BUILD_OBJ_DIR}"/dist/bin/geckodriver "${ED%/}"${MOZILLA_FIVE_HOME} || die
702 pax-mark m "${ED%/}"${MOZILLA_FIVE_HOME}/geckodriver
704 dosym ${MOZILLA_FIVE_HOME}/geckodriver /usr/bin/geckodriver
707 # Install language packs
708 MOZEXTENSION_TARGET="distribution/extensions" MOZ_INSTALL_L10N_XPIFILE="1" mozlinguas_src_install
710 local size sizes icon_path icon name
711 if use bindist ; then
713 icon_path="${S}/browser/branding/aurora"
714 # Firefox's new rapid release cycle means no more codenames
715 # Let's just stick with this one...
719 # Override preferences to set the MOZ_DEV_EDITION defaults, since we
720 # don't define MOZ_DEV_EDITION to avoid profile debaucles.
721 # (source: browser/app/profile/firefox.js)
722 cat >>"${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js" <<PROFILE_EOF
723 pref("app.feedback.baseURL", "https://input.mozilla.org/%LOCALE%/feedback/firefoxdev/%VERSION%/");
724 sticky_pref("lightweightThemes.selectedThemeID", "firefox-devedition@mozilla.org");
725 sticky_pref("browser.devedition.theme.enabled", true);
726 sticky_pref("devtools.theme", "dark");
730 sizes="16 22 24 32 48 64 128 256"
731 icon_path="${S}/browser/branding/official"
733 name="Mozilla Firefox"
736 # Disable built-in auto-update because we update firefox through package manager
737 insinto ${MOZILLA_FIVE_HOME}/distribution/
738 newins "${FILESDIR}"/disable-auto-update.policy.json policies.json
740 # Install icons and .desktop for menu entry
741 for size in ${sizes} ; do
742 insinto "/usr/share/icons/hicolor/${size}x${size}/apps"
743 newins "${icon_path}/default${size}.png" "${icon}.png"
745 # Install a 48x48 icon into /usr/share/pixmaps for legacy DEs
746 newicon "${icon_path}/default48.png" "${icon}.png"
748 # Add StartupNotify=true bug 237317
749 local startup_notify="false"
750 if use startup-notification ; then
751 startup_notify="true"
754 local display_protocols="auto X11" use_wayland="false"
755 if use wayland ; then
756 display_protocols+=" Wayland"
760 local app_name desktop_filename display_protocol exec_command
761 for display_protocol in ${display_protocols} ; do
762 app_name="${name} on ${display_protocol}"
763 desktop_filename="${PN}-${display_protocol,,}.desktop"
765 case ${display_protocol} in
767 exec_command='firefox-wayland --name firefox-wayland'
768 newbin "${FILESDIR}"/firefox-wayland.sh firefox-wayland
771 if ! use wayland ; then
772 # Exit loop here because there's no choice so
773 # we don't need wrapper/.desktop file for X11.
777 exec_command='firefox-x11 --name firefox-x11'
778 newbin "${FILESDIR}"/firefox-x11.sh firefox-x11
782 desktop_filename="${PN}.desktop"
783 exec_command='firefox'
787 newmenu "${FILESDIR}/icon/${PN}-r1.desktop" "${desktop_filename}"
789 -e "s:@NAME@:${app_name}:" \
790 -e "s:@EXEC@:${exec_command}:" \
791 -e "s:@ICON@:${icon}:" \
792 -e "s:@STARTUP_NOTIFY@:${startup_notify}:" \
793 "${ED%/}/usr/share/applications/${desktop_filename}" || die
796 rm "${ED%/}"/usr/bin/firefox || die
797 newbin "${FILESDIR}"/firefox.sh firefox
801 "${ED%/}"/usr/bin/firefox \
802 "${ED%/}"/usr/bin/firefox-x11 \
803 "${ED%/}"/usr/bin/firefox-wayland \
805 [[ ! -f "${wrapper}" ]] && continue
808 -e "s:@PREFIX@:${EPREFIX%/}/usr:" \
809 -e "s:@DEFAULT_WAYLAND@:${use_wayland}:" \
813 # Don't install llvm-symbolizer from sys-devel/llvm package
814 [[ -f "${ED%/}${MOZILLA_FIVE_HOME}/llvm-symbolizer" ]] && \
815 rm "${ED%/}${MOZILLA_FIVE_HOME}/llvm-symbolizer"
817 # firefox and firefox-bin are identical
818 rm "${ED%/}"${MOZILLA_FIVE_HOME}/firefox-bin || die
819 dosym firefox ${MOZILLA_FIVE_HOME}/firefox-bin
821 # Required in order to use plugins and even run firefox on hardened.
822 pax-mark m "${ED%/}"${MOZILLA_FIVE_HOME}/{firefox,plugin-container}
828 # if the apulse libs are available in MOZILLA_FIVE_HOME then apulse
829 # doesn't need to be forced into the LD_LIBRARY_PATH
830 if use pulseaudio && has_version ">=media-sound/apulse-0.1.9" ; then
831 einfo "APULSE found - Generating library symlinks for sound support"
833 pushd "${ED}"${MOZILLA_FIVE_HOME} &>/dev/null || die
834 for lib in ../apulse/libpulse{.so{,.0},-simple.so{,.0}} ; do
835 # a quickpkg rolled by hand will grab symlinks as part of the package,
836 # so we need to avoid creating them if they already exist.
837 if [[ ! -L ${lib##*/} ]] ; then
838 ln -s "${lib}" ${lib##*/} || die
841 popd &>/dev/null || die
846 gnome2_icon_cache_update
847 xdg_desktop_database_update
849 if ! use gmp-autoupdate && ! use eme-free ; then
850 elog "USE='-gmp-autoupdate' has disabled the following plugins from updating or"
851 elog "installing into new profiles:"
853 for plugin in "${GMP_PLUGIN_LIST[@]}"; do elog "\t ${plugin}" ; done
857 if use pulseaudio && has_version ">=media-sound/apulse-0.1.9" ; then
858 elog "Apulse was detected at merge time on this system and so it will always be"
859 elog "used for sound. If you wish to use pulseaudio instead please unmerge"
860 elog "media-sound/apulse."
864 local show_doh_information show_normandy_information
866 if [[ -z "${REPLACING_VERSIONS}" ]] ; then
867 # New install; Tell user that DoH is disabled by default
868 show_doh_information=yes
869 show_normandy_information=yes
871 local replacing_version
872 for replacing_version in ${REPLACING_VERSIONS} ; do
873 if ver_test "${replacing_version}" -lt 68.6.0-r3 ; then
874 # Tell user only once about our DoH default
875 show_doh_information=yes
878 if ver_test "${replacing_version}" -lt 68.6.0-r3 ; then
879 # Tell user only once about our Normandy default
880 show_normandy_information=yes
885 if [[ -n "${show_doh_information}" ]] ; then
887 elog "Note regarding Trusted Recursive Resolver aka DNS-over-HTTPS (DoH):"
888 elog "Due to privacy concerns (encrypting DNS might be a good thing, sending all"
889 elog "DNS traffic to Cloudflare by default is not a good idea and applications"
890 elog "should respect OS configured settings), \"network.trr.mode\" was set to 5"
891 elog "(\"Off by choice\") by default."
892 elog "You can enable DNS-over-HTTPS in ${PN^}'s preferences."
896 if [[ -n "${show_normandy_information}" ]] ; then
898 elog "Upstream operates a service named Normandy which allows Mozilla to"
899 elog "push changes for default settings or even install new add-ons remotely."
900 elog "While this can be useful to address problems like 'Armagadd-on 2.0' or"
901 elog "revert previous decisions to disable TLS 1.0/1.1, privacy and security"
902 elog "concerns prevail, which is why we have switched off the use of this"
903 elog "service by default."
905 elog "To re-enable this service set"
907 elog " app.normandy.enabled=true"
909 elog "in about:config."
914 gnome2_icon_cache_update
915 xdg_desktop_database_update