From d174af26299a0f445a174e3996dcd78202d00105 Mon Sep 17 00:00:00 2001 From: ProsperousPotato Date: Thu, 26 Feb 2026 11:54:28 +0000 Subject: update icecat ebuild to parity with parona-overlay --- www-client/icecat/Manifest | 10 +- .../icecat/files/icecat-140.7.1-glibc-2.43.patch | 48 + www-client/icecat/icecat-140.6.0.ebuild | 1265 ------------------- www-client/icecat/icecat-140.7.0.ebuild | 1264 ------------------- www-client/icecat/icecat-140.7.1.ebuild | 1270 ++++++++++++++++++++ www-client/icecat/icecat-140.8.0.ebuild | 1266 +++++++++++++++++++ 6 files changed, 2589 insertions(+), 2534 deletions(-) create mode 100644 www-client/icecat/files/icecat-140.7.1-glibc-2.43.patch delete mode 100644 www-client/icecat/icecat-140.6.0.ebuild delete mode 100644 www-client/icecat/icecat-140.7.0.ebuild create mode 100644 www-client/icecat/icecat-140.7.1.ebuild create mode 100644 www-client/icecat/icecat-140.8.0.ebuild diff --git a/www-client/icecat/Manifest b/www-client/icecat/Manifest index 2c598bb..c31fe69 100644 --- a/www-client/icecat/Manifest +++ b/www-client/icecat/Manifest @@ -1,7 +1,7 @@ DIST firefox-139-loong-patches-02.tar.xz 3096 BLAKE2B 2e9c0f3dac780c808a13f70fe3808df9976898360b55113def97bf3594893166e0647c70ebc389b2d14fa2c2453fc1dd68aba20d92178670ef97d70c34205e1c SHA512 e1244007290e2e15d14cf519e3ade6a4da06abe41c416de60569a11396609661cb62fb5b592e763cc079406699dc33d6a34851f71068f4d09bdf34021b035a59 -DIST firefox-140esr-patches-04.tar.xz 124424 BLAKE2B 89fd2cedb67a9d82c339fed01b79c9c4b3f58051b68764121f982d4eba04d979c9d16238a7599fbab4f9d3965253f3ec4886f2da590b05116bc6ea0ee027e935 SHA512 b8c268fd5118007490edb7ef99f90148af4fa88ec7cdec03d028630476c85862e896b1ad3a6964215835f6f442aa71df96d6dd9aab632802773792bced8dc17b DIST firefox-140esr-patches-05.tar.xz 124432 BLAKE2B 9281214dcf3da5d2e288112a99dc1fbee44ee93c4b83e30d73e8383805bd9c8ad9b1918d11351398cd963fdc30ec3cb50d7f6b5c9905d7c1303d21fdef440fbe SHA512 70551bb7eea2a50bbd30418438a78a8ace07467fe852b7655c24373c651f816df89fceeb98b6fa6c7d95944b0c5deef76b89b3e742795a8ac04259f02bd25c10 -DIST icecat-140.6.0-1gnu1.tar.zst 915461781 BLAKE2B 8f8bcba4fda47eb894d7a63ec099389c4eb654597b482cba7bac83c8e523bee504d8d4905200f9ac193deb2f4811ab63e89d3fe6507c4584588d612cbcd49bcd SHA512 a934bc5bd529488149a0502d777c92edd80cdba7543d24ea1f3744803cbd4f139bd105bd95125206a528b281b20d32118df4fcbc35915475a109453e9475c901 -DIST icecat-140.7.0-1gnu1.tar.zst 724386528 BLAKE2B 704de3e01c26dcaf3d6ebe5781ebfcd5d00d3d0e0f0e70a4f2825cc953b5354fa05ae0bed97a8a76fe17ba934979af781f9973226a690970d6124f8a77a96179 SHA512 6a7c90fdb7db46bd27632d947fa715f9dcaef497f046ba04ea05fc192c6aa341e608e7d0b90a1328f98b36c3f5d3a1c947a41a21799d1515b216f1b4a8ff12a1 -DIST wasi-sdk-28.0-arm64-linux.tar.gz 121761064 BLAKE2B 044a93cf1790dd652a86927bd74cf2a8b081a8db1261c2879d7fa72d5efde6a1ef65be63ff94c94d1e39d179ab829eded95121e2f6fd6c8f83374690763d532a SHA512 5ed16fdcdfa573630a75986cddde5ddc6a7e010ad9ad20cfa939becb78c1cbb0740fd1a53064e3d358b929b7b9ef6264612644293a1840c54a3e1868b4c15d7b -DIST wasi-sdk-28.0-x86_64-linux.tar.gz 121193888 BLAKE2B eaefdd7f0432b3a2432e09fce659282e1e1a515a0b31f63cc2d48953e180229fe494deff2e1019f60ab38179f7f93e6dd13d4763355b706e5f447efac1e5f08c SHA512 805412c73b4b2d3c9df9af25b95dd2ed7625dd1b4424bbf07286caf24fc87e54aee1fbb4fbe3904f180a7cca9decf00177915860ca216e87421d8c91a0693875 +DIST firefox-140esr-patches-07.tar.xz 125712 BLAKE2B df8cb80104d816966723de33c79aa56f2a0ff54bf1a8a0668b76c4bb1bf3a7fa181011850c3030c04c2b8abcd69bec2dc23d500cfb6a624704b0797b76af8062 SHA512 6735b7f00048a24f313f2a09a17c785d045b3ebc0e640c9b7932fd1e65b84284344adee73d058855aff6bf93384933323031799565838a6339b9d20684e162d4 +DIST icecat-140.7.1-1gnu1.tar.zst 726079419 BLAKE2B 08379aa8c95de7bce7ce39dd459514678ae989e039048a36939450848b1fd3d4fe6a0edc01a8e51bb109a6d0c48e759b65b0a5f02694ea94b4870ed02983b40b SHA512 e3e62360cfa4d7e62c0797f8323c713265110dadaf1843de68b08e7a534edfd652a160383967130655900d0d39ab03c23f7bc17284459a9f05289f393fa05d69 +DIST icecat-140.8.0-2gnu1.tar.zst 724677963 BLAKE2B d7f411f11147eb44b05ff88f037b389f1dc9a4830f45d7cbb59a64363d8286ec313f753ebe85ea23ce8f9ec949d34b56f62d8b3166d53ec763c82ca67559e7d1 SHA512 e1209dd8f2364246689a9245108bcd34cb4b32396b57703633016e697405214f1c42e0c2be4f4e8770d0f3eaeaa4c732811b61a09dfe2438c246444706f6e083 +DIST wasi-sdk-30.0-arm64-linux.tar.gz 119262670 BLAKE2B 59194c6459c98b0566522c97cceac61c68915629931546f8598856d726dff9f85742560afe9c86d6102a1faeb44c962b3935b8b6de326ea218158a32026319bc SHA512 ff794dd90c851b2c0b7ea2cb2ceddaf23cb4cb1c211e37ae3dcf12556e6a21e389c2b894ef52e68110ca085098ae3717b18a497a928b5d13b0a9dab61acb8b38 +DIST wasi-sdk-30.0-x86_64-linux.tar.gz 119449290 BLAKE2B 7286b9079eeb160b0e033b7802f703b08e089e452c6558f1feb6d9cf8cd240fabea7f9a39d44b13b2793e69a02c569f64520d677d76a577bc2e35ce07c722212 SHA512 9b8dc1cec71aa9e870840b30f2b7307d6b48f965d50b724926745780e4e76411f5eb97e443970ecdead90a4932669cc18ae506439f22a24d06e2e8fe44d220b3 diff --git a/www-client/icecat/files/icecat-140.7.1-glibc-2.43.patch b/www-client/icecat/files/icecat-140.7.1-glibc-2.43.patch new file mode 100644 index 0000000..2661683 --- /dev/null +++ b/www-client/icecat/files/icecat-140.7.1-glibc-2.43.patch @@ -0,0 +1,48 @@ +Cleaned up patch based on +https://github.com/xarblu/sysbits/blob/72296ccadaca4c245e713fcf5375a7449c2855d0/etc/portage/patches/mail-client/thunderbird/00-glibc-2.43.patch + +--- a/third_party/rust/glslopt/glsl-optimizer/include/c11/threads_posix.h.orig ++++ b/third_party/rust/glslopt/glsl-optimizer/include/c11/threads_posix.h +@@ -51,7 +51,6 @@ Configuration macro: + #include + + /*---------------------------- macros ----------------------------*/ +-#define ONCE_FLAG_INIT PTHREAD_ONCE_INIT + #ifdef INIT_ONCE_STATIC_INIT + #define TSS_DTOR_ITERATIONS PTHREAD_DESTRUCTOR_ITERATIONS + #else +@@ -66,7 +65,6 @@ typedef pthread_cond_t cnd_t; + typedef pthread_t thrd_t; + typedef pthread_key_t tss_t; + typedef pthread_mutex_t mtx_t; +-typedef pthread_once_t once_flag; + + + /* +@@ -88,15 +86,6 @@ impl_thrd_routine(void *p) + } + + +-/*--------------- 7.25.2 Initialization functions ---------------*/ +-// 7.25.2.1 +-static inline void +-call_once(once_flag *flag, void (*func)(void)) +-{ +- pthread_once(flag, func); +-} +- +- + /*------------- 7.25.3 Condition variable functions -------------*/ + // 7.25.3.1 + static inline int +--- a/security/sandbox/chromium/sandbox/linux/system_headers/linux_seccomp.h.orig ++++ b/security/sandbox/chromium/sandbox/linux/system_headers/linux_seccomp.h +@@ -214,8 +214,4 @@ struct seccomp_notif_addfd { + #define SECCOMP_RET_INVALID 0x00010000U // Illegal return value + #endif + +-#ifndef SYS_SECCOMP +-#define SYS_SECCOMP 1 +-#endif +- + #endif // SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SECCOMP_H_ diff --git a/www-client/icecat/icecat-140.6.0.ebuild b/www-client/icecat/icecat-140.6.0.ebuild deleted file mode 100644 index 3634daf..0000000 --- a/www-client/icecat/icecat-140.6.0.ebuild +++ /dev/null @@ -1,1265 +0,0 @@ -# Copyright 1999-2026 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -# Ebuild is based on the Firefox ebuilds in the main repo - -EAPI=8 - -# Using Gentoos firefox patches as system libraries and lto are quite nice -FIREFOX_PATCHSET="firefox-140esr-patches-04.tar.xz" -FIREFOX_LOONG_PATCHSET="firefox-139-loong-patches-02.tar.xz" - -LLVM_COMPAT=( 19 20 21 ) - -# This will also filter rust versions that don't match LLVM_COMPAT in the non-clang path; this is fine. -RUST_NEEDS_LLVM=1 -# If not building with clang we need at least rust 1.76 -RUST_MIN_VER=1.82.0 - -PYTHON_COMPAT=( python3_{11..14} ) -PYTHON_REQ_USE="ncurses,sqlite,ssl" - -VIRTUALX_REQUIRED="manual" - -# Information about the bundled wasi toolchain from -# https://github.com/WebAssembly/wasi-sdk/ -WASI_SDK_VER=28.0 -WASI_SDK_LLVM_VER=21 - -inherit check-reqs desktop flag-o-matic gnome2-utils linux-info llvm-r1 multiprocessing \ - optfeature pax-utils python-any-r1 readme.gentoo-r1 rust toolchain-funcs unpacker virtualx xdg - -DESCRIPTION="GNU IceCat Web Browser" -HOMEPAGE="https://www.gnu.org/software/gnuzilla/" - -PATCH_URIS=( - https://dev.gentoo.org/~juippis/mozilla/patchsets/${FIREFOX_PATCHSET} -) - -# Icecat tarball generated from https://cgit.git.savannah.gnu.org/cgit/gnuzilla.git -# Script modified to output zstd tarballs due to size and unpacking speed considerations. -ICECAT_REV="1gnu1" - -SRC_URI=" - https://gitlab.com/api/v4/projects/32909921/packages/generic/${PN}/${PV}-${ICECAT_REV}/${P}-${ICECAT_REV}.tar.zst - ${PATCH_URIS[@]} - loong? ( - https://dev.gentoo.org/~xen0n/distfiles/www-client/firefox/${FIREFOX_LOONG_PATCHSET} - ) - wasm-sandbox? ( - amd64? ( https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VER/.*/}/wasi-sdk-${WASI_SDK_VER}-x86_64-linux.tar.gz ) - arm64? ( https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VER/.*/}/wasi-sdk-${WASI_SDK_VER}-arm64-linux.tar.gz ) - )" -S="${WORKDIR}/${PN}-${PV%_*}" -LICENSE="MPL-2.0 GPL-2 LGPL-2.1" -SLOT="0" -KEYWORDS="amd64" - -IUSE="+clang dbus debug hardened hwaccel jack libproxy pgo pulseaudio selinux sndio" -IUSE+=" +system-av1 +system-harfbuzz +system-icu +system-jpeg +system-libevent +system-libvpx" -IUSE+=" system-pipewire system-png +system-webp test wayland wifi +X" - -# Firefox-only IUSE -IUSE+=" gnome-shell +jumbo-build openh264 wasm-sandbox" - -REQUIRED_USE="|| ( X wayland ) - debug? ( !system-av1 ) - pgo? ( jumbo-build ) - wayland? ( dbus ) - wifi? ( dbus ) -" - -RESTRICT="!test? ( test )" - -FF_ONLY_DEPEND="selinux? ( sec-policy/selinux-mozilla )" -BDEPEND="${PYTHON_DEPS} - $(unpacker_src_uri_depends) - $(llvm_gen_dep ' - llvm-core/clang:${LLVM_SLOT} - llvm-core/llvm:${LLVM_SLOT} - clang? ( - llvm-core/lld:${LLVM_SLOT} - pgo? ( llvm-runtimes/compiler-rt-sanitizers:${LLVM_SLOT}[profile] ) - ) - wasm-sandbox? ( llvm-core/lld:${LLVM_SLOT} ) - ') - app-alternatives/awk - app-arch/unzip - app-arch/zip - >=dev-util/cbindgen-0.27.0 - net-libs/nodejs - virtual/pkgconfig - amd64? ( >=dev-lang/nasm-2.14 ) - x86? ( >=dev-lang/nasm-2.14 ) - pgo? ( - X? ( - sys-devel/gettext - x11-base/xorg-server[xvfb] - x11-apps/xhost - ) - !X? ( - gui-wm/tinywl - x11-misc/xkeyboard-config - ) - )" -COMMON_DEPEND="${FF_ONLY_DEPEND} - >=app-accessibility/at-spi2-core-2.46.0:2 - dev-libs/expat - dev-libs/glib:2 - dev-libs/libffi:= - >=dev-libs/nss-3.112.2 - >=dev-libs/nspr-4.36 - media-libs/alsa-lib - media-libs/fontconfig - media-libs/freetype - media-libs/mesa - media-video/ffmpeg - virtual/zlib:= - virtual/freedesktop-icon-theme - x11-libs/cairo - x11-libs/gdk-pixbuf:2 - x11-libs/libdrm - x11-libs/pango - x11-libs/pixman - dbus? ( - sys-apps/dbus - ) - jack? ( virtual/jack ) - pulseaudio? ( - || ( - media-libs/libpulse - >=media-sound/apulse-0.1.12-r4[sdk] - ) - ) - libproxy? ( net-libs/libproxy ) - selinux? ( sec-policy/selinux-mozilla ) - sndio? ( >=media-sound/sndio-1.8.0-r1 ) - system-av1? ( - >=media-libs/dav1d-1.0.0:= - >=media-libs/libaom-3.10.0:= - ) - system-harfbuzz? ( - >=media-libs/harfbuzz-2.8.1:0= - !wasm-sandbox? ( >=media-gfx/graphite2-1.3.13 ) - ) - system-icu? ( >=dev-libs/icu-76.1:= ) - system-jpeg? ( >=media-libs/libjpeg-turbo-1.2.1:= ) - system-libevent? ( >=dev-libs/libevent-2.1.12:0=[threads(+)] ) - system-libvpx? ( >=media-libs/libvpx-1.8.2:0=[postproc] ) - system-pipewire? ( >=media-video/pipewire-1.4.7-r2:= ) - system-png? ( >=media-libs/libpng-1.6.45:0=[apng] ) - system-webp? ( >=media-libs/libwebp-1.1.0:0= ) - wayland? ( - >=media-libs/libepoxy-1.5.10-r1 - x11-libs/gtk+:3[wayland] - ) - wifi? ( - kernel_linux? ( - || ( - net-misc/networkmanager - net-misc/connman[networkmanager] - ) - sys-apps/dbus - ) - ) - X? ( - virtual/opengl - x11-libs/cairo[X] - x11-libs/gtk+:3[X] - x11-libs/libX11 - x11-libs/libXcomposite - x11-libs/libXdamage - x11-libs/libXext - x11-libs/libXfixes - x11-libs/libXrandr - x11-libs/libxcb:= - )" -RDEPEND="${COMMON_DEPEND} - hwaccel? ( - media-video/libva-utils - sys-apps/pciutils - ) - jack? ( virtual/jack ) - openh264? ( media-libs/openh264:*[plugin] )" -DEPEND="${COMMON_DEPEND} - X? ( - x11-base/xorg-proto - x11-libs/libICE - x11-libs/libSM - )" - -llvm_check_deps() { - if ! has_version -b "llvm-core/clang:${LLVM_SLOT}" ; then - einfo "llvm-core/clang:${LLVM_SLOT} is missing! Cannot use LLVM slot ${LLVM_SLOT} ..." >&2 - return 1 - fi - - if use clang && ! tc-ld-is-mold ; then - if ! has_version -b "llvm-core/lld:${LLVM_SLOT}" ; then - einfo "llvm-core/lld:${LLVM_SLOT} is missing! Cannot use LLVM slot ${LLVM_SLOT} ..." >&2 - return 1 - fi - fi - - if use pgo ; then - if ! has_version -b "=llvm-runtimes/compiler-rt-sanitizers-${LLVM_SLOT}*[profile]" ; then - einfo "=llvm-runtimes/compiler-rt-sanitizers-${LLVM_SLOT}*[profile] is missing!" >&2 - einfo "Cannot use LLVM slot ${LLVM_SLOT} ..." >&2 - return 1 - fi - fi - - einfo "Using LLVM slot ${LLVM_SLOT} to build" >&2 -} - -MOZ_LANGS=( - af ar ast be bg br ca cak cs cy da de dsb - el en-CA en-GB en-US es-AR es-ES et eu - fi fr fy-NL ga-IE gd gl he hr hsb hu - id is it ja ka kab kk ko lt lv ms nb-NO nl nn-NO - pa-IN pl pt-BR pt-PT rm ro ru - sk sl sq sr sv-SE th tr uk uz vi zh-CN zh-TW -) - -# Firefox-only LANGS -MOZ_LANGS+=( ach ) -MOZ_LANGS+=( an ) -MOZ_LANGS+=( az ) -MOZ_LANGS+=( bn ) -MOZ_LANGS+=( bs ) -MOZ_LANGS+=( ca-valencia ) -MOZ_LANGS+=( eo ) -MOZ_LANGS+=( es-CL ) -MOZ_LANGS+=( es-MX ) -MOZ_LANGS+=( fa ) -MOZ_LANGS+=( ff ) -MOZ_LANGS+=( fur ) -MOZ_LANGS+=( gn ) -MOZ_LANGS+=( gu-IN ) -MOZ_LANGS+=( hi-IN ) -MOZ_LANGS+=( hy-AM ) -MOZ_LANGS+=( ia ) -MOZ_LANGS+=( km ) -MOZ_LANGS+=( kn ) -MOZ_LANGS+=( lij ) -MOZ_LANGS+=( mk ) -MOZ_LANGS+=( mr ) -MOZ_LANGS+=( my ) -MOZ_LANGS+=( ne-NP ) -MOZ_LANGS+=( oc ) -MOZ_LANGS+=( sc ) -MOZ_LANGS+=( sco ) -MOZ_LANGS+=( si ) -MOZ_LANGS+=( skr ) -MOZ_LANGS+=( son ) -MOZ_LANGS+=( szl ) -MOZ_LANGS+=( ta ) -MOZ_LANGS+=( te ) -MOZ_LANGS+=( tl ) -MOZ_LANGS+=( trs ) -MOZ_LANGS+=( ur ) -MOZ_LANGS+=( xh ) - -mozilla_set_globals() { - # https://bugs.gentoo.org/587334 - local MOZ_TOO_REGIONALIZED_FOR_L10N=( - fy-NL ga-IE gu-IN hi-IN hy-AM nb-NO ne-NP nn-NO pa-IN sv-SE - ) - - local lang xflag - for lang in "${MOZ_LANGS[@]}" ; do - # en and en_US are handled internally - if [[ ${lang} == en ]] || [[ ${lang} == en-US ]] ; then - continue - fi - - # strip region subtag if $lang is in the list - if has ${lang} "${MOZ_TOO_REGIONALIZED_FOR_L10N[@]}" ; then - xflag=${lang%%-*} - else - xflag=${lang} - fi - - IUSE+=" l10n_${xflag/[_@]/-}" - done -} -mozilla_set_globals - -moz_clear_vendor_checksums() { - debug-print-function ${FUNCNAME} "$@" - - if [[ ${#} -ne 1 ]] ; then - die "${FUNCNAME} requires exact one argument" - fi - - einfo "Clearing cargo checksums for ${1} ..." - - sed -i \ - -e 's/\("files":{\)[^}]*/\1/' \ - "${S}"/third_party/rust/${1}/.cargo-checksum.json || die -} - -moz_build_xpi() { - debug-print-function ${FUNCNAME} "$@" - - local MOZ_TOO_REGIONALIZED_FOR_L10N=( - fy-NL ga-IE gu-IN hi-IN hy-AM nb-NO ne-NP nn-NO pa-IN sv-SE - ) - - cd "${BUILD_DIR}"/browser/locales || die - local lang xflag - for lang in "${MOZ_LANGS[@]}"; do - # en and en_US are handled internally - if [[ ${lang} == en ]] || [[ ${lang} == en-US ]] ; then - continue - fi - - # strip region subtag if $lang is in the list - if has ${lang} "${MOZ_TOO_REGIONALIZED_FOR_L10N[@]}" ; then - xflag=${lang%%-*} - else - xflag=${lang} - fi - - if use l10n_"${xflag}"; then - emake langpack-"${lang}" LOCALE_MERGEDIR=. - fi - done -} - -moz_install_xpi() { - debug-print-function ${FUNCNAME} "$@" - - if [[ ${#} -lt 2 ]] ; then - die "${FUNCNAME} requires at least two arguments" - fi - - local DESTDIR=${1} - shift - - insinto "${DESTDIR}" - - local emid xpi_file xpi_tmp_dir - for xpi_file in "${@}" ; do - emid= - xpi_tmp_dir=$(mktemp -d --tmpdir="${T}") - - # Unpack XPI - unzip -qq "${xpi_file}" -d "${xpi_tmp_dir}" || die - - # Determine extension ID - if [[ -f "${xpi_tmp_dir}/install.rdf" ]] ; then - emid=$(sed -n -e '/install-manifest/,$ { /em:id/!d; s/.*[\">]\([^\"<>]*\)[\"<].*/\1/; p; q }' "${xpi_tmp_dir}/install.rdf") - [[ -z "${emid}" ]] && die "failed to determine extension id from install.rdf" - elif [[ -f "${xpi_tmp_dir}/manifest.json" ]] ; then - emid=$(sed -n -e 's/.*"id": "\([^"]*\)".*/\1/p' "${xpi_tmp_dir}/manifest.json") - [[ -z "${emid}" ]] && die "failed to determine extension id from manifest.json" - else - die "failed to determine extension id" - fi - - einfo "Installing ${emid}.xpi into ${ED}${DESTDIR} ..." - newins "${xpi_file}" "${emid}.xpi" - done -} - -mozconfig_add_options_ac() { - debug-print-function ${FUNCNAME} "$@" - - if [[ ${#} -lt 2 ]] ; then - die "${FUNCNAME} requires at least two arguments" - fi - - local reason=${1} - shift - - local option - for option in ${@} ; do - echo "ac_add_options ${option} # ${reason}" >>${MOZCONFIG} - done -} - -mozconfig_add_options_mk() { - debug-print-function ${FUNCNAME} "$@" - - if [[ ${#} -lt 2 ]] ; then - die "${FUNCNAME} requires at least two arguments" - fi - - local reason=${1} - shift - - local option - for option in ${@} ; do - echo "mk_add_options ${option} # ${reason}" >>${MOZCONFIG} - done -} - -mozconfig_use_enable() { - debug-print-function ${FUNCNAME} "$@" - - if [[ ${#} -lt 1 ]] ; then - die "${FUNCNAME} requires at least one arguments" - fi - - local flag=$(use_enable "${@}") - mozconfig_add_options_ac "$(use ${1} && echo +${1} || echo -${1})" "${flag}" -} - -mozconfig_use_with() { - debug-print-function ${FUNCNAME} "$@" - - if [[ ${#} -lt 1 ]] ; then - die "${FUNCNAME} requires at least one arguments" - fi - - local flag=$(use_with "${@}") - mozconfig_add_options_ac "$(use ${1} && echo +${1} || echo -${1})" "${flag}" -} - -virtwl() { - debug-print-function ${FUNCNAME} "$@" - - [[ $# -lt 1 ]] && die "${FUNCNAME} needs at least one argument" - [[ -n $XDG_RUNTIME_DIR ]] || die "${FUNCNAME} needs XDG_RUNTIME_DIR to be set; try xdg_environment_reset" - tinywl -h >/dev/null || die 'tinywl -h failed' - - local VIRTWL VIRTWL_PID - coproc VIRTWL { WLR_BACKENDS=headless exec tinywl -s 'echo $WAYLAND_DISPLAY; read _; kill $PPID'; } - local -x WAYLAND_DISPLAY - read WAYLAND_DISPLAY <&${VIRTWL[0]} - - debug-print "${FUNCNAME}: $@" - "$@" - local r=$? - - [[ -n $VIRTWL_PID ]] || die "tinywl exited unexpectedly" - exec {VIRTWL[0]}<&- {VIRTWL[1]}>&- - return $r -} - -pkg_pretend() { - if [[ ${MERGE_TYPE} != binary ]] ; then - # Ensure we have enough disk space to compile - if use pgo || use debug ; then - CHECKREQS_DISK_BUILD="14300M" - elif tc-is-lto ; then - CHECKREQS_DISK_BUILD="10600M" - else - CHECKREQS_DISK_BUILD="7400M" - fi - - check-reqs_pkg_pretend - fi -} - -pkg_setup() { - - # Get LTO from environment; export after this phase for use in src_configure (etc) - use_lto=no - - if [[ ${MERGE_TYPE} != binary ]] ; then - - if tc-is-lto; then - use_lto=yes - # LTO is handled via configure - filter-lto - fi - - if use pgo ; then - if ! has userpriv ${FEATURES} ; then - eerror "Building ${PN} with USE=pgo and FEATURES=-userpriv is not supported!" - fi - fi - - if [[ ${use_lto} = yes ]]; then - # -Werror=lto-type-mismatch -Werror=odr are going to fail with GCC, - # bmo#1516758, bgo#942288 - filter-flags -Werror=lto-type-mismatch -Werror=odr - fi - - # Ensure we have enough disk space to compile - if use pgo || use debug ; then - CHECKREQS_DISK_BUILD="14300M" - elif [[ ${use_lto} == "yes" ]] ; then - CHECKREQS_DISK_BUILD="10600M" - else - CHECKREQS_DISK_BUILD="7400M" - fi - - check-reqs_pkg_setup - llvm-r1_pkg_setup - rust_pkg_setup - python-any-r1_pkg_setup - - # Avoid PGO profiling problems due to enviroment leakage - # These should *always* be cleaned up anyway - unset \ - DBUS_SESSION_BUS_ADDRESS \ - DISPLAY \ - ORBIT_SOCKETDIR \ - SESSION_MANAGER \ - XAUTHORITY \ - XDG_CACHE_HOME \ - XDG_SESSION_COOKIE - - # Build system is using /proc/self/oom_score_adj, bug #604394 - addpredict /proc/self/oom_score_adj - - if use pgo ; then - # Update 105.0: "/proc/self/oom_score_adj" isn't enough anymore with pgo, but not sure - # whether that's due to better OOM handling by Firefox (bmo#1771712), or portage - # (PORTAGE_SCHEDULING_POLICY) update... - addpredict /proc - - # Clear tons of conditions, since PGO is hardware-dependant. - addpredict /dev - fi - - if ! mountpoint -q /dev/shm ; then - # If /dev/shm is not available, configure is known to fail with - # a traceback report referencing /usr/lib/pythonN.N/multiprocessing/synchronize.py - ewarn "/dev/shm is not mounted -- expect build failures!" - fi - - # Ensure we use C locale when building, bug #746215 - export LC_ALL=C - fi - - export use_lto - - CONFIG_CHECK="~SECCOMP" - WARNING_SECCOMP="CONFIG_SECCOMP not set! This system will be unable to play DRM-protected content." - linux-info_pkg_setup -} - -src_prepare() { - if [[ ${use_lto} == "yes" ]]; then - rm -v "${WORKDIR}"/firefox-patches/*-LTO-Only-enable-LTO-*.patch || die - fi - - # Workaround for bgo#915651 on musl - if use elibc_glibc ; then - rm -v "${WORKDIR}"/firefox-patches/*bgo-748849-RUST_TARGET_override.patch || die - fi - - # Use modified patch that isn't mangled - for patch in 0013-gcc-lto-pgo-gentoo.patch 0016-bgo-929967-fix-pgo-on-musl.patch; do - cp "${FILESDIR}/${patch}" "${WORKDIR}/firefox-patches/${patch}" || die - done - - eapply "${WORKDIR}/firefox-patches" - use loong && eapply "${WORKDIR}/firefox-loong-patches" - - if use system-icu && has_version ">=dev-libs/icu-78.1"; then - eapply "${FILESDIR}/firefox-146.0.1-icu78.patch" # in 147, bug #967261 - fi - - # Allow user to apply any additional patches without modifing ebuild - eapply_user - - # Make cargo respect MAKEOPTS - export CARGO_BUILD_JOBS="$(makeopts_jobs)" - - # Workaround for bgo#915651 - if ! use elibc_glibc ; then - if use amd64 ; then - export RUST_TARGET="x86_64-unknown-linux-musl" - elif use x86 ; then - export RUST_TARGET="i686-unknown-linux-musl" - elif use arm64 ; then - export RUST_TARGET="aarch64-unknown-linux-musl" - elif use loong; then - # Only the LP64D ABI of LoongArch64 is actively supported among - # the wider Linux ecosystem, so the assumption is safe. - export RUST_TARGET="loongarch64-unknown-linux-musl" - elif use ppc64 ; then - export RUST_TARGET="powerpc64le-unknown-linux-musl" - elif use riscv ; then - # We can pretty safely rule out any 32-bit riscvs, but 64-bit riscvs also have tons of - # different ABIs available. riscv64gc-unknown-linux-musl seems to be the best working - # guess right now though. - elog "riscv detected, forcing a riscv64 target for now." - export RUST_TARGET="riscv64gc-unknown-linux-musl" - else - die "Unknown musl chost, please post a new bug with your rustc -vV along with emerge --info" - fi - fi - - # Pre-built wasm-sandbox path manipulation. - if use wasm-sandbox ; then - if use amd64 ; then - export wasi_arch="x86_64" - elif use arm64 ; then - export wasi_arch="arm64" - else - die "wasm-sandbox enabled on unknown/unsupported arch!" - fi - - sed -i \ - -e "s:%%PORTAGE_WORKDIR%%:${WORKDIR}:" \ - -e "s:%%WASI_ARCH%%:${wasi_arch}:" \ - -e "s:%%WASI_SDK_VER%%:${WASI_SDK_VER}:" \ - -e "s:%%WASI_SDK_LLVM_VER%%:${WASI_SDK_LLVM_VER}:" \ - toolkit/moz.configure || die "Failed to update wasi-related paths." - fi - - # Make LTO respect MAKEOPTS - sed -i -e "s/multiprocessing.cpu_count()/$(makeopts_jobs)/" \ - "${S}"/build/moz.configure/lto-pgo.configure || die "Failed sedding multiprocessing.cpu_count" - - - sed -i -e "s/multiprocessing.cpu_count()/$(makeopts_jobs)/" \ - "${S}"/third_party/chromium/build/toolchain/get_cpu_count.py || die "Failed sedding multiprocessing.cpu_count" - - sed -i -e "s/multiprocessing.cpu_count()/$(makeopts_jobs)/" \ - "${S}"/third_party/python/gyp/pylib/gyp/input.py || die "Failed sedding multiprocessing.cpu_count" - - # sed-in toolchain prefix - sed -i \ - -e "s/objdump/${CHOST}-objdump/" \ - "${S}"/python/mozbuild/mozbuild/configure/check_debug_ranges.py || die "sed failed to set toolchain prefix" - - sed -i \ - -e 's/ccache_stats = None/return None/' \ - "${S}"/python/mozbuild/mozbuild/controller/building.py || die "sed failed to disable ccache stats call" - - einfo "Removing pre-built binaries ..." - - find "${S}"/third_party -type f \( -name '*.so' -o -name '*.o' \) -print -delete || die - - # Clear checksums from cargo crates we've manually patched. - # moz_clear_vendor_checksums xyz - - # Respect choice for "jumbo-build" - # Changing the value for FILES_PER_UNIFIED_FILE may not work, see #905431 - if [[ -n ${FILES_PER_UNIFIED_FILE} ]] && use jumbo-build; then - local my_files_per_unified_file=${FILES_PER_UNIFIED_FILE:=16} - elog "" - elog "jumbo-build defaults modified to ${my_files_per_unified_file}." - elog "if you get a build failure, try undefining FILES_PER_UNIFIED_FILE," - elog "if that fails try -jumbo-build before opening a bug report." - elog "" - - sed -i -e "s/\"FILES_PER_UNIFIED_FILE\", 16/\"FILES_PER_UNIFIED_FILE\", "${my_files_per_unified_file}"/" \ - python/mozbuild/mozbuild/frontend/data.py || - die "Failed to adjust FILES_PER_UNIFIED_FILE in python/mozbuild/mozbuild/frontend/data.py" - sed -i -e "s/FILES_PER_UNIFIED_FILE = 6/FILES_PER_UNIFIED_FILE = "${my_files_per_unified_file}"/" \ - js/src/moz.build || - die "Failed to adjust FILES_PER_UNIFIED_FILE in js/src/moz.build" - fi - - # Create build dir - BUILD_DIR="${WORKDIR}/${PN}_build" - mkdir -p "${BUILD_DIR}" || die - - xdg_environment_reset -} - -src_configure() { - # Show flags set at the beginning - einfo "Current BINDGEN_CFLAGS:\t${BINDGEN_CFLAGS:-no value set}" - einfo "Current CFLAGS:\t\t${CFLAGS:-no value set}" - einfo "Current CXXFLAGS:\t\t${CXXFLAGS:-no value set}" - einfo "Current LDFLAGS:\t\t${LDFLAGS:-no value set}" - einfo "Current RUSTFLAGS:\t\t${RUSTFLAGS:-no value set}" - - local have_switched_compiler= - if use clang; then - # Force clang - einfo "Enforcing the use of clang due to USE=clang ..." - - local version_clang=$(clang --version 2>/dev/null | grep -F -- 'clang version' | awk '{ print $3 }') - [[ -n ${version_clang} ]] && version_clang=$(ver_cut 1 "${version_clang}") - [[ -z ${version_clang} ]] && die "Failed to read clang version!" - - if tc-is-gcc; then - have_switched_compiler=yes - fi - - AR=llvm-ar - CC=${CHOST}-clang-${version_clang} - CXX=${CHOST}-clang++-${version_clang} - NM=llvm-nm - RANLIB=llvm-ranlib - - elif ! use clang && ! tc-is-gcc ; then - # Force gcc - have_switched_compiler=yes - einfo "Enforcing the use of gcc due to USE=-clang ..." - AR=gcc-ar - CC=${CHOST}-gcc - CXX=${CHOST}-g++ - NM=gcc-nm - RANLIB=gcc-ranlib - fi - - if [[ -n "${have_switched_compiler}" ]] ; then - # Because we switched active compiler we have to ensure - # that no unsupported flags are set - strip-unsupported-flags - fi - - # Ensure we use correct toolchain, - # AS is used in a non-standard way by upstream, #bmo1654031 - export HOST_CC="$(tc-getBUILD_CC)" - export HOST_CXX="$(tc-getBUILD_CXX)" - export AS="$(tc-getCC) -c" - - # Configuration tests expect llvm-readelf output, bug 913130 - READELF="llvm-readelf" - - tc-export CC CXX LD AR AS NM OBJDUMP RANLIB READELF PKG_CONFIG - - # Pass the correct toolchain paths through cbindgen - if tc-is-cross-compiler ; then - export BINDGEN_CFLAGS="${SYSROOT:+--sysroot=${ESYSROOT}} --target=${CHOST} ${BINDGEN_CFLAGS-}" - fi - - # Set MOZILLA_FIVE_HOME - export MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}" - - # python/mach/mach/mixin/process.py fails to detect SHELL - export SHELL="${EPREFIX}/bin/bash" - - # Set state path - export MOZBUILD_STATE_PATH="${BUILD_DIR}" - - # Set MOZCONFIG - export MOZCONFIG="${S}/.mozconfig" - - # Initialize MOZCONFIG - mozconfig_add_options_ac '' --enable-application=browser - mozconfig_add_options_ac '' --enable-project=browser - - # Set Gentoo defaults - mozconfig_add_options_ac 'Gentoo default' \ - --allow-addon-sideload \ - --disable-cargo-incremental \ - --disable-crashreporter \ - --disable-disk-remnant-avoidance \ - --disable-geckodriver \ - --disable-install-strip \ - --disable-legacy-profile-creation \ - --disable-parental-controls \ - --disable-strip \ - --disable-updater \ - --disable-wmf \ - --enable-negotiateauth \ - --enable-new-pass-manager \ - --enable-official-branding \ - --enable-packed-relative-relocs \ - --enable-release \ - --enable-system-policies \ - --host="${CBUILD:-${CHOST}}" \ - --libdir="${EPREFIX}/usr/$(get_libdir)" \ - --prefix="${EPREFIX}/usr" \ - --target="${CHOST}" \ - --without-ccache \ - --with-intl-api \ - --with-l10n-base="${S}/l10n" \ - --with-libclang-path="$(llvm-config --libdir)" \ - --with-system-ffi \ - --with-system-gbm \ - --with-system-libdrm \ - --with-system-nspr \ - --with-system-nss \ - --with-system-pixman \ - --with-system-zlib \ - --with-toolchain-prefix="${CHOST}-" \ - --with-unsigned-addon-scopes=app,system - - # Whitelist to allow unkeyworded arches to build with "--disable-rust-simd" by default. - if use amd64 || use arm64 || use ppc64 || use loong || use riscv ; then - mozconfig_add_options_ac '' --enable-rust-simd - fi - - # For future keywording: This is currently (97.0) only supported on: - # amd64, arm, arm64 & x86. - # Might want to flip the logic around if Firefox is to support more arches. - # bug 833001, bug 903411#c8 - if use loong || use ppc64 || use riscv; then - mozconfig_add_options_ac '' --disable-sandbox - else - mozconfig_add_options_ac '' --enable-sandbox - fi - - # riscv-related options, bgo#947337, bgo#947338 - if use riscv ; then - mozconfig_add_options_ac 'Disable JIT for RISC-V 64' --disable-jit - mozconfig_add_options_ac 'Disable webrtc for RISC-V' --disable-webrtc - fi - - mozconfig_use_with system-av1 - mozconfig_use_with system-harfbuzz - mozconfig_use_with system-icu - mozconfig_use_with system-jpeg - mozconfig_use_with system-libevent - mozconfig_use_with system-libvpx - mozconfig_use_with system-pipewire - mozconfig_use_with system-png - mozconfig_use_with system-webp - - mozconfig_use_enable dbus - mozconfig_use_enable libproxy - - # --disable-eme is only supported on x86 and x86-64 - if use amd64 || use x86 ; then - mozconfig_add_options_ac '' --disable-eme - fi - - if use hardened ; then - mozconfig_add_options_ac "+hardened" --enable-hardening - append-ldflags "-Wl,-z,relro -Wl,-z,now" - - # Increase the FORTIFY_SOURCE value, #910071. - sed -i -e '/-D_FORTIFY_SOURCE=/s:2:3:' "${S}"/build/moz.configure/toolchain.configure || die - fi - - local myaudiobackends="" - use jack && myaudiobackends+="jack," - use sndio && myaudiobackends+="sndio," - use pulseaudio && myaudiobackends+="pulseaudio," - ! use pulseaudio && myaudiobackends+="alsa," - - mozconfig_add_options_ac '--enable-audio-backends' --enable-audio-backends="${myaudiobackends::-1}" - - mozconfig_use_enable wifi necko-wifi - - ! use jumbo-build && mozconfig_add_options_ac '--disable-unified-build' --disable-unified-build - - if use X && use wayland ; then - mozconfig_add_options_ac '+x11+wayland' --enable-default-toolkit=cairo-gtk3-x11-wayland - elif ! use X && use wayland ; then - mozconfig_add_options_ac '+wayland' --enable-default-toolkit=cairo-gtk3-wayland-only - else - mozconfig_add_options_ac '+x11' --enable-default-toolkit=cairo-gtk3-x11-only - fi - - # wasm-sandbox - # Since graphite2 is one of the sandboxed libraries, system-graphite2 obviously can't work with +wasm-sandbox. - if use wasm-sandbox ; then - mozconfig_add_options_ac '+wasm-sandbox' --with-wasi-sysroot="${WORKDIR}/wasi-sdk-${WASI_SDK_VER}-${wasi_arch}-linux/share/wasi-sysroot/" - else - mozconfig_add_options_ac 'no wasm-sandbox' --without-wasm-sandboxed-libraries - mozconfig_use_with system-harfbuzz system-graphite2 - fi - - if [[ ${use_lto} == "yes" ]] ; then - if use clang ; then - # Upstream only supports lld or mold when using clang. - if tc-ld-is-mold ; then - # mold expects the -flto line from *FLAGS configuration, bgo#923119 - append-ldflags "-flto=thin" - mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker=mold - else - mozconfig_add_options_ac "forcing ld=lld due to USE=clang and USE=lto" --enable-linker=lld - fi - - mozconfig_add_options_ac '+lto' --enable-lto=cross - - else - # ThinLTO is currently broken, see bmo#1644409. - # mold does not support gcc+lto combination. - mozconfig_add_options_ac '+lto' --enable-lto=full - mozconfig_add_options_ac "linker is set to bfd" --enable-linker=bfd - fi - else - # Avoid auto-magic on linker - if use clang ; then - # lld is upstream's default - if tc-ld-is-mold ; then - mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker=mold - else - mozconfig_add_options_ac "forcing ld=lld due to USE=clang" --enable-linker=lld - fi - - else - if tc-ld-is-mold ; then - mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker=mold - else - mozconfig_add_options_ac "linker is set to bfd due to USE=-clang" --enable-linker=bfd - fi - fi - fi - - # PGO was moved outside lto block to allow building pgo without lto. - if use pgo ; then - mozconfig_add_options_ac '+pgo' MOZ_PGO=1 - - # Avoid compressing just-built instrumented Firefox with - # high levels of compression. Just use tar as a container - # to save >=10 minutes. - export MOZ_PKG_FORMAT=tar - - if use clang ; then - # Used in build/pgo/profileserver.py - export LLVM_PROFDATA="llvm-profdata" - fi - fi - - mozconfig_use_enable debug - if use debug ; then - mozconfig_add_options_ac '+debug' --disable-optimize - mozconfig_add_options_ac '+debug' --enable-jemalloc - mozconfig_add_options_ac '+debug' --enable-real-time-tracing - else - mozconfig_add_options_ac 'Gentoo defaults' --disable-real-time-tracing - - if is-flag '-g*' ; then - if use clang ; then - mozconfig_add_options_ac 'from CFLAGS' --enable-debug-symbols=$(get-flag '-g*') - else - mozconfig_add_options_ac 'from CFLAGS' --enable-debug-symbols - fi - else - mozconfig_add_options_ac 'Gentoo default' --disable-debug-symbols - fi - - if is-flag '-O0' ; then - mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-O0 - elif is-flag '-O4' ; then - mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-O4 - elif is-flag '-O3' ; then - mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-O3 - elif is-flag '-O1' ; then - mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-O1 - elif is-flag '-Os' ; then - mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-Os - else - mozconfig_add_options_ac "Gentoo default" --enable-optimize=-O2 - fi - fi - - # Debug flag was handled via configure - filter-flags '-g*' - - # Optimization flag was handled via configure - filter-flags '-O*' - - # elf-hack - # Filter "-z,pack-relative-relocs" and let the build system handle it instead. - if use amd64 || use x86 ; then - filter-flags "-z,pack-relative-relocs" - - if tc-ld-is-mold ; then - # relr-elf-hack is currently broken with mold, bgo#916259 - mozconfig_add_options_ac 'disable elf-hack with mold linker' --disable-elf-hack - else - mozconfig_add_options_ac 'relr elf-hack' --enable-elf-hack=relr - fi - elif use loong || use ppc64 || use riscv ; then - # '--disable-elf-hack' is not recognized on loong/ppc64/riscv, - # see bgo #917049, #930046 - :; - else - mozconfig_add_options_ac 'disable elf-hack on non-supported arches' --disable-elf-hack - fi - - if ! use elibc_glibc; then - mozconfig_add_options_ac '!elibc_glibc' --disable-jemalloc - fi - - # System-av1 fix - use system-av1 && append-ldflags "-Wl,--undefined-version" - - # Make revdep-rebuild.sh happy; Also required for musl - append-ldflags -Wl,-rpath="${MOZILLA_FIVE_HOME}",--enable-new-dtags - - # Pass $MAKEOPTS to build system - export MOZ_MAKE_FLAGS="${MAKEOPTS}" - - # Use system's Python environment - export PIP_NETWORK_INSTALL_RESTRICTED_VIRTUALENVS=mach - - export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE="none" - - mozconfig_use_enable test tests - - # Disable notification when build system has finished - export MOZ_NOSPAM=1 - - # Portage sets XARGS environment variable to "xargs -r" by default which - # breaks build system's check_prog() function which doesn't support arguments - mozconfig_add_options_ac 'Gentoo default' "XARGS=${EPREFIX}/usr/bin/xargs" - - # Set build dir - mozconfig_add_options_mk 'Gentoo default' "MOZ_OBJDIR=${BUILD_DIR}" - - # Show flags we will use - einfo "Build BINDGEN_CFLAGS:\t${BINDGEN_CFLAGS:-no value set}" - einfo "Build CFLAGS:\t\t${CFLAGS:-no value set}" - einfo "Build CXXFLAGS:\t\t${CXXFLAGS:-no value set}" - einfo "Build LDFLAGS:\t\t${LDFLAGS:-no value set}" - einfo "Build RUSTFLAGS:\t\t${RUSTFLAGS:-no value set}" - - # Handle EXTRA_CONF and show summary - local ac opt hash reason - - # Apply EXTRA_ECONF entries to $MOZCONFIG - if [[ -n ${EXTRA_ECONF} ]] ; then - IFS=\! read -a ac <<<${EXTRA_ECONF// --/\!} - for opt in "${ac[@]}"; do - mozconfig_add_options_ac "EXTRA_ECONF" --${opt#--} - done - fi - - echo - echo "==========================================================" - echo "Building ${PF} with the following configuration" - grep ^ac_add_options "${MOZCONFIG}" | while read ac opt hash reason; do - [[ -z ${hash} || ${hash} == \# ]] \ - || die "error reading mozconfig: ${ac} ${opt} ${hash} ${reason}" - printf " %-30s %s\n" "${opt}" "${reason:-mozilla.org default}" - done - echo "==========================================================" - echo - - ./mach configure || die -} - -src_compile() { - local virtx_cmd= - - if [[ ${use_lto} == "yes" ]] && tc-ld-is-mold ; then - # increase ulimit with mold+lto, bugs #892641, #907485 - if ! ulimit -n 16384 1>/dev/null 2>&1 ; then - ewarn "Unable to modify ulimits - building with mold+lto might fail due to low ulimit -n resources." - ewarn "Please see bugs #892641 & #907485." - else - ulimit -n 16384 - fi - fi - - if use pgo; then - # Reset and cleanup environment variables used by GNOME/XDG - gnome2_environment_reset - - addpredict /root - - if ! use X; then - virtx_cmd=virtwl - else - virtx_cmd=virtx - fi - fi - - if ! use X; then - local -x GDK_BACKEND=wayland - else - local -x GDK_BACKEND=x11 - fi - - ${virtx_cmd} ./mach build --verbose || die - - # Build language packs - moz_build_xpi -} - -src_test() { - # https://firefox-source-docs.mozilla.org/testing/automated-testing/index.html - local -a failures=() - - # Some tests respect this - local -x MOZ_HEADLESS=1 - - # Check testing/mach_commands.py - einfo "Testing with cppunittest ..." - ./mach cppunittest - local ret=$? - if [[ ${ret} -ne 0 ]]; then - eerror "Test suite cppunittest failed with error code ${ret}" - failures+=( cppunittest ) - fi - - if [[ ${#failures} -eq 0 ]]; then - einfo "Test suites succeeded" - else - die "Test suites failed: ${failures[@]}" - fi -} - -src_install() { - # xpcshell is getting called during install - pax-mark m \ - "${BUILD_DIR}"/dist/bin/xpcshell \ - "${BUILD_DIR}"/dist/bin/${PN} \ - "${BUILD_DIR}"/dist/bin/plugin-container - - DESTDIR="${D}" ./mach install || die - - # Upstream cannot ship symlink but we can (bmo#658850) - rm "${ED}${MOZILLA_FIVE_HOME}/${PN}-bin" || die - dosym ${PN} ${MOZILLA_FIVE_HOME}/${PN}-bin - - # Don't install llvm-symbolizer from llvm-core/llvm package - if [[ -f "${ED}${MOZILLA_FIVE_HOME}/llvm-symbolizer" ]] ; then - rm -v "${ED}${MOZILLA_FIVE_HOME}/llvm-symbolizer" || die - fi - - # Install policy (currently only used to disable application updates) - insinto "${MOZILLA_FIVE_HOME}/distribution" - newins "${FILESDIR}"/distribution.ini distribution.ini - newins "${FILESDIR}"/disable-auto-update.policy.json policies.json - - # Install system-wide preferences - local PREFS_DIR="${MOZILLA_FIVE_HOME}/browser/defaults/preferences" - insinto "${PREFS_DIR}" - newins "${FILESDIR}"/gentoo-default-prefs.js gentoo-prefs.js - - local GENTOO_PREFS="${ED}${PREFS_DIR}/gentoo-prefs.js" - - # Set dictionary path to use system hunspell - cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set spellchecker.dictionary_path pref" - pref("spellchecker.dictionary_path", "${EPREFIX}/usr/share/myspell"); - EOF - - # Force hwaccel prefs if USE=hwaccel is enabled - if use hwaccel ; then - cat "${FILESDIR}"/gentoo-hwaccel-prefs.js-r2 \ - >>"${GENTOO_PREFS}" \ - || die "failed to add prefs to force hardware-accelerated rendering to all-gentoo.js" - - if use wayland; then - cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set hwaccel wayland prefs" - pref("gfx.x11-egl.force-enabled", false); - EOF - else - cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set hwaccel x11 prefs" - pref("gfx.x11-egl.force-enabled", true); - EOF - fi - - # Install the vaapitest binary on supported arches (122.0 supports all platforms, bmo#1865969) - exeinto "${MOZILLA_FIVE_HOME}" - doexe "${BUILD_DIR}"/dist/bin/vaapitest - - # Install the v4l2test on supported arches (+ arm, + riscv64 when keyworded) - if use arm64 ; then - exeinto "${MOZILLA_FIVE_HOME}" - doexe "${BUILD_DIR}"/dist/bin/v4l2test - fi - fi - - # Force the graphite pref if USE=system-harfbuzz is enabled, since the pref cannot disable it - if use system-harfbuzz ; then - cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set gfx.font_rendering.graphite.enabled pref" - sticky_pref("gfx.font_rendering.graphite.enabled", true); - EOF - fi - - # Install language packs - local langpacks=( $(find "${BUILD_DIR}"/dist/linux-x86_64/xpi -type f -name '*.xpi') ) - if [[ -n "${langpacks}" ]] ; then - moz_install_xpi "${MOZILLA_FIVE_HOME}/distribution/extensions" "${langpacks[@]}" - fi - - # Install icons - local icon_srcdir="${S}/browser/branding/official" - - insinto /usr/share/icons/hicolor/symbolic/apps - newins "${FILESDIR}/icon/icecat-symbolic.svg" icecat-symbolic.svg - - local icon size - for icon in "${icon_srcdir}"/default*.png ; do - size=${icon%.png} - size=${size##*/default} - - if [[ ${size} -eq 48 ]] ; then - newicon "${icon}" ${PN}.png - fi - - newicon -s ${size} "${icon}" ${PN}.png - done - - # Install menu - local app_name="GNU IceCat" - local desktop_file="${FILESDIR}/icon/${PN}-r3.desktop" - local exec_command="${PN}" - local icon="${PN}" - local use_wayland="false" - - if use wayland ; then - use_wayland="true" - fi - - cp "${desktop_file}" "${WORKDIR}/${PN}.desktop-template" || die - - sed -i \ - -e "s:@NAME@:${app_name}:" \ - -e "s:@EXEC@:${exec_command}:" \ - -e "s:@ICON@:${icon}:" \ - "${WORKDIR}/${PN}.desktop-template" || die - - newmenu "${WORKDIR}/${PN}.desktop-template" icecat.desktop - - rm "${WORKDIR}/${PN}.desktop-template" || die - - if use gnome-shell ; then - # Install search provider for Gnome - insinto /usr/share/gnome-shell/search-providers/ - doins browser/components/shell/search-provider-files/org.gnu.icecat.search-provider.ini - - insinto /usr/share/dbus-1/services/ - doins browser/components/shell/search-provider-files/org.gnu.icecat.SearchProvider.service - - # Make the dbus service aware of a previous session, bgo#939196 - sed -e \ - "s/Exec=\/usr\/bin\/icecat/Exec=\/usr\/$(get_libdir)\/icecat\/icecat --dbus-service \/usr\/bin\/icecat/g" \ - -i "${ED}/usr/share/dbus-1/services/org.gnu.icecat.SearchProvider.service" || - die "Failed to sed org.gnu.icecat.SearchProvider.service dbus file" - - # Update prefs to enable Gnome search provider - cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to enable gnome-search-provider via prefs" - pref("browser.gnome-search-provider.enabled", true); - EOF - fi - - # Install wrapper script - [[ -f "${ED}/usr/bin/${PN}" ]] && rm "${ED}/usr/bin/${PN}" - newbin "${FILESDIR}/${PN}-r1.sh" ${PN} - - # Update wrapper - sed -i \ - -e "s:@PREFIX@:${EPREFIX}/usr:" \ - -e "s:@DEFAULT_WAYLAND@:${use_wayland}:" \ - "${ED}/usr/bin/${PN}" || die - - readme.gentoo_create_doc -} - -pkg_postinst() { - xdg_pkg_postinst - - elog "Cloudflare browser checks are broken with GNU IceCats anti fingerprinting measures." - elog "You can fix cloudflare browser checks by undoing them in about:config like below:" - # Specifying (X11) is necessary for it to work, even in a Wayland session - elog " general.appversion.override: ${PV%.[0-9]*} (X11)" - elog " general.oscpu.override: Linux x86_64" - elog " general.platform.override: Linux x86_64" - - # bug 835078 - if use hwaccel && has_version "x11-drivers/xf86-video-nouveau"; then - ewarn "You have nouveau drivers installed in your system and 'hwaccel' " - ewarn "enabled for Firefox. Nouveau / your GPU might not support the " - ewarn "required EGL, so either disable 'hwaccel' or try the workaround " - ewarn "explained in https://bugs.gentoo.org/835078#c5 if Firefox crashes." - fi - - readme.gentoo_print_elog - - optfeature_header "Optional programs for extra features:" - optfeature "desktop notifications" x11-libs/libnotify - optfeature "fallback mouse cursor theme e.g. on WMs" gnome-base/gsettings-desktop-schemas - optfeature "screencasting with pipewire" sys-apps/xdg-desktop-portal - if use hwaccel && has_version "x11-drivers/nvidia-drivers"; then - optfeature "hardware acceleration with NVIDIA cards" media-libs/nvidia-vaapi-driver - fi - - if ! has_version "sys-libs/glibc"; then - elog - elog "glibc not found! You won't be able to play DRM content." - elog "See Gentoo bug #910309 or upstream bug #1843683." - elog - fi -} diff --git a/www-client/icecat/icecat-140.7.0.ebuild b/www-client/icecat/icecat-140.7.0.ebuild deleted file mode 100644 index 80460e6..0000000 --- a/www-client/icecat/icecat-140.7.0.ebuild +++ /dev/null @@ -1,1264 +0,0 @@ -# Copyright 1999-2026 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -# Ebuild is based on the Firefox ebuilds in the main repo - -EAPI=8 - -# Using Gentoos firefox patches as system libraries and lto are quite nice -FIREFOX_PATCHSET="firefox-140esr-patches-05.tar.xz" -FIREFOX_LOONG_PATCHSET="firefox-139-loong-patches-02.tar.xz" - -LLVM_COMPAT=( 19 20 21 ) - -# This will also filter rust versions that don't match LLVM_COMPAT in the non-clang path; this is fine. -RUST_NEEDS_LLVM=1 -# If not building with clang we need at least rust 1.76 -RUST_MIN_VER=1.82.0 - -PYTHON_COMPAT=( python3_{11..14} ) -PYTHON_REQ_USE="ncurses,sqlite,ssl" - -VIRTUALX_REQUIRED="manual" - -# Information about the bundled wasi toolchain from -# https://github.com/WebAssembly/wasi-sdk/ -WASI_SDK_VER=28.0 -WASI_SDK_LLVM_VER=21 - -inherit check-reqs desktop flag-o-matic gnome2-utils linux-info llvm-r1 multiprocessing \ - optfeature pax-utils python-any-r1 readme.gentoo-r1 rust toolchain-funcs unpacker virtualx xdg - -DESCRIPTION="GNU IceCat Web Browser" -HOMEPAGE="https://www.gnu.org/software/gnuzilla/" - -PATCH_URIS=( - https://dev.gentoo.org/~juippis/mozilla/patchsets/${FIREFOX_PATCHSET} -) - -# Icecat tarball generated from https://cgit.git.savannah.gnu.org/cgit/gnuzilla.git -# Script modified to output zstd tarballs due to size and unpacking speed considerations. -ICECAT_REV="1gnu1" - -SRC_URI=" - https://gitlab.com/api/v4/projects/32909921/packages/generic/${PN}/${PV}-${ICECAT_REV}/${P}-${ICECAT_REV}.tar.zst - ${PATCH_URIS[@]} - loong? ( - https://dev.gentoo.org/~xen0n/distfiles/www-client/firefox/${FIREFOX_LOONG_PATCHSET} - ) - wasm-sandbox? ( - amd64? ( https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VER/.*/}/wasi-sdk-${WASI_SDK_VER}-x86_64-linux.tar.gz ) - arm64? ( https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VER/.*/}/wasi-sdk-${WASI_SDK_VER}-arm64-linux.tar.gz ) - )" -S="${WORKDIR}/${PN}-${PV%_*}" -LICENSE="MPL-2.0 GPL-2 LGPL-2.1" -SLOT="0" -KEYWORDS="amd64" - -IUSE="+clang dbus debug hardened hwaccel jack libproxy pgo pulseaudio selinux sndio" -IUSE+=" +system-av1 +system-harfbuzz +system-icu +system-jpeg +system-libevent +system-libvpx" -IUSE+=" system-pipewire system-png +system-webp test wayland wifi +X" - -# Firefox-only IUSE -IUSE+=" gnome-shell +jumbo-build openh264 wasm-sandbox" - -REQUIRED_USE="|| ( X wayland ) - debug? ( !system-av1 ) - pgo? ( jumbo-build ) - wayland? ( dbus ) - wifi? ( dbus ) -" - -RESTRICT="!test? ( test )" - -FF_ONLY_DEPEND="selinux? ( sec-policy/selinux-mozilla )" -BDEPEND="${PYTHON_DEPS} - $(unpacker_src_uri_depends) - $(llvm_gen_dep ' - llvm-core/clang:${LLVM_SLOT} - llvm-core/llvm:${LLVM_SLOT} - clang? ( - llvm-core/lld:${LLVM_SLOT} - pgo? ( llvm-runtimes/compiler-rt-sanitizers:${LLVM_SLOT}[profile] ) - ) - wasm-sandbox? ( llvm-core/lld:${LLVM_SLOT} ) - ') - app-alternatives/awk - app-arch/unzip - app-arch/zip - >=dev-util/cbindgen-0.27.0 - net-libs/nodejs - virtual/pkgconfig - amd64? ( >=dev-lang/nasm-2.14 ) - x86? ( >=dev-lang/nasm-2.14 ) - pgo? ( - X? ( - sys-devel/gettext - x11-base/xorg-server[xvfb] - x11-apps/xhost - ) - !X? ( - gui-wm/tinywl - x11-misc/xkeyboard-config - ) - )" -COMMON_DEPEND="${FF_ONLY_DEPEND} - >=app-accessibility/at-spi2-core-2.46.0:2 - dev-libs/glib:2 - dev-libs/libffi:= - >=dev-libs/nss-3.112.2 - >=dev-libs/nspr-4.36 - media-libs/alsa-lib - media-libs/fontconfig - media-libs/freetype - media-libs/mesa - media-video/ffmpeg - virtual/zlib:= - virtual/freedesktop-icon-theme - x11-libs/cairo - x11-libs/gdk-pixbuf:2 - x11-libs/libdrm - x11-libs/pango - x11-libs/pixman - dbus? ( - sys-apps/dbus - ) - jack? ( virtual/jack ) - pulseaudio? ( - || ( - media-libs/libpulse - >=media-sound/apulse-0.1.12-r4[sdk] - ) - ) - libproxy? ( net-libs/libproxy ) - selinux? ( sec-policy/selinux-mozilla ) - sndio? ( >=media-sound/sndio-1.8.0-r1 ) - system-av1? ( - >=media-libs/dav1d-1.0.0:= - >=media-libs/libaom-3.10.0:= - ) - system-harfbuzz? ( - >=media-libs/harfbuzz-2.8.1:0= - !wasm-sandbox? ( >=media-gfx/graphite2-1.3.13 ) - ) - system-icu? ( >=dev-libs/icu-76.1:= ) - system-jpeg? ( >=media-libs/libjpeg-turbo-1.2.1:= ) - system-libevent? ( >=dev-libs/libevent-2.1.12:0=[threads(+)] ) - system-libvpx? ( >=media-libs/libvpx-1.8.2:0=[postproc] ) - system-pipewire? ( >=media-video/pipewire-1.4.7-r2:= ) - system-png? ( >=media-libs/libpng-1.6.45:0=[apng] ) - system-webp? ( >=media-libs/libwebp-1.1.0:0= ) - wayland? ( - >=media-libs/libepoxy-1.5.10-r1 - x11-libs/gtk+:3[wayland] - ) - wifi? ( - kernel_linux? ( - || ( - net-misc/networkmanager - net-misc/connman[networkmanager] - ) - sys-apps/dbus - ) - ) - X? ( - virtual/opengl - x11-libs/cairo[X] - x11-libs/gtk+:3[X] - x11-libs/libX11 - x11-libs/libXcomposite - x11-libs/libXdamage - x11-libs/libXext - x11-libs/libXfixes - x11-libs/libXrandr - x11-libs/libxcb:= - )" -RDEPEND="${COMMON_DEPEND} - hwaccel? ( - media-video/libva-utils - sys-apps/pciutils - ) - jack? ( virtual/jack ) - openh264? ( media-libs/openh264:*[plugin] )" -DEPEND="${COMMON_DEPEND} - X? ( - x11-base/xorg-proto - x11-libs/libICE - x11-libs/libSM - )" - -llvm_check_deps() { - if ! has_version -b "llvm-core/clang:${LLVM_SLOT}" ; then - einfo "llvm-core/clang:${LLVM_SLOT} is missing! Cannot use LLVM slot ${LLVM_SLOT} ..." >&2 - return 1 - fi - - if use clang && ! tc-ld-is-mold ; then - if ! has_version -b "llvm-core/lld:${LLVM_SLOT}" ; then - einfo "llvm-core/lld:${LLVM_SLOT} is missing! Cannot use LLVM slot ${LLVM_SLOT} ..." >&2 - return 1 - fi - fi - - if use pgo ; then - if ! has_version -b "=llvm-runtimes/compiler-rt-sanitizers-${LLVM_SLOT}*[profile]" ; then - einfo "=llvm-runtimes/compiler-rt-sanitizers-${LLVM_SLOT}*[profile] is missing!" >&2 - einfo "Cannot use LLVM slot ${LLVM_SLOT} ..." >&2 - return 1 - fi - fi - - einfo "Using LLVM slot ${LLVM_SLOT} to build" >&2 -} - -MOZ_LANGS=( - af ar ast be bg br ca cak cs cy da de dsb - el en-CA en-GB en-US es-AR es-ES et eu - fi fr fy-NL ga-IE gd gl he hr hsb hu - id is it ja ka kab kk ko lt lv ms nb-NO nl nn-NO - pa-IN pl pt-BR pt-PT rm ro ru - sk sl sq sr sv-SE th tr uk uz vi zh-CN zh-TW -) - -# Firefox-only LANGS -MOZ_LANGS+=( ach ) -MOZ_LANGS+=( an ) -MOZ_LANGS+=( az ) -MOZ_LANGS+=( bn ) -MOZ_LANGS+=( bs ) -MOZ_LANGS+=( ca-valencia ) -MOZ_LANGS+=( eo ) -MOZ_LANGS+=( es-CL ) -MOZ_LANGS+=( es-MX ) -MOZ_LANGS+=( fa ) -MOZ_LANGS+=( ff ) -MOZ_LANGS+=( fur ) -MOZ_LANGS+=( gn ) -MOZ_LANGS+=( gu-IN ) -MOZ_LANGS+=( hi-IN ) -MOZ_LANGS+=( hy-AM ) -MOZ_LANGS+=( ia ) -MOZ_LANGS+=( km ) -MOZ_LANGS+=( kn ) -MOZ_LANGS+=( lij ) -MOZ_LANGS+=( mk ) -MOZ_LANGS+=( mr ) -MOZ_LANGS+=( my ) -MOZ_LANGS+=( ne-NP ) -MOZ_LANGS+=( oc ) -MOZ_LANGS+=( sc ) -MOZ_LANGS+=( sco ) -MOZ_LANGS+=( si ) -MOZ_LANGS+=( skr ) -MOZ_LANGS+=( son ) -MOZ_LANGS+=( szl ) -MOZ_LANGS+=( ta ) -MOZ_LANGS+=( te ) -MOZ_LANGS+=( tl ) -MOZ_LANGS+=( trs ) -MOZ_LANGS+=( ur ) -MOZ_LANGS+=( xh ) - -mozilla_set_globals() { - # https://bugs.gentoo.org/587334 - local MOZ_TOO_REGIONALIZED_FOR_L10N=( - fy-NL ga-IE gu-IN hi-IN hy-AM nb-NO ne-NP nn-NO pa-IN sv-SE - ) - - local lang xflag - for lang in "${MOZ_LANGS[@]}" ; do - # en and en_US are handled internally - if [[ ${lang} == en ]] || [[ ${lang} == en-US ]] ; then - continue - fi - - # strip region subtag if $lang is in the list - if has ${lang} "${MOZ_TOO_REGIONALIZED_FOR_L10N[@]}" ; then - xflag=${lang%%-*} - else - xflag=${lang} - fi - - IUSE+=" l10n_${xflag/[_@]/-}" - done -} -mozilla_set_globals - -moz_clear_vendor_checksums() { - debug-print-function ${FUNCNAME} "$@" - - if [[ ${#} -ne 1 ]] ; then - die "${FUNCNAME} requires exact one argument" - fi - - einfo "Clearing cargo checksums for ${1} ..." - - sed -i \ - -e 's/\("files":{\)[^}]*/\1/' \ - "${S}"/third_party/rust/${1}/.cargo-checksum.json || die -} - -moz_build_xpi() { - debug-print-function ${FUNCNAME} "$@" - - local MOZ_TOO_REGIONALIZED_FOR_L10N=( - fy-NL ga-IE gu-IN hi-IN hy-AM nb-NO ne-NP nn-NO pa-IN sv-SE - ) - - cd "${BUILD_DIR}"/browser/locales || die - local lang xflag - for lang in "${MOZ_LANGS[@]}"; do - # en and en_US are handled internally - if [[ ${lang} == en ]] || [[ ${lang} == en-US ]] ; then - continue - fi - - # strip region subtag if $lang is in the list - if has ${lang} "${MOZ_TOO_REGIONALIZED_FOR_L10N[@]}" ; then - xflag=${lang%%-*} - else - xflag=${lang} - fi - - if use l10n_"${xflag}"; then - emake langpack-"${lang}" LOCALE_MERGEDIR=. - fi - done -} - -moz_install_xpi() { - debug-print-function ${FUNCNAME} "$@" - - if [[ ${#} -lt 2 ]] ; then - die "${FUNCNAME} requires at least two arguments" - fi - - local DESTDIR=${1} - shift - - insinto "${DESTDIR}" - - local emid xpi_file xpi_tmp_dir - for xpi_file in "${@}" ; do - emid= - xpi_tmp_dir=$(mktemp -d --tmpdir="${T}") - - # Unpack XPI - unzip -qq "${xpi_file}" -d "${xpi_tmp_dir}" || die - - # Determine extension ID - if [[ -f "${xpi_tmp_dir}/install.rdf" ]] ; then - emid=$(sed -n -e '/install-manifest/,$ { /em:id/!d; s/.*[\">]\([^\"<>]*\)[\"<].*/\1/; p; q }' "${xpi_tmp_dir}/install.rdf") - [[ -z "${emid}" ]] && die "failed to determine extension id from install.rdf" - elif [[ -f "${xpi_tmp_dir}/manifest.json" ]] ; then - emid=$(sed -n -e 's/.*"id": "\([^"]*\)".*/\1/p' "${xpi_tmp_dir}/manifest.json") - [[ -z "${emid}" ]] && die "failed to determine extension id from manifest.json" - else - die "failed to determine extension id" - fi - - einfo "Installing ${emid}.xpi into ${ED}${DESTDIR} ..." - newins "${xpi_file}" "${emid}.xpi" - done -} - -mozconfig_add_options_ac() { - debug-print-function ${FUNCNAME} "$@" - - if [[ ${#} -lt 2 ]] ; then - die "${FUNCNAME} requires at least two arguments" - fi - - local reason=${1} - shift - - local option - for option in ${@} ; do - echo "ac_add_options ${option} # ${reason}" >>${MOZCONFIG} - done -} - -mozconfig_add_options_mk() { - debug-print-function ${FUNCNAME} "$@" - - if [[ ${#} -lt 2 ]] ; then - die "${FUNCNAME} requires at least two arguments" - fi - - local reason=${1} - shift - - local option - for option in ${@} ; do - echo "mk_add_options ${option} # ${reason}" >>${MOZCONFIG} - done -} - -mozconfig_use_enable() { - debug-print-function ${FUNCNAME} "$@" - - if [[ ${#} -lt 1 ]] ; then - die "${FUNCNAME} requires at least one arguments" - fi - - local flag=$(use_enable "${@}") - mozconfig_add_options_ac "$(use ${1} && echo +${1} || echo -${1})" "${flag}" -} - -mozconfig_use_with() { - debug-print-function ${FUNCNAME} "$@" - - if [[ ${#} -lt 1 ]] ; then - die "${FUNCNAME} requires at least one arguments" - fi - - local flag=$(use_with "${@}") - mozconfig_add_options_ac "$(use ${1} && echo +${1} || echo -${1})" "${flag}" -} - -virtwl() { - debug-print-function ${FUNCNAME} "$@" - - [[ $# -lt 1 ]] && die "${FUNCNAME} needs at least one argument" - [[ -n $XDG_RUNTIME_DIR ]] || die "${FUNCNAME} needs XDG_RUNTIME_DIR to be set; try xdg_environment_reset" - tinywl -h >/dev/null || die 'tinywl -h failed' - - local VIRTWL VIRTWL_PID - coproc VIRTWL { WLR_BACKENDS=headless exec tinywl -s 'echo $WAYLAND_DISPLAY; read _; kill $PPID'; } - local -x WAYLAND_DISPLAY - read WAYLAND_DISPLAY <&${VIRTWL[0]} - - debug-print "${FUNCNAME}: $@" - "$@" - local r=$? - - [[ -n $VIRTWL_PID ]] || die "tinywl exited unexpectedly" - exec {VIRTWL[0]}<&- {VIRTWL[1]}>&- - return $r -} - -pkg_pretend() { - if [[ ${MERGE_TYPE} != binary ]] ; then - # Ensure we have enough disk space to compile - if use pgo || use debug ; then - CHECKREQS_DISK_BUILD="14300M" - elif tc-is-lto ; then - CHECKREQS_DISK_BUILD="10600M" - else - CHECKREQS_DISK_BUILD="7400M" - fi - - check-reqs_pkg_pretend - fi -} - -pkg_setup() { - - # Get LTO from environment; export after this phase for use in src_configure (etc) - use_lto=no - - if [[ ${MERGE_TYPE} != binary ]] ; then - - if tc-is-lto; then - use_lto=yes - # LTO is handled via configure - filter-lto - fi - - if use pgo ; then - if ! has userpriv ${FEATURES} ; then - eerror "Building ${PN} with USE=pgo and FEATURES=-userpriv is not supported!" - fi - fi - - if [[ ${use_lto} = yes ]]; then - # -Werror=lto-type-mismatch -Werror=odr are going to fail with GCC, - # bmo#1516758, bgo#942288 - filter-flags -Werror=lto-type-mismatch -Werror=odr - fi - - # Ensure we have enough disk space to compile - if use pgo || use debug ; then - CHECKREQS_DISK_BUILD="14300M" - elif [[ ${use_lto} == "yes" ]] ; then - CHECKREQS_DISK_BUILD="10600M" - else - CHECKREQS_DISK_BUILD="7400M" - fi - - check-reqs_pkg_setup - llvm-r1_pkg_setup - rust_pkg_setup - python-any-r1_pkg_setup - - # Avoid PGO profiling problems due to enviroment leakage - # These should *always* be cleaned up anyway - unset \ - DBUS_SESSION_BUS_ADDRESS \ - DISPLAY \ - ORBIT_SOCKETDIR \ - SESSION_MANAGER \ - XAUTHORITY \ - XDG_CACHE_HOME \ - XDG_SESSION_COOKIE - - # Build system is using /proc/self/oom_score_adj, bug #604394 - addpredict /proc/self/oom_score_adj - - if use pgo ; then - # Update 105.0: "/proc/self/oom_score_adj" isn't enough anymore with pgo, but not sure - # whether that's due to better OOM handling by Firefox (bmo#1771712), or portage - # (PORTAGE_SCHEDULING_POLICY) update... - addpredict /proc - - # Clear tons of conditions, since PGO is hardware-dependant. - addpredict /dev - fi - - if ! mountpoint -q /dev/shm ; then - # If /dev/shm is not available, configure is known to fail with - # a traceback report referencing /usr/lib/pythonN.N/multiprocessing/synchronize.py - ewarn "/dev/shm is not mounted -- expect build failures!" - fi - - # Ensure we use C locale when building, bug #746215 - export LC_ALL=C - fi - - export use_lto - - CONFIG_CHECK="~SECCOMP" - WARNING_SECCOMP="CONFIG_SECCOMP not set! This system will be unable to play DRM-protected content." - linux-info_pkg_setup -} - -src_prepare() { - if [[ ${use_lto} == "yes" ]]; then - rm -v "${WORKDIR}"/firefox-patches/*-LTO-Only-enable-LTO-*.patch || die - fi - - # Workaround for bgo#915651 on musl - if use elibc_glibc ; then - rm -v "${WORKDIR}"/firefox-patches/*bgo-748849-RUST_TARGET_override.patch || die - fi - - # Use modified patch that isn't mangled - for patch in 0013-gcc-lto-pgo-gentoo.patch 0016-bgo-929967-fix-pgo-on-musl.patch; do - cp "${FILESDIR}/${patch}" "${WORKDIR}/firefox-patches/${patch}" || die - done - - eapply "${WORKDIR}/firefox-patches" - use loong && eapply "${WORKDIR}/firefox-loong-patches" - - if use system-icu && has_version ">=dev-libs/icu-78.1"; then - eapply "${FILESDIR}/firefox-146.0.1-icu78.patch" # in 147, bug #967261, bgo#967261 - fi - - # Allow user to apply any additional patches without modifing ebuild - eapply_user - - # Make cargo respect MAKEOPTS - export CARGO_BUILD_JOBS="$(makeopts_jobs)" - - # Workaround for bgo#915651 - if ! use elibc_glibc ; then - if use amd64 ; then - export RUST_TARGET="x86_64-unknown-linux-musl" - elif use x86 ; then - export RUST_TARGET="i686-unknown-linux-musl" - elif use arm64 ; then - export RUST_TARGET="aarch64-unknown-linux-musl" - elif use loong; then - # Only the LP64D ABI of LoongArch64 is actively supported among - # the wider Linux ecosystem, so the assumption is safe. - export RUST_TARGET="loongarch64-unknown-linux-musl" - elif use ppc64 ; then - export RUST_TARGET="powerpc64le-unknown-linux-musl" - elif use riscv ; then - # We can pretty safely rule out any 32-bit riscvs, but 64-bit riscvs also have tons of - # different ABIs available. riscv64gc-unknown-linux-musl seems to be the best working - # guess right now though. - elog "riscv detected, forcing a riscv64 target for now." - export RUST_TARGET="riscv64gc-unknown-linux-musl" - else - die "Unknown musl chost, please post a new bug with your rustc -vV along with emerge --info" - fi - fi - - # Pre-built wasm-sandbox path manipulation. - if use wasm-sandbox ; then - if use amd64 ; then - export wasi_arch="x86_64" - elif use arm64 ; then - export wasi_arch="arm64" - else - die "wasm-sandbox enabled on unknown/unsupported arch!" - fi - - sed -i \ - -e "s:%%PORTAGE_WORKDIR%%:${WORKDIR}:" \ - -e "s:%%WASI_ARCH%%:${wasi_arch}:" \ - -e "s:%%WASI_SDK_VER%%:${WASI_SDK_VER}:" \ - -e "s:%%WASI_SDK_LLVM_VER%%:${WASI_SDK_LLVM_VER}:" \ - toolkit/moz.configure || die "Failed to update wasi-related paths." - fi - - # Make LTO respect MAKEOPTS - sed -i -e "s/multiprocessing.cpu_count()/$(makeopts_jobs)/" \ - "${S}"/build/moz.configure/lto-pgo.configure || die "Failed sedding multiprocessing.cpu_count" - - - sed -i -e "s/multiprocessing.cpu_count()/$(makeopts_jobs)/" \ - "${S}"/third_party/chromium/build/toolchain/get_cpu_count.py || die "Failed sedding multiprocessing.cpu_count" - - sed -i -e "s/multiprocessing.cpu_count()/$(makeopts_jobs)/" \ - "${S}"/third_party/python/gyp/pylib/gyp/input.py || die "Failed sedding multiprocessing.cpu_count" - - # sed-in toolchain prefix - sed -i \ - -e "s/objdump/${CHOST}-objdump/" \ - "${S}"/python/mozbuild/mozbuild/configure/check_debug_ranges.py || die "sed failed to set toolchain prefix" - - sed -i \ - -e 's/ccache_stats = None/return None/' \ - "${S}"/python/mozbuild/mozbuild/controller/building.py || die "sed failed to disable ccache stats call" - - einfo "Removing pre-built binaries ..." - - find "${S}"/third_party -type f \( -name '*.so' -o -name '*.o' \) -print -delete || die - - # Clear checksums from cargo crates we've manually patched. - # moz_clear_vendor_checksums xyz - - # Respect choice for "jumbo-build" - # Changing the value for FILES_PER_UNIFIED_FILE may not work, see #905431 - if [[ -n ${FILES_PER_UNIFIED_FILE} ]] && use jumbo-build; then - local my_files_per_unified_file=${FILES_PER_UNIFIED_FILE:=16} - elog "" - elog "jumbo-build defaults modified to ${my_files_per_unified_file}." - elog "if you get a build failure, try undefining FILES_PER_UNIFIED_FILE," - elog "if that fails try -jumbo-build before opening a bug report." - elog "" - - sed -i -e "s/\"FILES_PER_UNIFIED_FILE\", 16/\"FILES_PER_UNIFIED_FILE\", "${my_files_per_unified_file}"/" \ - python/mozbuild/mozbuild/frontend/data.py || - die "Failed to adjust FILES_PER_UNIFIED_FILE in python/mozbuild/mozbuild/frontend/data.py" - sed -i -e "s/FILES_PER_UNIFIED_FILE = 6/FILES_PER_UNIFIED_FILE = "${my_files_per_unified_file}"/" \ - js/src/moz.build || - die "Failed to adjust FILES_PER_UNIFIED_FILE in js/src/moz.build" - fi - - # Create build dir - BUILD_DIR="${WORKDIR}/${PN}_build" - mkdir -p "${BUILD_DIR}" || die - - xdg_environment_reset -} - -src_configure() { - # Show flags set at the beginning - einfo "Current BINDGEN_CFLAGS:\t${BINDGEN_CFLAGS:-no value set}" - einfo "Current CFLAGS:\t\t${CFLAGS:-no value set}" - einfo "Current CXXFLAGS:\t\t${CXXFLAGS:-no value set}" - einfo "Current LDFLAGS:\t\t${LDFLAGS:-no value set}" - einfo "Current RUSTFLAGS:\t\t${RUSTFLAGS:-no value set}" - - local have_switched_compiler= - if use clang; then - # Force clang - einfo "Enforcing the use of clang due to USE=clang ..." - - local version_clang=$(clang --version 2>/dev/null | grep -F -- 'clang version' | awk '{ print $3 }') - [[ -n ${version_clang} ]] && version_clang=$(ver_cut 1 "${version_clang}") - [[ -z ${version_clang} ]] && die "Failed to read clang version!" - - if tc-is-gcc; then - have_switched_compiler=yes - fi - - AR=llvm-ar - CC=${CHOST}-clang-${version_clang} - CXX=${CHOST}-clang++-${version_clang} - NM=llvm-nm - RANLIB=llvm-ranlib - - elif ! use clang && ! tc-is-gcc ; then - # Force gcc - have_switched_compiler=yes - einfo "Enforcing the use of gcc due to USE=-clang ..." - AR=gcc-ar - CC=${CHOST}-gcc - CXX=${CHOST}-g++ - NM=gcc-nm - RANLIB=gcc-ranlib - fi - - if [[ -n "${have_switched_compiler}" ]] ; then - # Because we switched active compiler we have to ensure - # that no unsupported flags are set - strip-unsupported-flags - fi - - # Ensure we use correct toolchain, - # AS is used in a non-standard way by upstream, #bmo1654031 - export HOST_CC="$(tc-getBUILD_CC)" - export HOST_CXX="$(tc-getBUILD_CXX)" - export AS="$(tc-getCC) -c" - - # Configuration tests expect llvm-readelf output, bug 913130 - READELF="llvm-readelf" - - tc-export CC CXX LD AR AS NM OBJDUMP RANLIB READELF PKG_CONFIG - - # Pass the correct toolchain paths through cbindgen - if tc-is-cross-compiler ; then - export BINDGEN_CFLAGS="${SYSROOT:+--sysroot=${ESYSROOT}} --target=${CHOST} ${BINDGEN_CFLAGS-}" - fi - - # Set MOZILLA_FIVE_HOME - export MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}" - - # python/mach/mach/mixin/process.py fails to detect SHELL - export SHELL="${EPREFIX}/bin/bash" - - # Set state path - export MOZBUILD_STATE_PATH="${BUILD_DIR}" - - # Set MOZCONFIG - export MOZCONFIG="${S}/.mozconfig" - - # Initialize MOZCONFIG - mozconfig_add_options_ac '' --enable-application=browser - mozconfig_add_options_ac '' --enable-project=browser - - # Set Gentoo defaults - mozconfig_add_options_ac 'Gentoo default' \ - --allow-addon-sideload \ - --disable-cargo-incremental \ - --disable-crashreporter \ - --disable-disk-remnant-avoidance \ - --disable-geckodriver \ - --disable-install-strip \ - --disable-legacy-profile-creation \ - --disable-parental-controls \ - --disable-strip \ - --disable-updater \ - --disable-wmf \ - --enable-negotiateauth \ - --enable-new-pass-manager \ - --enable-official-branding \ - --enable-packed-relative-relocs \ - --enable-release \ - --enable-system-policies \ - --host="${CBUILD:-${CHOST}}" \ - --libdir="${EPREFIX}/usr/$(get_libdir)" \ - --prefix="${EPREFIX}/usr" \ - --target="${CHOST}" \ - --without-ccache \ - --with-intl-api \ - --with-l10n-base="${S}/l10n" \ - --with-libclang-path="$(llvm-config --libdir)" \ - --with-system-ffi \ - --with-system-gbm \ - --with-system-libdrm \ - --with-system-nspr \ - --with-system-nss \ - --with-system-pixman \ - --with-system-zlib \ - --with-toolchain-prefix="${CHOST}-" \ - --with-unsigned-addon-scopes=app,system - - # Whitelist to allow unkeyworded arches to build with "--disable-rust-simd" by default. - if use amd64 || use arm64 || use ppc64 || use loong || use riscv ; then - mozconfig_add_options_ac '' --enable-rust-simd - fi - - # For future keywording: This is currently (97.0) only supported on: - # amd64, arm, arm64 & x86. - # Might want to flip the logic around if Firefox is to support more arches. - # bug 833001, bug 903411#c8 - if use loong || use ppc64 || use riscv; then - mozconfig_add_options_ac '' --disable-sandbox - else - mozconfig_add_options_ac '' --enable-sandbox - fi - - # riscv-related options, bgo#947337, bgo#947338 - if use riscv ; then - mozconfig_add_options_ac 'Disable JIT for RISC-V 64' --disable-jit - mozconfig_add_options_ac 'Disable webrtc for RISC-V' --disable-webrtc - fi - - mozconfig_use_with system-av1 - mozconfig_use_with system-harfbuzz - mozconfig_use_with system-icu - mozconfig_use_with system-jpeg - mozconfig_use_with system-libevent - mozconfig_use_with system-libvpx - mozconfig_use_with system-pipewire - mozconfig_use_with system-png - mozconfig_use_with system-webp - - mozconfig_use_enable dbus - mozconfig_use_enable libproxy - - # --disable-eme is only supported on x86 and x86-64 - if use amd64 || use x86 ; then - mozconfig_add_options_ac '' --disable-eme - fi - - if use hardened ; then - mozconfig_add_options_ac "+hardened" --enable-hardening - append-ldflags "-Wl,-z,relro -Wl,-z,now" - - # Increase the FORTIFY_SOURCE value, #910071. - sed -i -e '/-D_FORTIFY_SOURCE=/s:2:3:' "${S}"/build/moz.configure/toolchain.configure || die - fi - - local myaudiobackends="" - use jack && myaudiobackends+="jack," - use sndio && myaudiobackends+="sndio," - use pulseaudio && myaudiobackends+="pulseaudio," - ! use pulseaudio && myaudiobackends+="alsa," - - mozconfig_add_options_ac '--enable-audio-backends' --enable-audio-backends="${myaudiobackends::-1}" - - mozconfig_use_enable wifi necko-wifi - - ! use jumbo-build && mozconfig_add_options_ac '--disable-unified-build' --disable-unified-build - - if use X && use wayland ; then - mozconfig_add_options_ac '+x11+wayland' --enable-default-toolkit=cairo-gtk3-x11-wayland - elif ! use X && use wayland ; then - mozconfig_add_options_ac '+wayland' --enable-default-toolkit=cairo-gtk3-wayland-only - else - mozconfig_add_options_ac '+x11' --enable-default-toolkit=cairo-gtk3-x11-only - fi - - # wasm-sandbox - # Since graphite2 is one of the sandboxed libraries, system-graphite2 obviously can't work with +wasm-sandbox. - if use wasm-sandbox ; then - mozconfig_add_options_ac '+wasm-sandbox' --with-wasi-sysroot="${WORKDIR}/wasi-sdk-${WASI_SDK_VER}-${wasi_arch}-linux/share/wasi-sysroot/" - else - mozconfig_add_options_ac 'no wasm-sandbox' --without-wasm-sandboxed-libraries - mozconfig_use_with system-harfbuzz system-graphite2 - fi - - if [[ ${use_lto} == "yes" ]] ; then - if use clang ; then - # Upstream only supports lld or mold when using clang. - if tc-ld-is-mold ; then - # mold expects the -flto line from *FLAGS configuration, bgo#923119 - append-ldflags "-flto=thin" - mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker=mold - else - mozconfig_add_options_ac "forcing ld=lld due to USE=clang and USE=lto" --enable-linker=lld - fi - - mozconfig_add_options_ac '+lto' --enable-lto=cross - - else - # ThinLTO is currently broken, see bmo#1644409. - # mold does not support gcc+lto combination. - mozconfig_add_options_ac '+lto' --enable-lto=full - mozconfig_add_options_ac "linker is set to bfd" --enable-linker=bfd - fi - else - # Avoid auto-magic on linker - if use clang ; then - # lld is upstream's default - if tc-ld-is-mold ; then - mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker=mold - else - mozconfig_add_options_ac "forcing ld=lld due to USE=clang" --enable-linker=lld - fi - - else - if tc-ld-is-mold ; then - mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker=mold - else - mozconfig_add_options_ac "linker is set to bfd due to USE=-clang" --enable-linker=bfd - fi - fi - fi - - # PGO was moved outside lto block to allow building pgo without lto. - if use pgo ; then - mozconfig_add_options_ac '+pgo' MOZ_PGO=1 - - # Avoid compressing just-built instrumented Firefox with - # high levels of compression. Just use tar as a container - # to save >=10 minutes. - export MOZ_PKG_FORMAT=tar - - if use clang ; then - # Used in build/pgo/profileserver.py - export LLVM_PROFDATA="llvm-profdata" - fi - fi - - mozconfig_use_enable debug - if use debug ; then - mozconfig_add_options_ac '+debug' --disable-optimize - mozconfig_add_options_ac '+debug' --enable-jemalloc - mozconfig_add_options_ac '+debug' --enable-real-time-tracing - else - mozconfig_add_options_ac 'Gentoo defaults' --disable-real-time-tracing - - if is-flag '-g*' ; then - if use clang ; then - mozconfig_add_options_ac 'from CFLAGS' --enable-debug-symbols=$(get-flag '-g*') - else - mozconfig_add_options_ac 'from CFLAGS' --enable-debug-symbols - fi - else - mozconfig_add_options_ac 'Gentoo default' --disable-debug-symbols - fi - - if is-flag '-O0' ; then - mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-O0 - elif is-flag '-O4' ; then - mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-O4 - elif is-flag '-O3' ; then - mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-O3 - elif is-flag '-O1' ; then - mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-O1 - elif is-flag '-Os' ; then - mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-Os - else - mozconfig_add_options_ac "Gentoo default" --enable-optimize=-O2 - fi - fi - - # Debug flag was handled via configure - filter-flags '-g*' - - # Optimization flag was handled via configure - filter-flags '-O*' - - # elf-hack - # Filter "-z,pack-relative-relocs" and let the build system handle it instead. - if use amd64 || use x86 ; then - filter-flags "-z,pack-relative-relocs" - - if tc-ld-is-mold ; then - # relr-elf-hack is currently broken with mold, bgo#916259 - mozconfig_add_options_ac 'disable elf-hack with mold linker' --disable-elf-hack - else - mozconfig_add_options_ac 'relr elf-hack' --enable-elf-hack=relr - fi - elif use loong || use ppc64 || use riscv ; then - # '--disable-elf-hack' is not recognized on loong/ppc64/riscv, - # see bgo #917049, #930046 - :; - else - mozconfig_add_options_ac 'disable elf-hack on non-supported arches' --disable-elf-hack - fi - - if ! use elibc_glibc; then - mozconfig_add_options_ac '!elibc_glibc' --disable-jemalloc - fi - - # System-av1 fix - use system-av1 && append-ldflags "-Wl,--undefined-version" - - # Make revdep-rebuild.sh happy; Also required for musl - append-ldflags -Wl,-rpath="${MOZILLA_FIVE_HOME}",--enable-new-dtags - - # Pass $MAKEOPTS to build system - export MOZ_MAKE_FLAGS="${MAKEOPTS}" - - # Use system's Python environment - export PIP_NETWORK_INSTALL_RESTRICTED_VIRTUALENVS=mach - - export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE="none" - - mozconfig_use_enable test tests - - # Disable notification when build system has finished - export MOZ_NOSPAM=1 - - # Portage sets XARGS environment variable to "xargs -r" by default which - # breaks build system's check_prog() function which doesn't support arguments - mozconfig_add_options_ac 'Gentoo default' "XARGS=${EPREFIX}/usr/bin/xargs" - - # Set build dir - mozconfig_add_options_mk 'Gentoo default' "MOZ_OBJDIR=${BUILD_DIR}" - - # Show flags we will use - einfo "Build BINDGEN_CFLAGS:\t${BINDGEN_CFLAGS:-no value set}" - einfo "Build CFLAGS:\t\t${CFLAGS:-no value set}" - einfo "Build CXXFLAGS:\t\t${CXXFLAGS:-no value set}" - einfo "Build LDFLAGS:\t\t${LDFLAGS:-no value set}" - einfo "Build RUSTFLAGS:\t\t${RUSTFLAGS:-no value set}" - - # Handle EXTRA_CONF and show summary - local ac opt hash reason - - # Apply EXTRA_ECONF entries to $MOZCONFIG - if [[ -n ${EXTRA_ECONF} ]] ; then - IFS=\! read -a ac <<<${EXTRA_ECONF// --/\!} - for opt in "${ac[@]}"; do - mozconfig_add_options_ac "EXTRA_ECONF" --${opt#--} - done - fi - - echo - echo "==========================================================" - echo "Building ${PF} with the following configuration" - grep ^ac_add_options "${MOZCONFIG}" | while read ac opt hash reason; do - [[ -z ${hash} || ${hash} == \# ]] \ - || die "error reading mozconfig: ${ac} ${opt} ${hash} ${reason}" - printf " %-30s %s\n" "${opt}" "${reason:-mozilla.org default}" - done - echo "==========================================================" - echo - - ./mach configure || die -} - -src_compile() { - local virtx_cmd= - - if [[ ${use_lto} == "yes" ]] && tc-ld-is-mold ; then - # increase ulimit with mold+lto, bugs #892641, #907485 - if ! ulimit -n 16384 1>/dev/null 2>&1 ; then - ewarn "Unable to modify ulimits - building with mold+lto might fail due to low ulimit -n resources." - ewarn "Please see bugs #892641 & #907485." - else - ulimit -n 16384 - fi - fi - - if use pgo; then - # Reset and cleanup environment variables used by GNOME/XDG - gnome2_environment_reset - - addpredict /root - - if ! use X; then - virtx_cmd=virtwl - else - virtx_cmd=virtx - fi - fi - - if ! use X; then - local -x GDK_BACKEND=wayland - else - local -x GDK_BACKEND=x11 - fi - - ${virtx_cmd} ./mach build --verbose || die - - # Build language packs - moz_build_xpi -} - -src_test() { - # https://firefox-source-docs.mozilla.org/testing/automated-testing/index.html - local -a failures=() - - # Some tests respect this - local -x MOZ_HEADLESS=1 - - # Check testing/mach_commands.py - einfo "Testing with cppunittest ..." - ./mach cppunittest - local ret=$? - if [[ ${ret} -ne 0 ]]; then - eerror "Test suite cppunittest failed with error code ${ret}" - failures+=( cppunittest ) - fi - - if [[ ${#failures} -eq 0 ]]; then - einfo "Test suites succeeded" - else - die "Test suites failed: ${failures[@]}" - fi -} - -src_install() { - # xpcshell is getting called during install - pax-mark m \ - "${BUILD_DIR}"/dist/bin/xpcshell \ - "${BUILD_DIR}"/dist/bin/${PN} \ - "${BUILD_DIR}"/dist/bin/plugin-container - - DESTDIR="${D}" ./mach install || die - - # Upstream cannot ship symlink but we can (bmo#658850) - rm "${ED}${MOZILLA_FIVE_HOME}/${PN}-bin" || die - dosym ${PN} ${MOZILLA_FIVE_HOME}/${PN}-bin - - # Don't install llvm-symbolizer from llvm-core/llvm package - if [[ -f "${ED}${MOZILLA_FIVE_HOME}/llvm-symbolizer" ]] ; then - rm -v "${ED}${MOZILLA_FIVE_HOME}/llvm-symbolizer" || die - fi - - # Install policy (currently only used to disable application updates) - insinto "${MOZILLA_FIVE_HOME}/distribution" - newins "${FILESDIR}"/distribution.ini distribution.ini - newins "${FILESDIR}"/disable-auto-update.policy.json policies.json - - # Install system-wide preferences - local PREFS_DIR="${MOZILLA_FIVE_HOME}/browser/defaults/preferences" - insinto "${PREFS_DIR}" - newins "${FILESDIR}"/gentoo-default-prefs.js gentoo-prefs.js - - local GENTOO_PREFS="${ED}${PREFS_DIR}/gentoo-prefs.js" - - # Set dictionary path to use system hunspell - cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set spellchecker.dictionary_path pref" - pref("spellchecker.dictionary_path", "${EPREFIX}/usr/share/myspell"); - EOF - - # Force hwaccel prefs if USE=hwaccel is enabled - if use hwaccel ; then - cat "${FILESDIR}"/gentoo-hwaccel-prefs.js-r2 \ - >>"${GENTOO_PREFS}" \ - || die "failed to add prefs to force hardware-accelerated rendering to all-gentoo.js" - - if use wayland; then - cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set hwaccel wayland prefs" - pref("gfx.x11-egl.force-enabled", false); - EOF - else - cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set hwaccel x11 prefs" - pref("gfx.x11-egl.force-enabled", true); - EOF - fi - - # Install the vaapitest binary on supported arches (122.0 supports all platforms, bmo#1865969) - exeinto "${MOZILLA_FIVE_HOME}" - doexe "${BUILD_DIR}"/dist/bin/vaapitest - - # Install the v4l2test on supported arches (+ arm, + riscv64 when keyworded) - if use arm64 ; then - exeinto "${MOZILLA_FIVE_HOME}" - doexe "${BUILD_DIR}"/dist/bin/v4l2test - fi - fi - - # Force the graphite pref if USE=system-harfbuzz is enabled, since the pref cannot disable it - if use system-harfbuzz ; then - cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set gfx.font_rendering.graphite.enabled pref" - sticky_pref("gfx.font_rendering.graphite.enabled", true); - EOF - fi - - # Install language packs - local langpacks=( $(find "${BUILD_DIR}"/dist/linux-x86_64/xpi -type f -name '*.xpi') ) - if [[ -n "${langpacks}" ]] ; then - moz_install_xpi "${MOZILLA_FIVE_HOME}/distribution/extensions" "${langpacks[@]}" - fi - - # Install icons - local icon_srcdir="${S}/browser/branding/official" - - insinto /usr/share/icons/hicolor/symbolic/apps - newins "${FILESDIR}/icon/icecat-symbolic.svg" icecat-symbolic.svg - - local icon size - for icon in "${icon_srcdir}"/default*.png ; do - size=${icon%.png} - size=${size##*/default} - - if [[ ${size} -eq 48 ]] ; then - newicon "${icon}" ${PN}.png - fi - - newicon -s ${size} "${icon}" ${PN}.png - done - - # Install menu - local app_name="GNU IceCat" - local desktop_file="${FILESDIR}/icon/${PN}-r3.desktop" - local exec_command="${PN}" - local icon="${PN}" - local use_wayland="false" - - if use wayland ; then - use_wayland="true" - fi - - cp "${desktop_file}" "${WORKDIR}/${PN}.desktop-template" || die - - sed -i \ - -e "s:@NAME@:${app_name}:" \ - -e "s:@EXEC@:${exec_command}:" \ - -e "s:@ICON@:${icon}:" \ - "${WORKDIR}/${PN}.desktop-template" || die - - newmenu "${WORKDIR}/${PN}.desktop-template" icecat.desktop - - rm "${WORKDIR}/${PN}.desktop-template" || die - - if use gnome-shell ; then - # Install search provider for Gnome - insinto /usr/share/gnome-shell/search-providers/ - doins browser/components/shell/search-provider-files/org.gnu.icecat.search-provider.ini - - insinto /usr/share/dbus-1/services/ - doins browser/components/shell/search-provider-files/org.gnu.icecat.SearchProvider.service - - # Make the dbus service aware of a previous session, bgo#939196 - sed -e \ - "s/Exec=\/usr\/bin\/icecat/Exec=\/usr\/$(get_libdir)\/icecat\/icecat --dbus-service \/usr\/bin\/icecat/g" \ - -i "${ED}/usr/share/dbus-1/services/org.gnu.icecat.SearchProvider.service" || - die "Failed to sed org.gnu.icecat.SearchProvider.service dbus file" - - # Update prefs to enable Gnome search provider - cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to enable gnome-search-provider via prefs" - pref("browser.gnome-search-provider.enabled", true); - EOF - fi - - # Install wrapper script - [[ -f "${ED}/usr/bin/${PN}" ]] && rm "${ED}/usr/bin/${PN}" - newbin "${FILESDIR}/${PN}-r1.sh" ${PN} - - # Update wrapper - sed -i \ - -e "s:@PREFIX@:${EPREFIX}/usr:" \ - -e "s:@DEFAULT_WAYLAND@:${use_wayland}:" \ - "${ED}/usr/bin/${PN}" || die - - readme.gentoo_create_doc -} - -pkg_postinst() { - xdg_pkg_postinst - - elog "Cloudflare browser checks are broken with GNU IceCats anti fingerprinting measures." - elog "You can fix cloudflare browser checks by undoing them in about:config like below:" - # Specifying (X11) is necessary for it to work, even in a Wayland session - elog " general.appversion.override: ${PV%.[0-9]*} (X11)" - elog " general.oscpu.override: Linux x86_64" - elog " general.platform.override: Linux x86_64" - - # bug 835078 - if use hwaccel && has_version "x11-drivers/xf86-video-nouveau"; then - ewarn "You have nouveau drivers installed in your system and 'hwaccel' " - ewarn "enabled for Firefox. Nouveau / your GPU might not support the " - ewarn "required EGL, so either disable 'hwaccel' or try the workaround " - ewarn "explained in https://bugs.gentoo.org/835078#c5 if Firefox crashes." - fi - - readme.gentoo_print_elog - - optfeature_header "Optional programs for extra features:" - optfeature "desktop notifications" x11-libs/libnotify - optfeature "fallback mouse cursor theme e.g. on WMs" gnome-base/gsettings-desktop-schemas - optfeature "screencasting with pipewire" sys-apps/xdg-desktop-portal - if use hwaccel && has_version "x11-drivers/nvidia-drivers"; then - optfeature "hardware acceleration with NVIDIA cards" media-libs/nvidia-vaapi-driver - fi - - if ! has_version "sys-libs/glibc"; then - elog - elog "glibc not found! You won't be able to play DRM content." - elog "See Gentoo bug #910309 or upstream bug #1843683." - elog - fi -} diff --git a/www-client/icecat/icecat-140.7.1.ebuild b/www-client/icecat/icecat-140.7.1.ebuild new file mode 100644 index 0000000..0a517e3 --- /dev/null +++ b/www-client/icecat/icecat-140.7.1.ebuild @@ -0,0 +1,1270 @@ +# Copyright 1999-2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# Ebuild is based on the Firefox ebuilds in the main repo + +EAPI=8 + +# Using Gentoos firefox patches as system libraries and lto are quite nice +FIREFOX_PATCHSET="firefox-140esr-patches-05.tar.xz" +FIREFOX_LOONG_PATCHSET="firefox-139-loong-patches-02.tar.xz" + +LLVM_COMPAT=( 19 20 21 ) + +# This will also filter rust versions that don't match LLVM_COMPAT in the non-clang path; this is fine. +RUST_NEEDS_LLVM=1 +# If not building with clang we need at least rust 1.76 +RUST_MIN_VER=1.82.0 + +PYTHON_COMPAT=( python3_{11..14} ) +PYTHON_REQ_USE="ncurses,sqlite,ssl" + +VIRTUALX_REQUIRED="manual" + +# Information about the bundled wasi toolchain from +# https://github.com/WebAssembly/wasi-sdk/ +WASI_SDK_VER=30.0 +WASI_SDK_LLVM_VER=21 + +inherit check-reqs desktop flag-o-matic gnome2-utils linux-info llvm-r1 multiprocessing \ + optfeature pax-utils python-any-r1 readme.gentoo-r1 rust toolchain-funcs unpacker virtualx xdg + +DESCRIPTION="GNU IceCat Web Browser" +HOMEPAGE="https://www.gnu.org/software/gnuzilla/" + +PATCH_URIS=( + https://dev.gentoo.org/~juippis/mozilla/patchsets/${FIREFOX_PATCHSET} +) + +# Icecat tarball generated from https://cgit.git.savannah.gnu.org/cgit/gnuzilla.git +# Script modified to output zstd tarballs due to size and unpacking speed considerations. +ICECAT_REV="1gnu1" + +SRC_URI=" + https://gitlab.com/api/v4/projects/32909921/packages/generic/${PN}/${PV}-${ICECAT_REV}/${P}-${ICECAT_REV}.tar.zst + ${PATCH_URIS[@]} + loong? ( + https://dev.gentoo.org/~xen0n/distfiles/www-client/firefox/${FIREFOX_LOONG_PATCHSET} + ) + wasm-sandbox? ( + amd64? ( https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VER/.*/}/wasi-sdk-${WASI_SDK_VER}-x86_64-linux.tar.gz ) + arm64? ( https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VER/.*/}/wasi-sdk-${WASI_SDK_VER}-arm64-linux.tar.gz ) + )" +S="${WORKDIR}/${PN}-${PV%_*}" +LICENSE="MPL-2.0 GPL-2 LGPL-2.1" +SLOT="0" +KEYWORDS="~amd64" + +IUSE="+clang dbus debug hardened hwaccel jack libproxy pgo pulseaudio selinux sndio" +IUSE+=" +system-av1 +system-harfbuzz +system-icu +system-jpeg +system-libevent +system-libvpx" +IUSE+=" system-pipewire system-png +system-webp test wayland wifi +X" + +# Firefox-only IUSE +IUSE+=" gnome-shell +jumbo-build openh264 wasm-sandbox" + +REQUIRED_USE="|| ( X wayland ) + debug? ( !system-av1 ) + pgo? ( jumbo-build ) + wayland? ( dbus ) + wifi? ( dbus ) +" + +RESTRICT="!test? ( test )" + +FF_ONLY_DEPEND="selinux? ( sec-policy/selinux-mozilla )" +BDEPEND="${PYTHON_DEPS} + $(unpacker_src_uri_depends) + $(llvm_gen_dep ' + llvm-core/clang:${LLVM_SLOT} + llvm-core/llvm:${LLVM_SLOT} + clang? ( + llvm-core/lld:${LLVM_SLOT} + pgo? ( llvm-runtimes/compiler-rt-sanitizers:${LLVM_SLOT}[profile] ) + ) + wasm-sandbox? ( llvm-core/lld:${LLVM_SLOT} ) + ') + app-alternatives/awk + app-arch/unzip + app-arch/zip + >=dev-util/cbindgen-0.27.0 + net-libs/nodejs + virtual/pkgconfig + amd64? ( >=dev-lang/nasm-2.14 ) + x86? ( >=dev-lang/nasm-2.14 ) + pgo? ( + X? ( + sys-devel/gettext + x11-base/xorg-server[xvfb] + x11-apps/xhost + ) + !X? ( + gui-wm/tinywl + x11-misc/xkeyboard-config + ) + )" +COMMON_DEPEND="${FF_ONLY_DEPEND} + >=app-accessibility/at-spi2-core-2.46.0:2 + dev-libs/glib:2 + dev-libs/libffi:= + >=dev-libs/nss-3.112.2 + >=dev-libs/nspr-4.36 + media-libs/alsa-lib + media-libs/fontconfig + media-libs/freetype + media-libs/mesa + media-video/ffmpeg + virtual/zlib:= + virtual/freedesktop-icon-theme + x11-libs/cairo + x11-libs/gdk-pixbuf:2 + x11-libs/libdrm + x11-libs/pango + x11-libs/pixman + dbus? ( + sys-apps/dbus + ) + jack? ( virtual/jack ) + pulseaudio? ( + || ( + media-libs/libpulse + >=media-sound/apulse-0.1.12-r4[sdk] + ) + ) + libproxy? ( net-libs/libproxy ) + selinux? ( sec-policy/selinux-mozilla ) + sndio? ( >=media-sound/sndio-1.8.0-r1 ) + system-av1? ( + >=media-libs/dav1d-1.0.0:= + >=media-libs/libaom-3.10.0:= + ) + system-harfbuzz? ( + >=media-libs/harfbuzz-2.8.1:0= + !wasm-sandbox? ( >=media-gfx/graphite2-1.3.13 ) + ) + system-icu? ( >=dev-libs/icu-76.1:= ) + system-jpeg? ( >=media-libs/libjpeg-turbo-1.2.1:= ) + system-libevent? ( >=dev-libs/libevent-2.1.12:0=[threads(+)] ) + system-libvpx? ( >=media-libs/libvpx-1.8.2:0=[postproc] ) + system-pipewire? ( >=media-video/pipewire-1.4.7-r2:= ) + system-png? ( >=media-libs/libpng-1.6.45:0=[apng] ) + system-webp? ( >=media-libs/libwebp-1.1.0:0= ) + wayland? ( + >=media-libs/libepoxy-1.5.10-r1 + x11-libs/gtk+:3[wayland] + ) + wifi? ( + kernel_linux? ( + || ( + net-misc/networkmanager + net-misc/connman[networkmanager] + ) + sys-apps/dbus + ) + ) + X? ( + virtual/opengl + x11-libs/cairo[X] + x11-libs/gtk+:3[X] + x11-libs/libX11 + x11-libs/libXcomposite + x11-libs/libXdamage + x11-libs/libXext + x11-libs/libXfixes + x11-libs/libXrandr + x11-libs/libxcb:= + )" +RDEPEND="${COMMON_DEPEND} + hwaccel? ( + media-video/libva-utils + sys-apps/pciutils + ) + jack? ( virtual/jack ) + openh264? ( media-libs/openh264:*[plugin] )" +DEPEND="${COMMON_DEPEND} + X? ( + x11-base/xorg-proto + x11-libs/libICE + x11-libs/libSM + )" + +llvm_check_deps() { + if ! has_version -b "llvm-core/clang:${LLVM_SLOT}" ; then + einfo "llvm-core/clang:${LLVM_SLOT} is missing! Cannot use LLVM slot ${LLVM_SLOT} ..." >&2 + return 1 + fi + + if use clang && ! tc-ld-is-mold ; then + if ! has_version -b "llvm-core/lld:${LLVM_SLOT}" ; then + einfo "llvm-core/lld:${LLVM_SLOT} is missing! Cannot use LLVM slot ${LLVM_SLOT} ..." >&2 + return 1 + fi + fi + + if use pgo ; then + if ! has_version -b "=llvm-runtimes/compiler-rt-sanitizers-${LLVM_SLOT}*[profile]" ; then + einfo "=llvm-runtimes/compiler-rt-sanitizers-${LLVM_SLOT}*[profile] is missing!" >&2 + einfo "Cannot use LLVM slot ${LLVM_SLOT} ..." >&2 + return 1 + fi + fi + + einfo "Using LLVM slot ${LLVM_SLOT} to build" >&2 +} + +MOZ_LANGS=( + af ar ast be bg br ca cak cs cy da de dsb + el en-CA en-GB en-US es-AR es-ES et eu + fi fr fy-NL ga-IE gd gl he hr hsb hu + id is it ja ka kab kk ko lt lv ms nb-NO nl nn-NO + pa-IN pl pt-BR pt-PT rm ro ru + sk sl sq sr sv-SE th tr uk uz vi zh-CN zh-TW +) + +# Firefox-only LANGS +MOZ_LANGS+=( ach ) +MOZ_LANGS+=( an ) +MOZ_LANGS+=( az ) +MOZ_LANGS+=( bn ) +MOZ_LANGS+=( bs ) +MOZ_LANGS+=( ca-valencia ) +MOZ_LANGS+=( eo ) +MOZ_LANGS+=( es-CL ) +MOZ_LANGS+=( es-MX ) +MOZ_LANGS+=( fa ) +MOZ_LANGS+=( ff ) +MOZ_LANGS+=( fur ) +MOZ_LANGS+=( gn ) +MOZ_LANGS+=( gu-IN ) +MOZ_LANGS+=( hi-IN ) +MOZ_LANGS+=( hy-AM ) +MOZ_LANGS+=( ia ) +MOZ_LANGS+=( km ) +MOZ_LANGS+=( kn ) +MOZ_LANGS+=( lij ) +MOZ_LANGS+=( mk ) +MOZ_LANGS+=( mr ) +MOZ_LANGS+=( my ) +MOZ_LANGS+=( ne-NP ) +MOZ_LANGS+=( oc ) +MOZ_LANGS+=( sc ) +MOZ_LANGS+=( sco ) +MOZ_LANGS+=( si ) +MOZ_LANGS+=( skr ) +MOZ_LANGS+=( son ) +MOZ_LANGS+=( szl ) +MOZ_LANGS+=( ta ) +MOZ_LANGS+=( te ) +MOZ_LANGS+=( tl ) +MOZ_LANGS+=( trs ) +MOZ_LANGS+=( ur ) +MOZ_LANGS+=( xh ) + +mozilla_set_globals() { + # https://bugs.gentoo.org/587334 + local MOZ_TOO_REGIONALIZED_FOR_L10N=( + fy-NL ga-IE gu-IN hi-IN hy-AM nb-NO ne-NP nn-NO pa-IN sv-SE + ) + + local lang xflag + for lang in "${MOZ_LANGS[@]}" ; do + # en and en_US are handled internally + if [[ ${lang} == en ]] || [[ ${lang} == en-US ]] ; then + continue + fi + + # strip region subtag if $lang is in the list + if has ${lang} "${MOZ_TOO_REGIONALIZED_FOR_L10N[@]}" ; then + xflag=${lang%%-*} + else + xflag=${lang} + fi + + IUSE+=" l10n_${xflag/[_@]/-}" + done +} +mozilla_set_globals + +moz_clear_vendor_checksums() { + debug-print-function ${FUNCNAME} "$@" + + if [[ ${#} -ne 1 ]] ; then + die "${FUNCNAME} requires exact one argument" + fi + + einfo "Clearing cargo checksums for ${1} ..." + + sed -i \ + -e 's/\("files":{\)[^}]*/\1/' \ + "${S}"/third_party/rust/${1}/.cargo-checksum.json || die +} + +moz_build_xpi() { + debug-print-function ${FUNCNAME} "$@" + + local MOZ_TOO_REGIONALIZED_FOR_L10N=( + fy-NL ga-IE gu-IN hi-IN hy-AM nb-NO ne-NP nn-NO pa-IN sv-SE + ) + + cd "${BUILD_DIR}"/browser/locales || die + local lang xflag + for lang in "${MOZ_LANGS[@]}"; do + # en and en_US are handled internally + if [[ ${lang} == en ]] || [[ ${lang} == en-US ]] ; then + continue + fi + + # strip region subtag if $lang is in the list + if has ${lang} "${MOZ_TOO_REGIONALIZED_FOR_L10N[@]}" ; then + xflag=${lang%%-*} + else + xflag=${lang} + fi + + if use l10n_"${xflag}"; then + emake langpack-"${lang}" LOCALE_MERGEDIR=. + fi + done +} + +moz_install_xpi() { + debug-print-function ${FUNCNAME} "$@" + + if [[ ${#} -lt 2 ]] ; then + die "${FUNCNAME} requires at least two arguments" + fi + + local DESTDIR=${1} + shift + + insinto "${DESTDIR}" + + local emid xpi_file xpi_tmp_dir + for xpi_file in "${@}" ; do + emid= + xpi_tmp_dir=$(mktemp -d --tmpdir="${T}") + + # Unpack XPI + unzip -qq "${xpi_file}" -d "${xpi_tmp_dir}" || die + + # Determine extension ID + if [[ -f "${xpi_tmp_dir}/install.rdf" ]] ; then + emid=$(sed -n -e '/install-manifest/,$ { /em:id/!d; s/.*[\">]\([^\"<>]*\)[\"<].*/\1/; p; q }' "${xpi_tmp_dir}/install.rdf") + [[ -z "${emid}" ]] && die "failed to determine extension id from install.rdf" + elif [[ -f "${xpi_tmp_dir}/manifest.json" ]] ; then + emid=$(sed -n -e 's/.*"id": "\([^"]*\)".*/\1/p' "${xpi_tmp_dir}/manifest.json") + [[ -z "${emid}" ]] && die "failed to determine extension id from manifest.json" + else + die "failed to determine extension id" + fi + + einfo "Installing ${emid}.xpi into ${ED}${DESTDIR} ..." + newins "${xpi_file}" "${emid}.xpi" + done +} + +mozconfig_add_options_ac() { + debug-print-function ${FUNCNAME} "$@" + + if [[ ${#} -lt 2 ]] ; then + die "${FUNCNAME} requires at least two arguments" + fi + + local reason=${1} + shift + + local option + for option in ${@} ; do + echo "ac_add_options ${option} # ${reason}" >>${MOZCONFIG} + done +} + +mozconfig_add_options_mk() { + debug-print-function ${FUNCNAME} "$@" + + if [[ ${#} -lt 2 ]] ; then + die "${FUNCNAME} requires at least two arguments" + fi + + local reason=${1} + shift + + local option + for option in ${@} ; do + echo "mk_add_options ${option} # ${reason}" >>${MOZCONFIG} + done +} + +mozconfig_use_enable() { + debug-print-function ${FUNCNAME} "$@" + + if [[ ${#} -lt 1 ]] ; then + die "${FUNCNAME} requires at least one arguments" + fi + + local flag=$(use_enable "${@}") + mozconfig_add_options_ac "$(use ${1} && echo +${1} || echo -${1})" "${flag}" +} + +mozconfig_use_with() { + debug-print-function ${FUNCNAME} "$@" + + if [[ ${#} -lt 1 ]] ; then + die "${FUNCNAME} requires at least one arguments" + fi + + local flag=$(use_with "${@}") + mozconfig_add_options_ac "$(use ${1} && echo +${1} || echo -${1})" "${flag}" +} + +virtwl() { + debug-print-function ${FUNCNAME} "$@" + + [[ $# -lt 1 ]] && die "${FUNCNAME} needs at least one argument" + [[ -n $XDG_RUNTIME_DIR ]] || die "${FUNCNAME} needs XDG_RUNTIME_DIR to be set; try xdg_environment_reset" + tinywl -h >/dev/null || die 'tinywl -h failed' + + local VIRTWL VIRTWL_PID + coproc VIRTWL { WLR_BACKENDS=headless exec tinywl -s 'echo $WAYLAND_DISPLAY; read _; kill $PPID'; } + local -x WAYLAND_DISPLAY + read WAYLAND_DISPLAY <&${VIRTWL[0]} + + debug-print "${FUNCNAME}: $@" + "$@" + local r=$? + + [[ -n $VIRTWL_PID ]] || die "tinywl exited unexpectedly" + exec {VIRTWL[0]}<&- {VIRTWL[1]}>&- + return $r +} + +pkg_pretend() { + if [[ ${MERGE_TYPE} != binary ]] ; then + # Ensure we have enough disk space to compile + if use pgo || use debug ; then + CHECKREQS_DISK_BUILD="14300M" + elif tc-is-lto ; then + CHECKREQS_DISK_BUILD="10600M" + else + CHECKREQS_DISK_BUILD="7400M" + fi + + check-reqs_pkg_pretend + fi +} + +pkg_setup() { + + # Get LTO from environment; export after this phase for use in src_configure (etc) + use_lto=no + + if [[ ${MERGE_TYPE} != binary ]] ; then + + if tc-is-lto; then + use_lto=yes + # LTO is handled via configure + filter-lto + fi + + if use pgo ; then + if ! has userpriv ${FEATURES} ; then + eerror "Building ${PN} with USE=pgo and FEATURES=-userpriv is not supported!" + fi + fi + + if [[ ${use_lto} = yes ]]; then + # -Werror=lto-type-mismatch -Werror=odr are going to fail with GCC, + # bmo#1516758, bgo#942288 + filter-flags -Werror=lto-type-mismatch -Werror=odr + fi + + # Ensure we have enough disk space to compile + if use pgo || use debug ; then + CHECKREQS_DISK_BUILD="14300M" + elif [[ ${use_lto} == "yes" ]] ; then + CHECKREQS_DISK_BUILD="10600M" + else + CHECKREQS_DISK_BUILD="7400M" + fi + + check-reqs_pkg_setup + llvm-r1_pkg_setup + rust_pkg_setup + python-any-r1_pkg_setup + + # Avoid PGO profiling problems due to enviroment leakage + # These should *always* be cleaned up anyway + unset \ + DBUS_SESSION_BUS_ADDRESS \ + DISPLAY \ + ORBIT_SOCKETDIR \ + SESSION_MANAGER \ + XAUTHORITY \ + XDG_CACHE_HOME \ + XDG_SESSION_COOKIE + + # Build system is using /proc/self/oom_score_adj, bug #604394 + addpredict /proc/self/oom_score_adj + + if use pgo ; then + # Update 105.0: "/proc/self/oom_score_adj" isn't enough anymore with pgo, but not sure + # whether that's due to better OOM handling by Firefox (bmo#1771712), or portage + # (PORTAGE_SCHEDULING_POLICY) update... + addpredict /proc + + # Clear tons of conditions, since PGO is hardware-dependant. + addpredict /dev + fi + + if ! mountpoint -q /dev/shm ; then + # If /dev/shm is not available, configure is known to fail with + # a traceback report referencing /usr/lib/pythonN.N/multiprocessing/synchronize.py + ewarn "/dev/shm is not mounted -- expect build failures!" + fi + + # Ensure we use C locale when building, bug #746215 + export LC_ALL=C + fi + + export use_lto + + CONFIG_CHECK="~SECCOMP" + WARNING_SECCOMP="CONFIG_SECCOMP not set! This system will be unable to play DRM-protected content." + linux-info_pkg_setup +} + +src_prepare() { + if [[ ${use_lto} == "yes" ]]; then + rm -v "${WORKDIR}"/firefox-patches/*-LTO-Only-enable-LTO-*.patch || die + fi + + # Workaround for bgo#915651 on musl + if use elibc_glibc ; then + rm -v "${WORKDIR}"/firefox-patches/*bgo-748849-RUST_TARGET_override.patch || die + fi + + # Use modified patch that isn't mangled + for patch in 0013-gcc-lto-pgo-gentoo.patch 0016-bgo-929967-fix-pgo-on-musl.patch; do + cp "${FILESDIR}/${patch}" "${WORKDIR}/firefox-patches/${patch}" || die + done + + eapply "${WORKDIR}/firefox-patches" + use loong && eapply "${WORKDIR}/firefox-loong-patches" + + if has_version ">=sys-libs/glibc-2.43"; then + eapply "${FILESDIR}/icecat-140.7.1-glibc-2.43.patch" + fi + + if use system-icu && has_version ">=dev-libs/icu-78.1"; then + eapply "${FILESDIR}/firefox-146.0.1-icu78.patch" # in 147, bug #967261, bgo#967261 + fi + + # Allow user to apply any additional patches without modifing ebuild + eapply_user + + # Make cargo respect MAKEOPTS + export CARGO_BUILD_JOBS="$(makeopts_jobs)" + + # Workaround for bgo#915651 + if ! use elibc_glibc ; then + if use amd64 ; then + export RUST_TARGET="x86_64-unknown-linux-musl" + elif use x86 ; then + export RUST_TARGET="i686-unknown-linux-musl" + elif use arm64 ; then + export RUST_TARGET="aarch64-unknown-linux-musl" + elif use loong; then + # Only the LP64D ABI of LoongArch64 is actively supported among + # the wider Linux ecosystem, so the assumption is safe. + export RUST_TARGET="loongarch64-unknown-linux-musl" + elif use ppc64 ; then + export RUST_TARGET="powerpc64le-unknown-linux-musl" + elif use riscv ; then + # We can pretty safely rule out any 32-bit riscvs, but 64-bit riscvs also have tons of + # different ABIs available. riscv64gc-unknown-linux-musl seems to be the best working + # guess right now though. + elog "riscv detected, forcing a riscv64 target for now." + export RUST_TARGET="riscv64gc-unknown-linux-musl" + else + die "Unknown musl chost, please post a new bug with your rustc -vV along with emerge --info" + fi + fi + + # Pre-built wasm-sandbox path manipulation. + if use wasm-sandbox ; then + if use amd64 ; then + export wasi_arch="x86_64" + elif use arm64 ; then + export wasi_arch="arm64" + else + die "wasm-sandbox enabled on unknown/unsupported arch!" + fi + + sed -i \ + -e "s:%%PORTAGE_WORKDIR%%:${WORKDIR}:" \ + -e "s:%%WASI_ARCH%%:${wasi_arch}:" \ + -e "s:%%WASI_SDK_VER%%:${WASI_SDK_VER}:" \ + -e "s:%%WASI_SDK_LLVM_VER%%:${WASI_SDK_LLVM_VER}:" \ + toolkit/moz.configure || die "Failed to update wasi-related paths." + fi + + # Make LTO respect MAKEOPTS + sed -i -e "s/multiprocessing.cpu_count()/$(makeopts_jobs)/" \ + "${S}"/build/moz.configure/lto-pgo.configure || die "Failed sedding multiprocessing.cpu_count" + + + sed -i -e "s/multiprocessing.cpu_count()/$(makeopts_jobs)/" \ + "${S}"/third_party/chromium/build/toolchain/get_cpu_count.py || die "Failed sedding multiprocessing.cpu_count" + + sed -i -e "s/multiprocessing.cpu_count()/$(makeopts_jobs)/" \ + "${S}"/third_party/python/gyp/pylib/gyp/input.py || die "Failed sedding multiprocessing.cpu_count" + + # sed-in toolchain prefix + sed -i \ + -e "s/objdump/${CHOST}-objdump/" \ + "${S}"/python/mozbuild/mozbuild/configure/check_debug_ranges.py || die "sed failed to set toolchain prefix" + + sed -i \ + -e 's/ccache_stats = None/return None/' \ + "${S}"/python/mozbuild/mozbuild/controller/building.py || die "sed failed to disable ccache stats call" + + einfo "Removing pre-built binaries ..." + + find "${S}"/third_party -type f \( -name '*.so' -o -name '*.o' \) -print -delete || die + + # Clear checksums from cargo crates we've manually patched. + # moz_clear_vendor_checksums xyz + # glibc-2.43 + moz_clear_vendor_checksums glslopt + + # Respect choice for "jumbo-build" + # Changing the value for FILES_PER_UNIFIED_FILE may not work, see #905431 + if [[ -n ${FILES_PER_UNIFIED_FILE} ]] && use jumbo-build; then + local my_files_per_unified_file=${FILES_PER_UNIFIED_FILE:=16} + elog "" + elog "jumbo-build defaults modified to ${my_files_per_unified_file}." + elog "if you get a build failure, try undefining FILES_PER_UNIFIED_FILE," + elog "if that fails try -jumbo-build before opening a bug report." + elog "" + + sed -i -e "s/\"FILES_PER_UNIFIED_FILE\", 16/\"FILES_PER_UNIFIED_FILE\", "${my_files_per_unified_file}"/" \ + python/mozbuild/mozbuild/frontend/data.py || + die "Failed to adjust FILES_PER_UNIFIED_FILE in python/mozbuild/mozbuild/frontend/data.py" + sed -i -e "s/FILES_PER_UNIFIED_FILE = 6/FILES_PER_UNIFIED_FILE = "${my_files_per_unified_file}"/" \ + js/src/moz.build || + die "Failed to adjust FILES_PER_UNIFIED_FILE in js/src/moz.build" + fi + + # Create build dir + BUILD_DIR="${WORKDIR}/${PN}_build" + mkdir -p "${BUILD_DIR}" || die + + xdg_environment_reset +} + +src_configure() { + # Show flags set at the beginning + einfo "Current BINDGEN_CFLAGS:\t${BINDGEN_CFLAGS:-no value set}" + einfo "Current CFLAGS:\t\t${CFLAGS:-no value set}" + einfo "Current CXXFLAGS:\t\t${CXXFLAGS:-no value set}" + einfo "Current LDFLAGS:\t\t${LDFLAGS:-no value set}" + einfo "Current RUSTFLAGS:\t\t${RUSTFLAGS:-no value set}" + + local have_switched_compiler= + if use clang; then + # Force clang + einfo "Enforcing the use of clang due to USE=clang ..." + + local version_clang=$(clang --version 2>/dev/null | grep -F -- 'clang version' | awk '{ print $3 }') + [[ -n ${version_clang} ]] && version_clang=$(ver_cut 1 "${version_clang}") + [[ -z ${version_clang} ]] && die "Failed to read clang version!" + + if tc-is-gcc; then + have_switched_compiler=yes + fi + + AR=llvm-ar + CC=${CHOST}-clang-${version_clang} + CXX=${CHOST}-clang++-${version_clang} + NM=llvm-nm + RANLIB=llvm-ranlib + + elif ! use clang && ! tc-is-gcc ; then + # Force gcc + have_switched_compiler=yes + einfo "Enforcing the use of gcc due to USE=-clang ..." + AR=gcc-ar + CC=${CHOST}-gcc + CXX=${CHOST}-g++ + NM=gcc-nm + RANLIB=gcc-ranlib + fi + + if [[ -n "${have_switched_compiler}" ]] ; then + # Because we switched active compiler we have to ensure + # that no unsupported flags are set + strip-unsupported-flags + fi + + # Ensure we use correct toolchain, + # AS is used in a non-standard way by upstream, #bmo1654031 + export HOST_CC="$(tc-getBUILD_CC)" + export HOST_CXX="$(tc-getBUILD_CXX)" + export AS="$(tc-getCC) -c" + + # Configuration tests expect llvm-readelf output, bug 913130 + READELF="llvm-readelf" + + tc-export CC CXX LD AR AS NM OBJDUMP RANLIB READELF PKG_CONFIG + + # Pass the correct toolchain paths through cbindgen + if tc-is-cross-compiler ; then + export BINDGEN_CFLAGS="${SYSROOT:+--sysroot=${ESYSROOT}} --target=${CHOST} ${BINDGEN_CFLAGS-}" + fi + + # Set MOZILLA_FIVE_HOME + export MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}" + + # python/mach/mach/mixin/process.py fails to detect SHELL + export SHELL="${EPREFIX}/bin/bash" + + # Set state path + export MOZBUILD_STATE_PATH="${BUILD_DIR}" + + # Set MOZCONFIG + export MOZCONFIG="${S}/.mozconfig" + + # Initialize MOZCONFIG + mozconfig_add_options_ac '' --enable-application=browser + mozconfig_add_options_ac '' --enable-project=browser + + # Set Gentoo defaults + mozconfig_add_options_ac 'Gentoo default' \ + --allow-addon-sideload \ + --disable-cargo-incremental \ + --disable-crashreporter \ + --disable-disk-remnant-avoidance \ + --disable-geckodriver \ + --disable-install-strip \ + --disable-legacy-profile-creation \ + --disable-parental-controls \ + --disable-strip \ + --disable-updater \ + --disable-wmf \ + --enable-negotiateauth \ + --enable-new-pass-manager \ + --enable-official-branding \ + --enable-packed-relative-relocs \ + --enable-release \ + --enable-system-policies \ + --host="${CBUILD:-${CHOST}}" \ + --libdir="${EPREFIX}/usr/$(get_libdir)" \ + --prefix="${EPREFIX}/usr" \ + --target="${CHOST}" \ + --without-ccache \ + --with-intl-api \ + --with-l10n-base="${S}/l10n" \ + --with-libclang-path="$(llvm-config --libdir)" \ + --with-system-ffi \ + --with-system-gbm \ + --with-system-libdrm \ + --with-system-nspr \ + --with-system-nss \ + --with-system-pixman \ + --with-system-zlib \ + --with-toolchain-prefix="${CHOST}-" \ + --with-unsigned-addon-scopes=app,system + + # Whitelist to allow unkeyworded arches to build with "--disable-rust-simd" by default. + if use amd64 || use arm64 || use ppc64 || use loong || use riscv ; then + mozconfig_add_options_ac '' --enable-rust-simd + fi + + # For future keywording: This is currently (97.0) only supported on: + # amd64, arm, arm64 & x86. + # Might want to flip the logic around if Firefox is to support more arches. + # bug 833001, bug 903411#c8 + if use loong || use ppc64 || use riscv; then + mozconfig_add_options_ac '' --disable-sandbox + else + mozconfig_add_options_ac '' --enable-sandbox + fi + + # riscv-related options, bgo#947337, bgo#947338 + if use riscv ; then + mozconfig_add_options_ac 'Disable JIT for RISC-V 64' --disable-jit + mozconfig_add_options_ac 'Disable webrtc for RISC-V' --disable-webrtc + fi + + mozconfig_use_with system-av1 + mozconfig_use_with system-harfbuzz + mozconfig_use_with system-icu + mozconfig_use_with system-jpeg + mozconfig_use_with system-libevent + mozconfig_use_with system-libvpx + mozconfig_use_with system-pipewire + mozconfig_use_with system-png + mozconfig_use_with system-webp + + mozconfig_use_enable dbus + mozconfig_use_enable libproxy + + # --disable-eme is only supported on x86 and x86-64 + if use amd64 || use x86 ; then + mozconfig_add_options_ac '' --disable-eme + fi + + if use hardened ; then + mozconfig_add_options_ac "+hardened" --enable-hardening + append-ldflags "-Wl,-z,relro -Wl,-z,now" + + # Increase the FORTIFY_SOURCE value, #910071. + sed -i -e '/-D_FORTIFY_SOURCE=/s:2:3:' "${S}"/build/moz.configure/toolchain.configure || die + fi + + local myaudiobackends="" + use jack && myaudiobackends+="jack," + use sndio && myaudiobackends+="sndio," + use pulseaudio && myaudiobackends+="pulseaudio," + ! use pulseaudio && myaudiobackends+="alsa," + + mozconfig_add_options_ac '--enable-audio-backends' --enable-audio-backends="${myaudiobackends::-1}" + + mozconfig_use_enable wifi necko-wifi + + ! use jumbo-build && mozconfig_add_options_ac '--disable-unified-build' --disable-unified-build + + if use X && use wayland ; then + mozconfig_add_options_ac '+x11+wayland' --enable-default-toolkit=cairo-gtk3-x11-wayland + elif ! use X && use wayland ; then + mozconfig_add_options_ac '+wayland' --enable-default-toolkit=cairo-gtk3-wayland-only + else + mozconfig_add_options_ac '+x11' --enable-default-toolkit=cairo-gtk3-x11-only + fi + + # wasm-sandbox + # Since graphite2 is one of the sandboxed libraries, system-graphite2 obviously can't work with +wasm-sandbox. + if use wasm-sandbox ; then + mozconfig_add_options_ac '+wasm-sandbox' --with-wasi-sysroot="${WORKDIR}/wasi-sdk-${WASI_SDK_VER}-${wasi_arch}-linux/share/wasi-sysroot/" + else + mozconfig_add_options_ac 'no wasm-sandbox' --without-wasm-sandboxed-libraries + mozconfig_use_with system-harfbuzz system-graphite2 + fi + + if [[ ${use_lto} == "yes" ]] ; then + if use clang ; then + # Upstream only supports lld or mold when using clang. + if tc-ld-is-mold ; then + # mold expects the -flto line from *FLAGS configuration, bgo#923119 + append-ldflags "-flto=thin" + mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker=mold + else + mozconfig_add_options_ac "forcing ld=lld due to USE=clang and USE=lto" --enable-linker=lld + fi + + mozconfig_add_options_ac '+lto' --enable-lto=cross + + else + # ThinLTO is currently broken, see bmo#1644409. + # mold does not support gcc+lto combination. + mozconfig_add_options_ac '+lto' --enable-lto=full + mozconfig_add_options_ac "linker is set to bfd" --enable-linker=bfd + fi + else + # Avoid auto-magic on linker + if use clang ; then + # lld is upstream's default + if tc-ld-is-mold ; then + mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker=mold + else + mozconfig_add_options_ac "forcing ld=lld due to USE=clang" --enable-linker=lld + fi + + else + if tc-ld-is-mold ; then + mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker=mold + else + mozconfig_add_options_ac "linker is set to bfd due to USE=-clang" --enable-linker=bfd + fi + fi + fi + + # PGO was moved outside lto block to allow building pgo without lto. + if use pgo ; then + mozconfig_add_options_ac '+pgo' MOZ_PGO=1 + + # Avoid compressing just-built instrumented Firefox with + # high levels of compression. Just use tar as a container + # to save >=10 minutes. + export MOZ_PKG_FORMAT=tar + + if use clang ; then + # Used in build/pgo/profileserver.py + export LLVM_PROFDATA="llvm-profdata" + fi + fi + + mozconfig_use_enable debug + if use debug ; then + mozconfig_add_options_ac '+debug' --disable-optimize + mozconfig_add_options_ac '+debug' --enable-jemalloc + mozconfig_add_options_ac '+debug' --enable-real-time-tracing + else + mozconfig_add_options_ac 'Gentoo defaults' --disable-real-time-tracing + + if is-flag '-g*' ; then + if use clang ; then + mozconfig_add_options_ac 'from CFLAGS' --enable-debug-symbols=$(get-flag '-g*') + else + mozconfig_add_options_ac 'from CFLAGS' --enable-debug-symbols + fi + else + mozconfig_add_options_ac 'Gentoo default' --disable-debug-symbols + fi + + if is-flag '-O0' ; then + mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-O0 + elif is-flag '-O4' ; then + mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-O4 + elif is-flag '-O3' ; then + mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-O3 + elif is-flag '-O1' ; then + mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-O1 + elif is-flag '-Os' ; then + mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-Os + else + mozconfig_add_options_ac "Gentoo default" --enable-optimize=-O2 + fi + fi + + # Debug flag was handled via configure + filter-flags '-g*' + + # Optimization flag was handled via configure + filter-flags '-O*' + + # elf-hack + # Filter "-z,pack-relative-relocs" and let the build system handle it instead. + if use amd64 || use x86 ; then + filter-flags "-z,pack-relative-relocs" + + if tc-ld-is-mold ; then + # relr-elf-hack is currently broken with mold, bgo#916259 + mozconfig_add_options_ac 'disable elf-hack with mold linker' --disable-elf-hack + else + mozconfig_add_options_ac 'relr elf-hack' --enable-elf-hack=relr + fi + elif use loong || use ppc64 || use riscv ; then + # '--disable-elf-hack' is not recognized on loong/ppc64/riscv, + # see bgo #917049, #930046 + :; + else + mozconfig_add_options_ac 'disable elf-hack on non-supported arches' --disable-elf-hack + fi + + if ! use elibc_glibc; then + mozconfig_add_options_ac '!elibc_glibc' --disable-jemalloc + fi + + # System-av1 fix + use system-av1 && append-ldflags "-Wl,--undefined-version" + + # Make revdep-rebuild.sh happy; Also required for musl + append-ldflags -Wl,-rpath="${MOZILLA_FIVE_HOME}",--enable-new-dtags + + # Pass $MAKEOPTS to build system + export MOZ_MAKE_FLAGS="${MAKEOPTS}" + + # Use system's Python environment + export PIP_NETWORK_INSTALL_RESTRICTED_VIRTUALENVS=mach + + export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE="none" + + mozconfig_use_enable test tests + + # Disable notification when build system has finished + export MOZ_NOSPAM=1 + + # Portage sets XARGS environment variable to "xargs -r" by default which + # breaks build system's check_prog() function which doesn't support arguments + mozconfig_add_options_ac 'Gentoo default' "XARGS=${EPREFIX}/usr/bin/xargs" + + # Set build dir + mozconfig_add_options_mk 'Gentoo default' "MOZ_OBJDIR=${BUILD_DIR}" + + # Show flags we will use + einfo "Build BINDGEN_CFLAGS:\t${BINDGEN_CFLAGS:-no value set}" + einfo "Build CFLAGS:\t\t${CFLAGS:-no value set}" + einfo "Build CXXFLAGS:\t\t${CXXFLAGS:-no value set}" + einfo "Build LDFLAGS:\t\t${LDFLAGS:-no value set}" + einfo "Build RUSTFLAGS:\t\t${RUSTFLAGS:-no value set}" + + # Handle EXTRA_CONF and show summary + local ac opt hash reason + + # Apply EXTRA_ECONF entries to $MOZCONFIG + if [[ -n ${EXTRA_ECONF} ]] ; then + IFS=\! read -a ac <<<${EXTRA_ECONF// --/\!} + for opt in "${ac[@]}"; do + mozconfig_add_options_ac "EXTRA_ECONF" --${opt#--} + done + fi + + echo + echo "==========================================================" + echo "Building ${PF} with the following configuration" + grep ^ac_add_options "${MOZCONFIG}" | while read ac opt hash reason; do + [[ -z ${hash} || ${hash} == \# ]] \ + || die "error reading mozconfig: ${ac} ${opt} ${hash} ${reason}" + printf " %-30s %s\n" "${opt}" "${reason:-mozilla.org default}" + done + echo "==========================================================" + echo + + ./mach configure || die +} + +src_compile() { + local virtx_cmd= + + if [[ ${use_lto} == "yes" ]] && tc-ld-is-mold ; then + # increase ulimit with mold+lto, bugs #892641, #907485 + if ! ulimit -n 16384 1>/dev/null 2>&1 ; then + ewarn "Unable to modify ulimits - building with mold+lto might fail due to low ulimit -n resources." + ewarn "Please see bugs #892641 & #907485." + else + ulimit -n 16384 + fi + fi + + if use pgo; then + # Reset and cleanup environment variables used by GNOME/XDG + gnome2_environment_reset + + addpredict /root + + if ! use X; then + virtx_cmd=virtwl + else + virtx_cmd=virtx + fi + fi + + if ! use X; then + local -x GDK_BACKEND=wayland + else + local -x GDK_BACKEND=x11 + fi + + ${virtx_cmd} ./mach build --verbose || die + + # Build language packs + moz_build_xpi +} + +src_test() { + # https://firefox-source-docs.mozilla.org/testing/automated-testing/index.html + local -a failures=() + + # Some tests respect this + local -x MOZ_HEADLESS=1 + + # Check testing/mach_commands.py + einfo "Testing with cppunittest ..." + ./mach cppunittest + local ret=$? + if [[ ${ret} -ne 0 ]]; then + eerror "Test suite cppunittest failed with error code ${ret}" + failures+=( cppunittest ) + fi + + if [[ ${#failures} -eq 0 ]]; then + einfo "Test suites succeeded" + else + die "Test suites failed: ${failures[@]}" + fi +} + +src_install() { + # xpcshell is getting called during install + pax-mark m \ + "${BUILD_DIR}"/dist/bin/xpcshell \ + "${BUILD_DIR}"/dist/bin/${PN} \ + "${BUILD_DIR}"/dist/bin/plugin-container + + DESTDIR="${D}" ./mach install || die + + # Upstream cannot ship symlink but we can (bmo#658850) + rm "${ED}${MOZILLA_FIVE_HOME}/${PN}-bin" || die + dosym ${PN} ${MOZILLA_FIVE_HOME}/${PN}-bin + + # Don't install llvm-symbolizer from llvm-core/llvm package + if [[ -f "${ED}${MOZILLA_FIVE_HOME}/llvm-symbolizer" ]] ; then + rm -v "${ED}${MOZILLA_FIVE_HOME}/llvm-symbolizer" || die + fi + + # Install policy (currently only used to disable application updates) + insinto "${MOZILLA_FIVE_HOME}/distribution" + newins "${FILESDIR}"/distribution.ini distribution.ini + newins "${FILESDIR}"/disable-auto-update.policy.json policies.json + + # Install system-wide preferences + local PREFS_DIR="${MOZILLA_FIVE_HOME}/browser/defaults/preferences" + insinto "${PREFS_DIR}" + newins "${FILESDIR}"/gentoo-default-prefs.js gentoo-prefs.js + + local GENTOO_PREFS="${ED}${PREFS_DIR}/gentoo-prefs.js" + + # Set dictionary path to use system hunspell + cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set spellchecker.dictionary_path pref" + pref("spellchecker.dictionary_path", "${EPREFIX}/usr/share/myspell"); + EOF + + # Force hwaccel prefs if USE=hwaccel is enabled + if use hwaccel ; then + cat "${FILESDIR}"/gentoo-hwaccel-prefs.js-r2 \ + >>"${GENTOO_PREFS}" \ + || die "failed to add prefs to force hardware-accelerated rendering to all-gentoo.js" + + if use wayland; then + cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set hwaccel wayland prefs" + pref("gfx.x11-egl.force-enabled", false); + EOF + else + cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set hwaccel x11 prefs" + pref("gfx.x11-egl.force-enabled", true); + EOF + fi + + # Install the vaapitest binary on supported arches (122.0 supports all platforms, bmo#1865969) + exeinto "${MOZILLA_FIVE_HOME}" + doexe "${BUILD_DIR}"/dist/bin/vaapitest + + # Install the v4l2test on supported arches (+ arm, + riscv64 when keyworded) + if use arm64 ; then + exeinto "${MOZILLA_FIVE_HOME}" + doexe "${BUILD_DIR}"/dist/bin/v4l2test + fi + fi + + # Force the graphite pref if USE=system-harfbuzz is enabled, since the pref cannot disable it + if use system-harfbuzz ; then + cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set gfx.font_rendering.graphite.enabled pref" + sticky_pref("gfx.font_rendering.graphite.enabled", true); + EOF + fi + + # Install language packs + local langpacks=( $(find "${BUILD_DIR}"/dist/linux-x86_64/xpi -type f -name '*.xpi') ) + if [[ -n "${langpacks}" ]] ; then + moz_install_xpi "${MOZILLA_FIVE_HOME}/distribution/extensions" "${langpacks[@]}" + fi + + # Install icons + local icon_srcdir="${S}/browser/branding/official" + + insinto /usr/share/icons/hicolor/symbolic/apps + newins "${FILESDIR}/icon/icecat-symbolic.svg" icecat-symbolic.svg + + local icon size + for icon in "${icon_srcdir}"/default*.png ; do + size=${icon%.png} + size=${size##*/default} + + if [[ ${size} -eq 48 ]] ; then + newicon "${icon}" ${PN}.png + fi + + newicon -s ${size} "${icon}" ${PN}.png + done + + # Install menu + local app_name="GNU IceCat" + local desktop_file="${FILESDIR}/icon/${PN}-r3.desktop" + local exec_command="${PN}" + local icon="${PN}" + local use_wayland="false" + + if use wayland ; then + use_wayland="true" + fi + + cp "${desktop_file}" "${WORKDIR}/${PN}.desktop-template" || die + + sed -i \ + -e "s:@NAME@:${app_name}:" \ + -e "s:@EXEC@:${exec_command}:" \ + -e "s:@ICON@:${icon}:" \ + "${WORKDIR}/${PN}.desktop-template" || die + + newmenu "${WORKDIR}/${PN}.desktop-template" icecat.desktop + + rm "${WORKDIR}/${PN}.desktop-template" || die + + if use gnome-shell ; then + # Install search provider for Gnome + insinto /usr/share/gnome-shell/search-providers/ + doins browser/components/shell/search-provider-files/org.gnu.icecat.search-provider.ini + + insinto /usr/share/dbus-1/services/ + doins browser/components/shell/search-provider-files/org.gnu.icecat.SearchProvider.service + + # Make the dbus service aware of a previous session, bgo#939196 + sed -e \ + "s/Exec=\/usr\/bin\/icecat/Exec=\/usr\/$(get_libdir)\/icecat\/icecat --dbus-service \/usr\/bin\/icecat/g" \ + -i "${ED}/usr/share/dbus-1/services/org.gnu.icecat.SearchProvider.service" || + die "Failed to sed org.gnu.icecat.SearchProvider.service dbus file" + + # Update prefs to enable Gnome search provider + cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to enable gnome-search-provider via prefs" + pref("browser.gnome-search-provider.enabled", true); + EOF + fi + + # Install wrapper script + [[ -f "${ED}/usr/bin/${PN}" ]] && rm "${ED}/usr/bin/${PN}" + newbin "${FILESDIR}/${PN}-r1.sh" ${PN} + + # Update wrapper + sed -i \ + -e "s:@PREFIX@:${EPREFIX}/usr:" \ + -e "s:@DEFAULT_WAYLAND@:${use_wayland}:" \ + "${ED}/usr/bin/${PN}" || die + + readme.gentoo_create_doc +} + +pkg_postinst() { + xdg_pkg_postinst + + elog "Cloudflare browser checks are broken with GNU IceCats anti fingerprinting measures." + elog "You can fix cloudflare browser checks by undoing them in about:config like below:" + # Specifying (X11) is necessary for it to work, even in a Wayland session + elog " general.appversion.override: ${PV%.[0-9]*} (X11)" + elog " general.oscpu.override: Linux x86_64" + elog " general.platform.override: Linux x86_64" + + # bug 835078 + if use hwaccel && has_version "x11-drivers/xf86-video-nouveau"; then + ewarn "You have nouveau drivers installed in your system and 'hwaccel' " + ewarn "enabled for Firefox. Nouveau / your GPU might not support the " + ewarn "required EGL, so either disable 'hwaccel' or try the workaround " + ewarn "explained in https://bugs.gentoo.org/835078#c5 if Firefox crashes." + fi + + readme.gentoo_print_elog + + optfeature_header "Optional programs for extra features:" + optfeature "desktop notifications" x11-libs/libnotify + optfeature "fallback mouse cursor theme e.g. on WMs" gnome-base/gsettings-desktop-schemas + optfeature "screencasting with pipewire" sys-apps/xdg-desktop-portal + if use hwaccel && has_version "x11-drivers/nvidia-drivers"; then + optfeature "hardware acceleration with NVIDIA cards" media-libs/nvidia-vaapi-driver + fi + + if ! has_version "sys-libs/glibc"; then + elog + elog "glibc not found! You won't be able to play DRM content." + elog "See Gentoo bug #910309 or upstream bug #1843683." + elog + fi +} diff --git a/www-client/icecat/icecat-140.8.0.ebuild b/www-client/icecat/icecat-140.8.0.ebuild new file mode 100644 index 0000000..8252a7c --- /dev/null +++ b/www-client/icecat/icecat-140.8.0.ebuild @@ -0,0 +1,1266 @@ +# Copyright 1999-2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# Ebuild is based on the Firefox ebuilds in the main repo + +EAPI=8 + +# Using Gentoos firefox patches as system libraries and lto are quite nice +FIREFOX_PATCHSET="firefox-140esr-patches-07.tar.xz" +FIREFOX_LOONG_PATCHSET="firefox-139-loong-patches-02.tar.xz" + +LLVM_COMPAT=( 19 20 21 ) + +# This will also filter rust versions that don't match LLVM_COMPAT in the non-clang path; this is fine. +RUST_NEEDS_LLVM=1 +# If not building with clang we need at least rust 1.76 +RUST_MIN_VER=1.82.0 + +PYTHON_COMPAT=( python3_{11..14} ) +PYTHON_REQ_USE="ncurses,sqlite,ssl" + +VIRTUALX_REQUIRED="manual" + +# Information about the bundled wasi toolchain from +# https://github.com/WebAssembly/wasi-sdk/ +WASI_SDK_VER=30.0 +WASI_SDK_LLVM_VER=21 + +inherit check-reqs desktop flag-o-matic gnome2-utils linux-info llvm-r1 multiprocessing \ + optfeature pax-utils python-any-r1 readme.gentoo-r1 rust toolchain-funcs unpacker virtualx xdg + +DESCRIPTION="GNU IceCat Web Browser" +HOMEPAGE="https://www.gnu.org/software/gnuzilla/" + +PATCH_URIS=( + https://dev.gentoo.org/~juippis/mozilla/patchsets/${FIREFOX_PATCHSET} +) + +# Icecat tarball generated from https://cgit.git.savannah.gnu.org/cgit/gnuzilla.git +# Script modified to output zstd tarballs due to size and unpacking speed considerations. +ICECAT_REV="2gnu1" + +SRC_URI=" + https://gitlab.com/api/v4/projects/32909921/packages/generic/${PN}/${PV}-${ICECAT_REV}/${P}-${ICECAT_REV}.tar.zst + ${PATCH_URIS[@]} + loong? ( + https://dev.gentoo.org/~xen0n/distfiles/www-client/firefox/${FIREFOX_LOONG_PATCHSET} + ) + wasm-sandbox? ( + amd64? ( https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VER/.*/}/wasi-sdk-${WASI_SDK_VER}-x86_64-linux.tar.gz ) + arm64? ( https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VER/.*/}/wasi-sdk-${WASI_SDK_VER}-arm64-linux.tar.gz ) + )" +S="${WORKDIR}/${PN}-${PV%_*}" +LICENSE="MPL-2.0 GPL-2 LGPL-2.1" +SLOT="0" +KEYWORDS="~amd64" + +IUSE="+clang dbus debug hardened hwaccel jack libproxy pgo pulseaudio selinux sndio" +IUSE+=" +system-av1 +system-harfbuzz +system-icu +system-jpeg +system-libevent +system-libvpx" +IUSE+=" system-pipewire system-png +system-webp test wayland wifi +X" + +# Firefox-only IUSE +IUSE+=" gnome-shell +jumbo-build openh264 wasm-sandbox" + +REQUIRED_USE="|| ( X wayland ) + debug? ( !system-av1 ) + pgo? ( jumbo-build ) + wayland? ( dbus ) + wifi? ( dbus ) +" + +RESTRICT="!test? ( test )" + +FF_ONLY_DEPEND="selinux? ( sec-policy/selinux-mozilla )" +BDEPEND="${PYTHON_DEPS} + $(unpacker_src_uri_depends) + $(llvm_gen_dep ' + llvm-core/clang:${LLVM_SLOT} + llvm-core/llvm:${LLVM_SLOT} + clang? ( + llvm-core/lld:${LLVM_SLOT} + pgo? ( llvm-runtimes/compiler-rt-sanitizers:${LLVM_SLOT}[profile] ) + ) + wasm-sandbox? ( llvm-core/lld:${LLVM_SLOT} ) + ') + app-alternatives/awk + app-arch/unzip + app-arch/zip + >=dev-util/cbindgen-0.27.0 + net-libs/nodejs + virtual/pkgconfig + amd64? ( >=dev-lang/nasm-2.14 ) + x86? ( >=dev-lang/nasm-2.14 ) + pgo? ( + X? ( + sys-devel/gettext + x11-base/xorg-server[xvfb] + x11-apps/xhost + ) + !X? ( + gui-wm/tinywl + x11-misc/xkeyboard-config + ) + )" +COMMON_DEPEND="${FF_ONLY_DEPEND} + >=app-accessibility/at-spi2-core-2.46.0:2 + dev-libs/glib:2 + dev-libs/libffi:= + >=dev-libs/nss-3.112.3 + >=dev-libs/nspr-4.36 + media-libs/alsa-lib + media-libs/fontconfig + media-libs/freetype + media-libs/mesa + media-video/ffmpeg + virtual/zlib:= + virtual/freedesktop-icon-theme + x11-libs/cairo + x11-libs/gdk-pixbuf:2 + x11-libs/libdrm + x11-libs/pango + x11-libs/pixman + dbus? ( + sys-apps/dbus + ) + jack? ( virtual/jack ) + pulseaudio? ( + || ( + media-libs/libpulse + >=media-sound/apulse-0.1.12-r4[sdk] + ) + ) + libproxy? ( net-libs/libproxy ) + selinux? ( sec-policy/selinux-mozilla ) + sndio? ( >=media-sound/sndio-1.8.0-r1 ) + system-av1? ( + >=media-libs/dav1d-1.0.0:= + >=media-libs/libaom-3.10.0:= + ) + system-harfbuzz? ( + >=media-libs/harfbuzz-2.8.1:0= + !wasm-sandbox? ( >=media-gfx/graphite2-1.3.13 ) + ) + system-icu? ( >=dev-libs/icu-76.1:= ) + system-jpeg? ( >=media-libs/libjpeg-turbo-1.2.1:= ) + system-libevent? ( >=dev-libs/libevent-2.1.12:0=[threads(+)] ) + system-libvpx? ( >=media-libs/libvpx-1.8.2:0=[postproc] ) + system-pipewire? ( >=media-video/pipewire-1.4.7-r2:= ) + system-png? ( >=media-libs/libpng-1.6.45:0=[apng] ) + system-webp? ( >=media-libs/libwebp-1.1.0:0= ) + wayland? ( + >=media-libs/libepoxy-1.5.10-r1 + x11-libs/gtk+:3[wayland] + ) + wifi? ( + kernel_linux? ( + || ( + net-misc/networkmanager + net-misc/connman[networkmanager] + ) + sys-apps/dbus + ) + ) + X? ( + virtual/opengl + x11-libs/cairo[X] + x11-libs/gtk+:3[X] + x11-libs/libX11 + x11-libs/libXcomposite + x11-libs/libXdamage + x11-libs/libXext + x11-libs/libXfixes + x11-libs/libXrandr + x11-libs/libxcb:= + )" +RDEPEND="${COMMON_DEPEND} + hwaccel? ( + media-video/libva-utils + sys-apps/pciutils + ) + jack? ( virtual/jack ) + openh264? ( media-libs/openh264:*[plugin] )" +DEPEND="${COMMON_DEPEND} + X? ( + x11-base/xorg-proto + x11-libs/libICE + x11-libs/libSM + )" + +llvm_check_deps() { + if ! has_version -b "llvm-core/clang:${LLVM_SLOT}" ; then + einfo "llvm-core/clang:${LLVM_SLOT} is missing! Cannot use LLVM slot ${LLVM_SLOT} ..." >&2 + return 1 + fi + + if use clang && ! tc-ld-is-mold ; then + if ! has_version -b "llvm-core/lld:${LLVM_SLOT}" ; then + einfo "llvm-core/lld:${LLVM_SLOT} is missing! Cannot use LLVM slot ${LLVM_SLOT} ..." >&2 + return 1 + fi + fi + + if use pgo ; then + if ! has_version -b "=llvm-runtimes/compiler-rt-sanitizers-${LLVM_SLOT}*[profile]" ; then + einfo "=llvm-runtimes/compiler-rt-sanitizers-${LLVM_SLOT}*[profile] is missing!" >&2 + einfo "Cannot use LLVM slot ${LLVM_SLOT} ..." >&2 + return 1 + fi + fi + + einfo "Using LLVM slot ${LLVM_SLOT} to build" >&2 +} + +MOZ_LANGS=( + af ar ast be bg br ca cak cs cy da de dsb + el en-CA en-GB en-US es-AR es-ES et eu + fi fr fy-NL ga-IE gd gl he hr hsb hu + id is it ja ka kab kk ko lt lv ms nb-NO nl nn-NO + pa-IN pl pt-BR pt-PT rm ro ru + sk sl sq sr sv-SE th tr uk uz vi zh-CN zh-TW +) + +# Firefox-only LANGS +MOZ_LANGS+=( ach ) +MOZ_LANGS+=( an ) +MOZ_LANGS+=( az ) +MOZ_LANGS+=( bn ) +MOZ_LANGS+=( bs ) +MOZ_LANGS+=( ca-valencia ) +MOZ_LANGS+=( eo ) +MOZ_LANGS+=( es-CL ) +MOZ_LANGS+=( es-MX ) +MOZ_LANGS+=( fa ) +MOZ_LANGS+=( ff ) +MOZ_LANGS+=( fur ) +MOZ_LANGS+=( gn ) +MOZ_LANGS+=( gu-IN ) +MOZ_LANGS+=( hi-IN ) +MOZ_LANGS+=( hy-AM ) +MOZ_LANGS+=( ia ) +MOZ_LANGS+=( km ) +MOZ_LANGS+=( kn ) +MOZ_LANGS+=( lij ) +MOZ_LANGS+=( mk ) +MOZ_LANGS+=( mr ) +MOZ_LANGS+=( my ) +MOZ_LANGS+=( ne-NP ) +MOZ_LANGS+=( oc ) +MOZ_LANGS+=( sc ) +MOZ_LANGS+=( sco ) +MOZ_LANGS+=( si ) +MOZ_LANGS+=( skr ) +MOZ_LANGS+=( son ) +MOZ_LANGS+=( szl ) +MOZ_LANGS+=( ta ) +MOZ_LANGS+=( te ) +MOZ_LANGS+=( tl ) +MOZ_LANGS+=( trs ) +MOZ_LANGS+=( ur ) +MOZ_LANGS+=( xh ) + +mozilla_set_globals() { + # https://bugs.gentoo.org/587334 + local MOZ_TOO_REGIONALIZED_FOR_L10N=( + fy-NL ga-IE gu-IN hi-IN hy-AM nb-NO ne-NP nn-NO pa-IN sv-SE + ) + + local lang xflag + for lang in "${MOZ_LANGS[@]}" ; do + # en and en_US are handled internally + if [[ ${lang} == en ]] || [[ ${lang} == en-US ]] ; then + continue + fi + + # strip region subtag if $lang is in the list + if has ${lang} "${MOZ_TOO_REGIONALIZED_FOR_L10N[@]}" ; then + xflag=${lang%%-*} + else + xflag=${lang} + fi + + IUSE+=" l10n_${xflag/[_@]/-}" + done +} +mozilla_set_globals + +moz_clear_vendor_checksums() { + debug-print-function ${FUNCNAME} "$@" + + if [[ ${#} -ne 1 ]] ; then + die "${FUNCNAME} requires exact one argument" + fi + + einfo "Clearing cargo checksums for ${1} ..." + + sed -i \ + -e 's/\("files":{\)[^}]*/\1/' \ + "${S}"/third_party/rust/${1}/.cargo-checksum.json || die +} + +moz_build_xpi() { + debug-print-function ${FUNCNAME} "$@" + + local MOZ_TOO_REGIONALIZED_FOR_L10N=( + fy-NL ga-IE gu-IN hi-IN hy-AM nb-NO ne-NP nn-NO pa-IN sv-SE + ) + + cd "${BUILD_DIR}"/browser/locales || die + local lang xflag + for lang in "${MOZ_LANGS[@]}"; do + # en and en_US are handled internally + if [[ ${lang} == en ]] || [[ ${lang} == en-US ]] ; then + continue + fi + + # strip region subtag if $lang is in the list + if has ${lang} "${MOZ_TOO_REGIONALIZED_FOR_L10N[@]}" ; then + xflag=${lang%%-*} + else + xflag=${lang} + fi + + if use l10n_"${xflag}"; then + emake langpack-"${lang}" LOCALE_MERGEDIR=. + fi + done +} + +moz_install_xpi() { + debug-print-function ${FUNCNAME} "$@" + + if [[ ${#} -lt 2 ]] ; then + die "${FUNCNAME} requires at least two arguments" + fi + + local DESTDIR=${1} + shift + + insinto "${DESTDIR}" + + local emid xpi_file xpi_tmp_dir + for xpi_file in "${@}" ; do + emid= + xpi_tmp_dir=$(mktemp -d --tmpdir="${T}") + + # Unpack XPI + unzip -qq "${xpi_file}" -d "${xpi_tmp_dir}" || die + + # Determine extension ID + if [[ -f "${xpi_tmp_dir}/install.rdf" ]] ; then + emid=$(sed -n -e '/install-manifest/,$ { /em:id/!d; s/.*[\">]\([^\"<>]*\)[\"<].*/\1/; p; q }' "${xpi_tmp_dir}/install.rdf") + [[ -z "${emid}" ]] && die "failed to determine extension id from install.rdf" + elif [[ -f "${xpi_tmp_dir}/manifest.json" ]] ; then + emid=$(sed -n -e 's/.*"id": "\([^"]*\)".*/\1/p' "${xpi_tmp_dir}/manifest.json") + [[ -z "${emid}" ]] && die "failed to determine extension id from manifest.json" + else + die "failed to determine extension id" + fi + + einfo "Installing ${emid}.xpi into ${ED}${DESTDIR} ..." + newins "${xpi_file}" "${emid}.xpi" + done +} + +mozconfig_add_options_ac() { + debug-print-function ${FUNCNAME} "$@" + + if [[ ${#} -lt 2 ]] ; then + die "${FUNCNAME} requires at least two arguments" + fi + + local reason=${1} + shift + + local option + for option in ${@} ; do + echo "ac_add_options ${option} # ${reason}" >>${MOZCONFIG} + done +} + +mozconfig_add_options_mk() { + debug-print-function ${FUNCNAME} "$@" + + if [[ ${#} -lt 2 ]] ; then + die "${FUNCNAME} requires at least two arguments" + fi + + local reason=${1} + shift + + local option + for option in ${@} ; do + echo "mk_add_options ${option} # ${reason}" >>${MOZCONFIG} + done +} + +mozconfig_use_enable() { + debug-print-function ${FUNCNAME} "$@" + + if [[ ${#} -lt 1 ]] ; then + die "${FUNCNAME} requires at least one arguments" + fi + + local flag=$(use_enable "${@}") + mozconfig_add_options_ac "$(use ${1} && echo +${1} || echo -${1})" "${flag}" +} + +mozconfig_use_with() { + debug-print-function ${FUNCNAME} "$@" + + if [[ ${#} -lt 1 ]] ; then + die "${FUNCNAME} requires at least one arguments" + fi + + local flag=$(use_with "${@}") + mozconfig_add_options_ac "$(use ${1} && echo +${1} || echo -${1})" "${flag}" +} + +virtwl() { + debug-print-function ${FUNCNAME} "$@" + + [[ $# -lt 1 ]] && die "${FUNCNAME} needs at least one argument" + [[ -n $XDG_RUNTIME_DIR ]] || die "${FUNCNAME} needs XDG_RUNTIME_DIR to be set; try xdg_environment_reset" + tinywl -h >/dev/null || die 'tinywl -h failed' + + local VIRTWL VIRTWL_PID + coproc VIRTWL { WLR_BACKENDS=headless exec tinywl -s 'echo $WAYLAND_DISPLAY; read _; kill $PPID'; } + local -x WAYLAND_DISPLAY + read WAYLAND_DISPLAY <&${VIRTWL[0]} + + debug-print "${FUNCNAME}: $@" + "$@" + local r=$? + + [[ -n $VIRTWL_PID ]] || die "tinywl exited unexpectedly" + exec {VIRTWL[0]}<&- {VIRTWL[1]}>&- + return $r +} + +pkg_pretend() { + if [[ ${MERGE_TYPE} != binary ]] ; then + # Ensure we have enough disk space to compile + if use pgo || use debug ; then + CHECKREQS_DISK_BUILD="14300M" + elif tc-is-lto ; then + CHECKREQS_DISK_BUILD="10600M" + else + CHECKREQS_DISK_BUILD="7400M" + fi + + check-reqs_pkg_pretend + fi +} + +pkg_setup() { + + # Get LTO from environment; export after this phase for use in src_configure (etc) + use_lto=no + + if [[ ${MERGE_TYPE} != binary ]] ; then + + if tc-is-lto; then + use_lto=yes + # LTO is handled via configure + filter-lto + fi + + if use pgo ; then + if ! has userpriv ${FEATURES} ; then + eerror "Building ${PN} with USE=pgo and FEATURES=-userpriv is not supported!" + fi + fi + + if [[ ${use_lto} = yes ]]; then + # -Werror=lto-type-mismatch -Werror=odr are going to fail with GCC, + # bmo#1516758, bgo#942288 + filter-flags -Werror=lto-type-mismatch -Werror=odr + fi + + # Ensure we have enough disk space to compile + if use pgo || use debug ; then + CHECKREQS_DISK_BUILD="14300M" + elif [[ ${use_lto} == "yes" ]] ; then + CHECKREQS_DISK_BUILD="10600M" + else + CHECKREQS_DISK_BUILD="7400M" + fi + + check-reqs_pkg_setup + llvm-r1_pkg_setup + rust_pkg_setup + python-any-r1_pkg_setup + + # Avoid PGO profiling problems due to enviroment leakage + # These should *always* be cleaned up anyway + unset \ + DBUS_SESSION_BUS_ADDRESS \ + DISPLAY \ + ORBIT_SOCKETDIR \ + SESSION_MANAGER \ + XAUTHORITY \ + XDG_CACHE_HOME \ + XDG_SESSION_COOKIE + + # Build system is using /proc/self/oom_score_adj, bug #604394 + addpredict /proc/self/oom_score_adj + + if use pgo ; then + # Update 105.0: "/proc/self/oom_score_adj" isn't enough anymore with pgo, but not sure + # whether that's due to better OOM handling by Firefox (bmo#1771712), or portage + # (PORTAGE_SCHEDULING_POLICY) update... + addpredict /proc + + # Clear tons of conditions, since PGO is hardware-dependant. + addpredict /dev + fi + + if ! mountpoint -q /dev/shm ; then + # If /dev/shm is not available, configure is known to fail with + # a traceback report referencing /usr/lib/pythonN.N/multiprocessing/synchronize.py + ewarn "/dev/shm is not mounted -- expect build failures!" + fi + + # Ensure we use C locale when building, bug #746215 + export LC_ALL=C + fi + + export use_lto + + CONFIG_CHECK="~SECCOMP" + WARNING_SECCOMP="CONFIG_SECCOMP not set! This system will be unable to play DRM-protected content." + linux-info_pkg_setup +} + +src_prepare() { + if [[ ${use_lto} == "yes" ]]; then + rm -v "${WORKDIR}"/firefox-patches/*-LTO-Only-enable-LTO-*.patch || die + fi + + # Workaround for bgo#915651 on musl + if use elibc_glibc ; then + rm -v "${WORKDIR}"/firefox-patches/*bgo-748849-RUST_TARGET_override.patch || die + fi + + # Use modified patch that isn't mangled + for patch in 0013-gcc-lto-pgo-gentoo.patch 0016-bgo-929967-fix-pgo-on-musl.patch; do + cp "${FILESDIR}/${patch}" "${WORKDIR}/firefox-patches/${patch}" || die + done + + eapply "${WORKDIR}/firefox-patches" + use loong && eapply "${WORKDIR}/firefox-loong-patches" + + if use system-icu && has_version ">=dev-libs/icu-78.1"; then + eapply "${FILESDIR}/firefox-146.0.1-icu78.patch" # in 147, bug #967261, bgo#967261 + fi + + # Allow user to apply any additional patches without modifing ebuild + eapply_user + + # Make cargo respect MAKEOPTS + export CARGO_BUILD_JOBS="$(makeopts_jobs)" + + # Workaround for bgo#915651 + if ! use elibc_glibc ; then + if use amd64 ; then + export RUST_TARGET="x86_64-unknown-linux-musl" + elif use x86 ; then + export RUST_TARGET="i686-unknown-linux-musl" + elif use arm64 ; then + export RUST_TARGET="aarch64-unknown-linux-musl" + elif use loong; then + # Only the LP64D ABI of LoongArch64 is actively supported among + # the wider Linux ecosystem, so the assumption is safe. + export RUST_TARGET="loongarch64-unknown-linux-musl" + elif use ppc64 ; then + export RUST_TARGET="powerpc64le-unknown-linux-musl" + elif use riscv ; then + # We can pretty safely rule out any 32-bit riscvs, but 64-bit riscvs also have tons of + # different ABIs available. riscv64gc-unknown-linux-musl seems to be the best working + # guess right now though. + elog "riscv detected, forcing a riscv64 target for now." + export RUST_TARGET="riscv64gc-unknown-linux-musl" + else + die "Unknown musl chost, please post a new bug with your rustc -vV along with emerge --info" + fi + fi + + # Pre-built wasm-sandbox path manipulation. + if use wasm-sandbox ; then + if use amd64 ; then + export wasi_arch="x86_64" + elif use arm64 ; then + export wasi_arch="arm64" + else + die "wasm-sandbox enabled on unknown/unsupported arch!" + fi + + sed -i \ + -e "s:%%PORTAGE_WORKDIR%%:${WORKDIR}:" \ + -e "s:%%WASI_ARCH%%:${wasi_arch}:" \ + -e "s:%%WASI_SDK_VER%%:${WASI_SDK_VER}:" \ + -e "s:%%WASI_SDK_LLVM_VER%%:${WASI_SDK_LLVM_VER}:" \ + toolkit/moz.configure || die "Failed to update wasi-related paths." + fi + + # Make LTO respect MAKEOPTS + sed -i -e "s/multiprocessing.cpu_count()/$(makeopts_jobs)/" \ + "${S}"/build/moz.configure/lto-pgo.configure || die "Failed sedding multiprocessing.cpu_count" + + + sed -i -e "s/multiprocessing.cpu_count()/$(makeopts_jobs)/" \ + "${S}"/third_party/chromium/build/toolchain/get_cpu_count.py || die "Failed sedding multiprocessing.cpu_count" + + sed -i -e "s/multiprocessing.cpu_count()/$(makeopts_jobs)/" \ + "${S}"/third_party/python/gyp/pylib/gyp/input.py || die "Failed sedding multiprocessing.cpu_count" + + # sed-in toolchain prefix + sed -i \ + -e "s/objdump/${CHOST}-objdump/" \ + "${S}"/python/mozbuild/mozbuild/configure/check_debug_ranges.py || die "sed failed to set toolchain prefix" + + sed -i \ + -e 's/ccache_stats = None/return None/' \ + "${S}"/python/mozbuild/mozbuild/controller/building.py || die "sed failed to disable ccache stats call" + + einfo "Removing pre-built binaries ..." + + find "${S}"/third_party -type f \( -name '*.so' -o -name '*.o' \) -print -delete || die + + # Clear checksums from cargo crates we've manually patched. + # moz_clear_vendor_checksums xyz + # glslopt: bgo#969412 + moz_clear_vendor_checksums glslopt + + # Respect choice for "jumbo-build" + # Changing the value for FILES_PER_UNIFIED_FILE may not work, see #905431 + if [[ -n ${FILES_PER_UNIFIED_FILE} ]] && use jumbo-build; then + local my_files_per_unified_file=${FILES_PER_UNIFIED_FILE:=16} + elog "" + elog "jumbo-build defaults modified to ${my_files_per_unified_file}." + elog "if you get a build failure, try undefining FILES_PER_UNIFIED_FILE," + elog "if that fails try -jumbo-build before opening a bug report." + elog "" + + sed -i -e "s/\"FILES_PER_UNIFIED_FILE\", 16/\"FILES_PER_UNIFIED_FILE\", "${my_files_per_unified_file}"/" \ + python/mozbuild/mozbuild/frontend/data.py || + die "Failed to adjust FILES_PER_UNIFIED_FILE in python/mozbuild/mozbuild/frontend/data.py" + sed -i -e "s/FILES_PER_UNIFIED_FILE = 6/FILES_PER_UNIFIED_FILE = "${my_files_per_unified_file}"/" \ + js/src/moz.build || + die "Failed to adjust FILES_PER_UNIFIED_FILE in js/src/moz.build" + fi + + # Create build dir + BUILD_DIR="${WORKDIR}/${PN}_build" + mkdir -p "${BUILD_DIR}" || die + + xdg_environment_reset +} + +src_configure() { + # Show flags set at the beginning + einfo "Current BINDGEN_CFLAGS:\t${BINDGEN_CFLAGS:-no value set}" + einfo "Current CFLAGS:\t\t${CFLAGS:-no value set}" + einfo "Current CXXFLAGS:\t\t${CXXFLAGS:-no value set}" + einfo "Current LDFLAGS:\t\t${LDFLAGS:-no value set}" + einfo "Current RUSTFLAGS:\t\t${RUSTFLAGS:-no value set}" + + local have_switched_compiler= + if use clang; then + # Force clang + einfo "Enforcing the use of clang due to USE=clang ..." + + local version_clang=$(clang --version 2>/dev/null | grep -F -- 'clang version' | awk '{ print $3 }') + [[ -n ${version_clang} ]] && version_clang=$(ver_cut 1 "${version_clang}") + [[ -z ${version_clang} ]] && die "Failed to read clang version!" + + if tc-is-gcc; then + have_switched_compiler=yes + fi + + AR=llvm-ar + CC=${CHOST}-clang-${version_clang} + CXX=${CHOST}-clang++-${version_clang} + NM=llvm-nm + RANLIB=llvm-ranlib + + elif ! use clang && ! tc-is-gcc ; then + # Force gcc + have_switched_compiler=yes + einfo "Enforcing the use of gcc due to USE=-clang ..." + AR=gcc-ar + CC=${CHOST}-gcc + CXX=${CHOST}-g++ + NM=gcc-nm + RANLIB=gcc-ranlib + fi + + if [[ -n "${have_switched_compiler}" ]] ; then + # Because we switched active compiler we have to ensure + # that no unsupported flags are set + strip-unsupported-flags + fi + + # Ensure we use correct toolchain, + # AS is used in a non-standard way by upstream, #bmo1654031 + export HOST_CC="$(tc-getBUILD_CC)" + export HOST_CXX="$(tc-getBUILD_CXX)" + export AS="$(tc-getCC) -c" + + # Configuration tests expect llvm-readelf output, bug 913130 + READELF="llvm-readelf" + + tc-export CC CXX LD AR AS NM OBJDUMP RANLIB READELF PKG_CONFIG + + # Pass the correct toolchain paths through cbindgen + if tc-is-cross-compiler ; then + export BINDGEN_CFLAGS="${SYSROOT:+--sysroot=${ESYSROOT}} --target=${CHOST} ${BINDGEN_CFLAGS-}" + fi + + # Set MOZILLA_FIVE_HOME + export MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}" + + # python/mach/mach/mixin/process.py fails to detect SHELL + export SHELL="${EPREFIX}/bin/bash" + + # Set state path + export MOZBUILD_STATE_PATH="${BUILD_DIR}" + + # Set MOZCONFIG + export MOZCONFIG="${S}/.mozconfig" + + # Initialize MOZCONFIG + mozconfig_add_options_ac '' --enable-application=browser + mozconfig_add_options_ac '' --enable-project=browser + + # Set Gentoo defaults + mozconfig_add_options_ac 'Gentoo default' \ + --allow-addon-sideload \ + --disable-cargo-incremental \ + --disable-crashreporter \ + --disable-disk-remnant-avoidance \ + --disable-geckodriver \ + --disable-install-strip \ + --disable-legacy-profile-creation \ + --disable-parental-controls \ + --disable-strip \ + --disable-updater \ + --disable-wmf \ + --enable-negotiateauth \ + --enable-new-pass-manager \ + --enable-official-branding \ + --enable-packed-relative-relocs \ + --enable-release \ + --enable-system-policies \ + --host="${CBUILD:-${CHOST}}" \ + --libdir="${EPREFIX}/usr/$(get_libdir)" \ + --prefix="${EPREFIX}/usr" \ + --target="${CHOST}" \ + --without-ccache \ + --with-intl-api \ + --with-l10n-base="${S}/l10n" \ + --with-libclang-path="$(llvm-config --libdir)" \ + --with-system-ffi \ + --with-system-gbm \ + --with-system-libdrm \ + --with-system-nspr \ + --with-system-nss \ + --with-system-pixman \ + --with-system-zlib \ + --with-toolchain-prefix="${CHOST}-" \ + --with-unsigned-addon-scopes=app,system + + # Whitelist to allow unkeyworded arches to build with "--disable-rust-simd" by default. + if use amd64 || use arm64 || use ppc64 || use loong || use riscv ; then + mozconfig_add_options_ac '' --enable-rust-simd + fi + + # For future keywording: This is currently (97.0) only supported on: + # amd64, arm, arm64 & x86. + # Might want to flip the logic around if Firefox is to support more arches. + # bug 833001, bug 903411#c8 + if use loong || use ppc64 || use riscv; then + mozconfig_add_options_ac '' --disable-sandbox + else + mozconfig_add_options_ac '' --enable-sandbox + fi + + # riscv-related options, bgo#947337, bgo#947338 + if use riscv ; then + mozconfig_add_options_ac 'Disable JIT for RISC-V 64' --disable-jit + mozconfig_add_options_ac 'Disable webrtc for RISC-V' --disable-webrtc + fi + + mozconfig_use_with system-av1 + mozconfig_use_with system-harfbuzz + mozconfig_use_with system-icu + mozconfig_use_with system-jpeg + mozconfig_use_with system-libevent + mozconfig_use_with system-libvpx + mozconfig_use_with system-pipewire + mozconfig_use_with system-png + mozconfig_use_with system-webp + + mozconfig_use_enable dbus + mozconfig_use_enable libproxy + + # --disable-eme is only supported on x86 and x86-64 + if use amd64 || use x86 ; then + mozconfig_add_options_ac '' --disable-eme + fi + + if use hardened ; then + mozconfig_add_options_ac "+hardened" --enable-hardening + append-ldflags "-Wl,-z,relro -Wl,-z,now" + + # Increase the FORTIFY_SOURCE value, #910071. + sed -i -e '/-D_FORTIFY_SOURCE=/s:2:3:' "${S}"/build/moz.configure/toolchain.configure || die + fi + + local myaudiobackends="" + use jack && myaudiobackends+="jack," + use sndio && myaudiobackends+="sndio," + use pulseaudio && myaudiobackends+="pulseaudio," + ! use pulseaudio && myaudiobackends+="alsa," + + mozconfig_add_options_ac '--enable-audio-backends' --enable-audio-backends="${myaudiobackends::-1}" + + mozconfig_use_enable wifi necko-wifi + + ! use jumbo-build && mozconfig_add_options_ac '--disable-unified-build' --disable-unified-build + + if use X && use wayland ; then + mozconfig_add_options_ac '+x11+wayland' --enable-default-toolkit=cairo-gtk3-x11-wayland + elif ! use X && use wayland ; then + mozconfig_add_options_ac '+wayland' --enable-default-toolkit=cairo-gtk3-wayland-only + else + mozconfig_add_options_ac '+x11' --enable-default-toolkit=cairo-gtk3-x11-only + fi + + # wasm-sandbox + # Since graphite2 is one of the sandboxed libraries, system-graphite2 obviously can't work with +wasm-sandbox. + if use wasm-sandbox ; then + mozconfig_add_options_ac '+wasm-sandbox' --with-wasi-sysroot="${WORKDIR}/wasi-sdk-${WASI_SDK_VER}-${wasi_arch}-linux/share/wasi-sysroot/" + else + mozconfig_add_options_ac 'no wasm-sandbox' --without-wasm-sandboxed-libraries + mozconfig_use_with system-harfbuzz system-graphite2 + fi + + if [[ ${use_lto} == "yes" ]] ; then + if use clang ; then + # Upstream only supports lld or mold when using clang. + if tc-ld-is-mold ; then + # mold expects the -flto line from *FLAGS configuration, bgo#923119 + append-ldflags "-flto=thin" + mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker=mold + else + mozconfig_add_options_ac "forcing ld=lld due to USE=clang and USE=lto" --enable-linker=lld + fi + + mozconfig_add_options_ac '+lto' --enable-lto=cross + + else + # ThinLTO is currently broken, see bmo#1644409. + # mold does not support gcc+lto combination. + mozconfig_add_options_ac '+lto' --enable-lto=full + mozconfig_add_options_ac "linker is set to bfd" --enable-linker=bfd + fi + else + # Avoid auto-magic on linker + if use clang ; then + # lld is upstream's default + if tc-ld-is-mold ; then + mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker=mold + else + mozconfig_add_options_ac "forcing ld=lld due to USE=clang" --enable-linker=lld + fi + + else + if tc-ld-is-mold ; then + mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker=mold + else + mozconfig_add_options_ac "linker is set to bfd due to USE=-clang" --enable-linker=bfd + fi + fi + fi + + # PGO was moved outside lto block to allow building pgo without lto. + if use pgo ; then + mozconfig_add_options_ac '+pgo' MOZ_PGO=1 + + # Avoid compressing just-built instrumented Firefox with + # high levels of compression. Just use tar as a container + # to save >=10 minutes. + export MOZ_PKG_FORMAT=tar + + if use clang ; then + # Used in build/pgo/profileserver.py + export LLVM_PROFDATA="llvm-profdata" + fi + fi + + mozconfig_use_enable debug + if use debug ; then + mozconfig_add_options_ac '+debug' --disable-optimize + mozconfig_add_options_ac '+debug' --enable-jemalloc + mozconfig_add_options_ac '+debug' --enable-real-time-tracing + else + mozconfig_add_options_ac 'Gentoo defaults' --disable-real-time-tracing + + if is-flag '-g*' ; then + if use clang ; then + mozconfig_add_options_ac 'from CFLAGS' --enable-debug-symbols=$(get-flag '-g*') + else + mozconfig_add_options_ac 'from CFLAGS' --enable-debug-symbols + fi + else + mozconfig_add_options_ac 'Gentoo default' --disable-debug-symbols + fi + + if is-flag '-O0' ; then + mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-O0 + elif is-flag '-O4' ; then + mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-O4 + elif is-flag '-O3' ; then + mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-O3 + elif is-flag '-O1' ; then + mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-O1 + elif is-flag '-Os' ; then + mozconfig_add_options_ac "from CFLAGS" --enable-optimize=-Os + else + mozconfig_add_options_ac "Gentoo default" --enable-optimize=-O2 + fi + fi + + # Debug flag was handled via configure + filter-flags '-g*' + + # Optimization flag was handled via configure + filter-flags '-O*' + + # elf-hack + # Filter "-z,pack-relative-relocs" and let the build system handle it instead. + if use amd64 || use x86 ; then + filter-flags "-z,pack-relative-relocs" + + if tc-ld-is-mold ; then + # relr-elf-hack is currently broken with mold, bgo#916259 + mozconfig_add_options_ac 'disable elf-hack with mold linker' --disable-elf-hack + else + mozconfig_add_options_ac 'relr elf-hack' --enable-elf-hack=relr + fi + elif use loong || use ppc64 || use riscv ; then + # '--disable-elf-hack' is not recognized on loong/ppc64/riscv, + # see bgo #917049, #930046 + :; + else + mozconfig_add_options_ac 'disable elf-hack on non-supported arches' --disable-elf-hack + fi + + if ! use elibc_glibc; then + mozconfig_add_options_ac '!elibc_glibc' --disable-jemalloc + fi + + # System-av1 fix + use system-av1 && append-ldflags "-Wl,--undefined-version" + + # Make revdep-rebuild.sh happy; Also required for musl + append-ldflags -Wl,-rpath="${MOZILLA_FIVE_HOME}",--enable-new-dtags + + # Pass $MAKEOPTS to build system + export MOZ_MAKE_FLAGS="${MAKEOPTS}" + + # Use system's Python environment + export PIP_NETWORK_INSTALL_RESTRICTED_VIRTUALENVS=mach + + export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE="none" + + mozconfig_use_enable test tests + + # Disable notification when build system has finished + export MOZ_NOSPAM=1 + + # Portage sets XARGS environment variable to "xargs -r" by default which + # breaks build system's check_prog() function which doesn't support arguments + mozconfig_add_options_ac 'Gentoo default' "XARGS=${EPREFIX}/usr/bin/xargs" + + # Set build dir + mozconfig_add_options_mk 'Gentoo default' "MOZ_OBJDIR=${BUILD_DIR}" + + # Show flags we will use + einfo "Build BINDGEN_CFLAGS:\t${BINDGEN_CFLAGS:-no value set}" + einfo "Build CFLAGS:\t\t${CFLAGS:-no value set}" + einfo "Build CXXFLAGS:\t\t${CXXFLAGS:-no value set}" + einfo "Build LDFLAGS:\t\t${LDFLAGS:-no value set}" + einfo "Build RUSTFLAGS:\t\t${RUSTFLAGS:-no value set}" + + # Handle EXTRA_CONF and show summary + local ac opt hash reason + + # Apply EXTRA_ECONF entries to $MOZCONFIG + if [[ -n ${EXTRA_ECONF} ]] ; then + IFS=\! read -a ac <<<${EXTRA_ECONF// --/\!} + for opt in "${ac[@]}"; do + mozconfig_add_options_ac "EXTRA_ECONF" --${opt#--} + done + fi + + echo + echo "==========================================================" + echo "Building ${PF} with the following configuration" + grep ^ac_add_options "${MOZCONFIG}" | while read ac opt hash reason; do + [[ -z ${hash} || ${hash} == \# ]] \ + || die "error reading mozconfig: ${ac} ${opt} ${hash} ${reason}" + printf " %-30s %s\n" "${opt}" "${reason:-mozilla.org default}" + done + echo "==========================================================" + echo + + ./mach configure || die +} + +src_compile() { + local virtx_cmd= + + if [[ ${use_lto} == "yes" ]] && tc-ld-is-mold ; then + # increase ulimit with mold+lto, bugs #892641, #907485 + if ! ulimit -n 16384 1>/dev/null 2>&1 ; then + ewarn "Unable to modify ulimits - building with mold+lto might fail due to low ulimit -n resources." + ewarn "Please see bugs #892641 & #907485." + else + ulimit -n 16384 + fi + fi + + if use pgo; then + # Reset and cleanup environment variables used by GNOME/XDG + gnome2_environment_reset + + addpredict /root + + if ! use X; then + virtx_cmd=virtwl + else + virtx_cmd=virtx + fi + fi + + if ! use X; then + local -x GDK_BACKEND=wayland + else + local -x GDK_BACKEND=x11 + fi + + ${virtx_cmd} ./mach build --verbose || die + + # Build language packs + moz_build_xpi +} + +src_test() { + # https://firefox-source-docs.mozilla.org/testing/automated-testing/index.html + local -a failures=() + + # Some tests respect this + local -x MOZ_HEADLESS=1 + + # Check testing/mach_commands.py + einfo "Testing with cppunittest ..." + ./mach cppunittest + local ret=$? + if [[ ${ret} -ne 0 ]]; then + eerror "Test suite cppunittest failed with error code ${ret}" + failures+=( cppunittest ) + fi + + if [[ ${#failures} -eq 0 ]]; then + einfo "Test suites succeeded" + else + die "Test suites failed: ${failures[@]}" + fi +} + +src_install() { + # xpcshell is getting called during install + pax-mark m \ + "${BUILD_DIR}"/dist/bin/xpcshell \ + "${BUILD_DIR}"/dist/bin/${PN} \ + "${BUILD_DIR}"/dist/bin/plugin-container + + DESTDIR="${D}" ./mach install || die + + # Upstream cannot ship symlink but we can (bmo#658850) + rm "${ED}${MOZILLA_FIVE_HOME}/${PN}-bin" || die + dosym ${PN} ${MOZILLA_FIVE_HOME}/${PN}-bin + + # Don't install llvm-symbolizer from llvm-core/llvm package + if [[ -f "${ED}${MOZILLA_FIVE_HOME}/llvm-symbolizer" ]] ; then + rm -v "${ED}${MOZILLA_FIVE_HOME}/llvm-symbolizer" || die + fi + + # Install policy (currently only used to disable application updates) + insinto "${MOZILLA_FIVE_HOME}/distribution" + newins "${FILESDIR}"/distribution.ini distribution.ini + newins "${FILESDIR}"/disable-auto-update.policy.json policies.json + + # Install system-wide preferences + local PREFS_DIR="${MOZILLA_FIVE_HOME}/browser/defaults/preferences" + insinto "${PREFS_DIR}" + newins "${FILESDIR}"/gentoo-default-prefs.js gentoo-prefs.js + + local GENTOO_PREFS="${ED}${PREFS_DIR}/gentoo-prefs.js" + + # Set dictionary path to use system hunspell + cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set spellchecker.dictionary_path pref" + pref("spellchecker.dictionary_path", "${EPREFIX}/usr/share/myspell"); + EOF + + # Force hwaccel prefs if USE=hwaccel is enabled + if use hwaccel ; then + cat "${FILESDIR}"/gentoo-hwaccel-prefs.js-r2 \ + >>"${GENTOO_PREFS}" \ + || die "failed to add prefs to force hardware-accelerated rendering to all-gentoo.js" + + if use wayland; then + cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set hwaccel wayland prefs" + pref("gfx.x11-egl.force-enabled", false); + EOF + else + cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set hwaccel x11 prefs" + pref("gfx.x11-egl.force-enabled", true); + EOF + fi + + # Install the vaapitest binary on supported arches (122.0 supports all platforms, bmo#1865969) + exeinto "${MOZILLA_FIVE_HOME}" + doexe "${BUILD_DIR}"/dist/bin/vaapitest + + # Install the v4l2test on supported arches (+ arm, + riscv64 when keyworded) + if use arm64 ; then + exeinto "${MOZILLA_FIVE_HOME}" + doexe "${BUILD_DIR}"/dist/bin/v4l2test + fi + fi + + # Force the graphite pref if USE=system-harfbuzz is enabled, since the pref cannot disable it + if use system-harfbuzz ; then + cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set gfx.font_rendering.graphite.enabled pref" + sticky_pref("gfx.font_rendering.graphite.enabled", true); + EOF + fi + + # Install language packs + local langpacks=( $(find "${BUILD_DIR}"/dist/linux-x86_64/xpi -type f -name '*.xpi') ) + if [[ -n "${langpacks}" ]] ; then + moz_install_xpi "${MOZILLA_FIVE_HOME}/distribution/extensions" "${langpacks[@]}" + fi + + # Install icons + local icon_srcdir="${S}/browser/branding/official" + + insinto /usr/share/icons/hicolor/symbolic/apps + newins "${FILESDIR}/icon/icecat-symbolic.svg" icecat-symbolic.svg + + local icon size + for icon in "${icon_srcdir}"/default*.png ; do + size=${icon%.png} + size=${size##*/default} + + if [[ ${size} -eq 48 ]] ; then + newicon "${icon}" ${PN}.png + fi + + newicon -s ${size} "${icon}" ${PN}.png + done + + # Install menu + local app_name="GNU IceCat" + local desktop_file="${FILESDIR}/icon/${PN}-r3.desktop" + local exec_command="${PN}" + local icon="${PN}" + local use_wayland="false" + + if use wayland ; then + use_wayland="true" + fi + + cp "${desktop_file}" "${WORKDIR}/${PN}.desktop-template" || die + + sed -i \ + -e "s:@NAME@:${app_name}:" \ + -e "s:@EXEC@:${exec_command}:" \ + -e "s:@ICON@:${icon}:" \ + "${WORKDIR}/${PN}.desktop-template" || die + + newmenu "${WORKDIR}/${PN}.desktop-template" icecat.desktop + + rm "${WORKDIR}/${PN}.desktop-template" || die + + if use gnome-shell ; then + # Install search provider for Gnome + insinto /usr/share/gnome-shell/search-providers/ + doins browser/components/shell/search-provider-files/org.gnu.icecat.search-provider.ini + + insinto /usr/share/dbus-1/services/ + doins browser/components/shell/search-provider-files/org.gnu.icecat.SearchProvider.service + + # Make the dbus service aware of a previous session, bgo#939196 + sed -e \ + "s/Exec=\/usr\/bin\/icecat/Exec=\/usr\/$(get_libdir)\/icecat\/icecat --dbus-service \/usr\/bin\/icecat/g" \ + -i "${ED}/usr/share/dbus-1/services/org.gnu.icecat.SearchProvider.service" || + die "Failed to sed org.gnu.icecat.SearchProvider.service dbus file" + + # Update prefs to enable Gnome search provider + cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to enable gnome-search-provider via prefs" + pref("browser.gnome-search-provider.enabled", true); + EOF + fi + + # Install wrapper script + [[ -f "${ED}/usr/bin/${PN}" ]] && rm "${ED}/usr/bin/${PN}" + newbin "${FILESDIR}/${PN}-r1.sh" ${PN} + + # Update wrapper + sed -i \ + -e "s:@PREFIX@:${EPREFIX}/usr:" \ + -e "s:@DEFAULT_WAYLAND@:${use_wayland}:" \ + "${ED}/usr/bin/${PN}" || die + + readme.gentoo_create_doc +} + +pkg_postinst() { + xdg_pkg_postinst + + elog "Cloudflare browser checks are broken with GNU IceCats anti fingerprinting measures." + elog "You can fix cloudflare browser checks by undoing them in about:config like below:" + # Specifying (X11) is necessary for it to work, even in a Wayland session + elog " general.appversion.override: ${PV%.[0-9]*} (X11)" + elog " general.oscpu.override: Linux x86_64" + elog " general.platform.override: Linux x86_64" + + # bug 835078 + if use hwaccel && has_version "x11-drivers/xf86-video-nouveau"; then + ewarn "You have nouveau drivers installed in your system and 'hwaccel' " + ewarn "enabled for Firefox. Nouveau / your GPU might not support the " + ewarn "required EGL, so either disable 'hwaccel' or try the workaround " + ewarn "explained in https://bugs.gentoo.org/835078#c5 if Firefox crashes." + fi + + readme.gentoo_print_elog + + optfeature_header "Optional programs for extra features:" + optfeature "desktop notifications" x11-libs/libnotify + optfeature "fallback mouse cursor theme e.g. on WMs" gnome-base/gsettings-desktop-schemas + optfeature "screencasting with pipewire" sys-apps/xdg-desktop-portal + if use hwaccel && has_version "x11-drivers/nvidia-drivers"; then + optfeature "hardware acceleration with NVIDIA cards" media-libs/nvidia-vaapi-driver + fi + + if ! has_version "sys-libs/glibc"; then + elog + elog "glibc not found! You won't be able to play DRM content." + elog "See Gentoo bug #910309 or upstream bug #1843683." + elog + fi +} -- cgit v1.2.3