]> git.draconx.ca Git - gentoo-fixes.git/blob - www-client/firefox/firefox-52.9.0-r3.ebuild
app-emulation/wine-vanilla-4.0.4: Adapt mpg123 dependency.
[gentoo-fixes.git] / www-client / firefox / firefox-52.9.0-r3.ebuild
1 # This ebuild is a modified version of the work originally distributed with
2 # Gentoo GNU/Linux, covered by the following copyright and permission notice:
3 #
4 #   Copyright 1999-2020 Gentoo Authors
5 #   Distributed under the terms of the GNU General Public License v2
6 #
7 # The modifications are:
8 #
9 #   * Apply patches to build on modern systems (2022-12)
10 #   * Update to EAPI 8 (2023-04)
11
12 EAPI=8
13 VIRTUALX_REQUIRED="pgo"
14 WANT_AUTOCONF="2.1"
15 MOZ_ESR=1
16
17 # This list can be updated with scripts/get_langs.sh from the mozilla overlay
18 MOZ_LANGS=( ach af an ar as ast az bg bn-BD bn-IN br bs ca cak cs cy da de dsb
19 el en en-GB en-US en-ZA eo es-AR es-CL es-ES es-MX et eu fa ff fi fr fy-NL ga-IE
20 gd gl gn gu-IN he hi-IN hr hsb hu hy-AM id is it ja ka kab kk km kn ko lij lt lv
21 mai mk ml mr ms nb-NO nl nn-NO or pa-IN pl pt-BR pt-PT rm ro ru si sk sl son sq
22 sr sv-SE ta te th tr uk uz vi xh zh-CN zh-TW )
23
24 # Convert the ebuild version to the upstream mozilla version, used by mozlinguas
25 MOZ_PV="${PV/_alpha/a}" # Handle alpha for SRC_URI
26 MOZ_PV="${MOZ_PV/_beta/b}" # Handle beta for SRC_URI
27 MOZ_PV="${MOZ_PV/_rc/rc}" # Handle rc for SRC_URI
28
29 if [[ ${MOZ_ESR} == 1 ]]; then
30         # ESR releases have slightly different version numbers
31         MOZ_PV="${MOZ_PV}esr"
32 fi
33
34 # Patch version
35 PATCH="${PN}-52.5-patches-02"
36 MOZ_HTTP_URI="https://archive.mozilla.org/pub/${PN}/releases"
37
38 MOZCONFIG_OPTIONAL_GTK2ONLY=1
39 MOZCONFIG_OPTIONAL_WIFI=1
40
41 inherit check-reqs flag-o-matic toolchain-funcs desktop mozconfig-v6.52 pax-utils xdg-utils autotools virtualx mozlinguas-v2
42
43 DESCRIPTION="Firefox Web Browser"
44 HOMEPAGE="https://www.mozilla.org/firefox"
45
46 KEYWORDS="~alpha amd64 ~arm ~arm64 ~ia64 ~ppc ~ppc64 x86 ~amd64-linux ~x86-linux"
47
48 SLOT="0"
49 LICENSE="MPL-2.0 GPL-2 LGPL-2.1"
50 IUSE="bindist eme-free +gmp-autoupdate hardened hwaccel jack pgo rust selinux test"
51 RESTRICT="!bindist? ( bindist ) !test? ( test )"
52
53 PATCH_URIS=( https://dev.gentoo.org/~{anarchy,axs,polynomial-c}/mozilla/patchsets/${PATCH}.tar.xz )
54 SRC_URI="${SRC_URI}
55         ${MOZ_HTTP_URI}/${MOZ_PV}/source/firefox-${MOZ_PV}.source.tar.xz
56         ${PATCH_URIS[@]}"
57
58 ASM_DEPEND=">=dev-lang/yasm-1.1"
59
60 RDEPEND="
61         jack? ( virtual/jack )
62         >=dev-libs/nss-3.28.3
63         >=dev-libs/nspr-4.13.1
64         selinux? ( sec-policy/selinux-mozilla )"
65
66 DEPEND="${RDEPEND}
67         pgo? ( >=sys-devel/gcc-4.5 )
68         rust? ( virtual/rust )
69         amd64? ( ${ASM_DEPEND} virtual/opengl )
70         x86? ( ${ASM_DEPEND} virtual/opengl )"
71
72 S="${WORKDIR}/firefox-${MOZ_PV}"
73
74 QA_PRESTRIPPED="usr/lib*/${PN}/firefox"
75
76 BUILD_OBJ_DIR="${S}/ff"
77
78 # allow GMP_PLUGIN_LIST to be set in an eclass or
79 # overridden in the enviromnent (advanced hackers only)
80 if [[ -z $GMP_PLUGIN_LIST ]]; then
81         GMP_PLUGIN_LIST=( gmp-gmpopenh264 gmp-widevinecdm )
82 fi
83
84 pkg_setup() {
85         moz_pkgsetup
86
87         # Avoid PGO profiling problems due to enviroment leakage
88         # These should *always* be cleaned up anyway
89         unset DBUS_SESSION_BUS_ADDRESS \
90                 DISPLAY \
91                 ORBIT_SOCKETDIR \
92                 SESSION_MANAGER \
93                 XDG_SESSION_COOKIE \
94                 XAUTHORITY
95
96         if ! use bindist; then
97                 einfo
98                 elog "You are enabling official branding. You may not redistribute this build"
99                 elog "to any users on your network or the internet. Doing so puts yourself into"
100                 elog "a legal problem with Mozilla Foundation"
101                 elog "You can disable it by emerging ${PN} _with_ the bindist USE-flag"
102         fi
103
104         if use pgo; then
105                 einfo
106                 ewarn "You will do a double build for profile guided optimization."
107                 ewarn "This will result in your build taking at least twice as long as before."
108         fi
109
110         if use rust; then
111                 einfo
112                 ewarn "This is very experimental, should only be used by those developing firefox."
113         fi
114 }
115
116 pkg_pretend() {
117         # Ensure we have enough disk space to compile
118         if use pgo || use debug || use test ; then
119                 CHECKREQS_DISK_BUILD="8G"
120         else
121                 CHECKREQS_DISK_BUILD="4G"
122         fi
123         check-reqs_pkg_setup
124 }
125
126 src_unpack() {
127         unpack ${A}
128
129         # Unpack language packs
130         mozlinguas_src_unpack
131 }
132
133 src_prepare() {
134         xdg_environment_reset
135
136         # Apply our patches
137         rm -f "${WORKDIR}"/firefox/2007_fix_nvidia_latest.patch
138         eapply "${WORKDIR}/firefox"
139
140         eapply "${FILESDIR}"/${P}-blessings-TERM.patch # 654316
141         eapply "${FILESDIR}"/${P}-fix-missing-includes.patch
142         eapply "${FILESDIR}"/${P}-fix-idb-name-conflict.patch
143         eapply "${FILESDIR}"/${P}-glibc-2.30.patch
144         eapply "${FILESDIR}"/${P}-glibc-2.36.patch
145         eapply "${FILESDIR}"/${P}-less-werror.patch
146         eapply "${FILESDIR}"/${P}-fix-thebes-templates.patch
147
148         # Enable gnomebreakpad
149         if use debug ; then
150                 sed -i -e "s:GNOME_DISABLE_CRASH_DIALOG=1:GNOME_DISABLE_CRASH_DIALOG=0:g" \
151                         "${S}"/build/unix/run-mozilla.sh || die "sed failed!"
152         fi
153
154         # Drop -Wl,--as-needed related manipulation for ia64 as it causes ld sefgaults, bug #582432
155         if use ia64 ; then
156                 sed -i \
157                 -e '/^OS_LIBS += no_as_needed/d' \
158                 -e '/^OS_LIBS += as_needed/d' \
159                 "${S}"/widget/gtk/mozgtk/gtk2/moz.build \
160                 "${S}"/widget/gtk/mozgtk/gtk3/moz.build \
161                 || die "sed failed to drop --as-needed for ia64"
162         fi
163
164         # Ensure that our plugins dir is enabled as default
165         sed -i -e "s:/usr/lib/mozilla/plugins:/usr/lib/nsbrowser/plugins:" \
166                 "${S}"/xpcom/io/nsAppFileLocationProvider.cpp || die "sed failed to replace plugin path for 32bit!"
167         sed -i -e "s:/usr/lib64/mozilla/plugins:/usr/lib64/nsbrowser/plugins:" \
168                 "${S}"/xpcom/io/nsAppFileLocationProvider.cpp || die "sed failed to replace plugin path for 64bit!"
169
170         # Fix sandbox violations during make clean, bug 372817
171         sed -e "s:\(/no-such-file\):${T}\1:g" \
172                 -i "${S}"/config/rules.mk \
173                 -i "${S}"/nsprpub/configure{.in,} \
174                 || die
175
176         # Don't exit with error when some libs are missing which we have in
177         # system.
178         sed '/^MOZ_PKG_FATAL_WARNINGS/s@= 1@= 0@' \
179                 -i "${S}"/browser/installer/Makefile.in || die
180
181         # Don't error out when there's no files to be removed:
182         sed 's@\(xargs rm\)$@\1 -f@' \
183                 -i "${S}"/toolkit/mozapps/installer/packager.mk || die
184
185         # Keep codebase the same even if not using official branding
186         sed '/^MOZ_DEV_EDITION=1/d' \
187                 -i "${S}"/browser/branding/aurora/configure.sh || die
188
189         # Allow user to apply any additional patches without modifing ebuild
190         eapply_user
191
192         # Autotools configure is now called old-configure.in
193         # This works because there is still a configure.in that happens to be for the
194         # shell wrapper configure script
195         eautoreconf old-configure.in
196
197         # Must run autoconf in js/src
198         cd "${S}"/js/src || die
199         eautoconf old-configure.in
200
201         # Need to update jemalloc's configure
202         cd "${S}"/memory/jemalloc/src || die
203         WANT_AUTOCONF= eautoconf
204 }
205
206 src_configure() {
207         MEXTENSIONS="default"
208         # Google API keys (see http://www.chromium.org/developers/how-tos/api-keys)
209         # Note: These are for Gentoo Linux use ONLY. For your own distribution, please
210         # get your own set of keys.
211         _google_api_key=AIzaSyDEAOvatFo0eTgsV_ZlEzx0ObmepsMzfAc
212
213         ####################################
214         #
215         # mozconfig, CFLAGS and CXXFLAGS setup
216         #
217         ####################################
218
219         mozconfig_init
220         mozconfig_config
221
222         # enable JACK, bug 600002
223         mozconfig_use_enable jack
224
225         use eme-free && mozconfig_annotate '+eme-free' --disable-eme
226
227         # It doesn't compile on alpha without this LDFLAGS
228         use alpha && append-ldflags "-Wl,--no-relax"
229
230         # Add full relro support for hardened
231         use hardened && append-ldflags "-Wl,-z,relro,-z,now"
232
233         # Only available on mozilla-overlay for experimentation -- Removed in Gentoo repo per bug 571180
234         #use egl && mozconfig_annotate 'Enable EGL as GL provider' --with-gl-provider=EGL
235
236         # Setup api key for location services
237         echo -n "${_google_api_key}" > "${S}"/google-api-key
238         mozconfig_annotate '' --with-google-api-keyfile="${S}/google-api-key"
239
240         mozconfig_annotate '' --enable-extensions="${MEXTENSIONS}"
241
242         mozconfig_use_enable rust
243
244         # Allow for a proper pgo build
245         if use pgo; then
246                 echo "mk_add_options PROFILE_GEN_SCRIPT='EXTRA_TEST_ARGS=10 \$(MAKE) -C \$(MOZ_OBJDIR) pgo-profile-run'" >> "${S}"/.mozconfig
247         fi
248
249         echo "mk_add_options MOZ_OBJDIR=${BUILD_OBJ_DIR}" >> "${S}"/.mozconfig
250         echo "mk_add_options XARGS=/usr/bin/xargs" >> "${S}"/.mozconfig
251
252         # Finalize and report settings
253         mozconfig_final
254
255         if [[ $(gcc-major-version) -lt 4 ]]; then
256                 append-cxxflags -fno-stack-protector
257 #       else
258 #               append-cxxflags -fpermissive
259         fi
260
261         # workaround for funky/broken upstream configure...
262         SHELL="${SHELL:-${EPREFIX}/bin/bash}" \
263         emake -f client.mk configure
264 }
265
266 src_compile() {
267         if use pgo; then
268                 addpredict /root
269                 addpredict /etc/gconf
270
271                 # Firefox tries to use dri stuff when it's run, see bug 380283
272                 shopt -s nullglob
273                 cards=$(echo -n /dev/dri/card* | sed 's/ /:/g')
274                 if test -z "${cards}"; then
275                         cards=$(echo -n /dev/ati/card* /dev/nvidiactl* | sed 's/ /:/g')
276                         if test -n "${cards}"; then
277                                 # Binary drivers seem to cause access violations anyway, so
278                                 # let's use indirect rendering so that the device files aren't
279                                 # touched at all. See bug 394715.
280                                 export LIBGL_ALWAYS_INDIRECT=1
281                         fi
282                 fi
283                 shopt -u nullglob
284                 [[ -n "${cards}" ]] && addpredict "${cards}"
285
286                 MOZ_MAKE_FLAGS="${MAKEOPTS}" SHELL="${SHELL:-${EPREFIX}/bin/bash}" \
287                 virtx emake -f client.mk profiledbuild
288         else
289                 MOZ_MAKE_FLAGS="${MAKEOPTS}" SHELL="${SHELL:-${EPREFIX}/bin/bash}" \
290                 emake -f client.mk realbuild
291         fi
292
293 }
294
295 src_install() {
296         cd "${BUILD_OBJ_DIR}" || die
297
298         # Pax mark xpcshell for hardened support, only used for startupcache creation.
299         pax-mark m "${BUILD_OBJ_DIR}"/dist/bin/xpcshell
300
301         # Add our default prefs for firefox
302         cp "${FILESDIR}"/gentoo-default-prefs.js-1 \
303                 "${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js" \
304                 || die
305
306         mozconfig_install_prefs \
307                 "${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js"
308
309         # Augment this with hwaccel prefs
310         if use hwaccel ; then
311                 cat "${FILESDIR}"/gentoo-hwaccel-prefs.js-1 >> \
312                 "${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js" \
313                 || die
314         fi
315
316         echo "pref(\"extensions.autoDisableScopes\", 3);" >> \
317                 "${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js" \
318                 || die
319
320         local plugin
321         use gmp-autoupdate || use eme-free || for plugin in "${GMP_PLUGIN_LIST[@]}" ; do
322                 echo "pref(\"media.${plugin}.autoupdate\", false);" >> \
323                         "${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js" \
324                         || die
325         done
326
327         MOZ_MAKE_FLAGS="${MAKEOPTS}" SHELL="${SHELL:-${EPREFIX}/bin/bash}" \
328         emake DESTDIR="${D}" install
329
330         # Install language packs
331         mozlinguas_src_install
332
333         local size sizes icon_path icon name
334         if use bindist; then
335                 sizes="16 32 48"
336                 icon_path="${S}/browser/branding/aurora"
337                 # Firefox's new rapid release cycle means no more codenames
338                 # Let's just stick with this one...
339                 icon="aurora"
340                 name="Aurora"
341
342                 # Override preferences to set the MOZ_DEV_EDITION defaults, since we
343                 # don't define MOZ_DEV_EDITION to avoid profile debaucles.
344                 # (source: browser/app/profile/firefox.js)
345                 cat >>"${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js" <<PROFILE_EOF
346 pref("app.feedback.baseURL", "https://input.mozilla.org/%LOCALE%/feedback/firefoxdev/%VERSION%/");
347 sticky_pref("lightweightThemes.selectedThemeID", "firefox-devedition@mozilla.org");
348 sticky_pref("browser.devedition.theme.enabled", true);
349 sticky_pref("devtools.theme", "dark");
350 PROFILE_EOF
351
352         else
353                 sizes="16 22 24 32 256"
354                 icon_path="${S}/browser/branding/official"
355                 icon="${PN}"
356                 name="Mozilla Firefox"
357         fi
358
359         # Install icons and .desktop for menu entry
360         for size in ${sizes}; do
361                 insinto "/usr/share/icons/hicolor/${size}x${size}/apps"
362                 newins "${icon_path}/default${size}.png" "${icon}.png"
363         done
364         # The 128x128 icon has a different name
365         insinto "/usr/share/icons/hicolor/128x128/apps"
366         newins "${icon_path}/mozicon128.png" "${icon}.png"
367         # Install a 48x48 icon into /usr/share/pixmaps for legacy DEs
368         newicon "${icon_path}/content/icon48.png" "${icon}.png"
369         newmenu "${FILESDIR}/icon/${PN}.desktop" "${PN}.desktop"
370         sed -i -e "s:@NAME@:${name}:" -e "s:@ICON@:${icon}:" \
371                 "${ED}/usr/share/applications/${PN}.desktop" || die
372
373         # Add StartupNotify=true bug 237317
374         if use startup-notification ; then
375                 echo "StartupNotify=true"\
376                          >> "${ED}/usr/share/applications/${PN}.desktop" \
377                         || die
378         fi
379
380         # Required in order to use plugins and even run firefox on hardened.
381         pax-mark m "${ED}"${MOZILLA_FIVE_HOME}/{firefox,firefox-bin,plugin-container}
382 }
383
384 pkg_preinst() {
385         # if the apulse libs are available in MOZILLA_FIVE_HOME then apulse
386         # doesn't need to be forced into the LD_LIBRARY_PATH
387         if use pulseaudio && has_version ">=media-sound/apulse-0.1.9" ; then
388                 einfo "APULSE found - Generating library symlinks for sound support"
389                 local lib
390                 pushd "${ED}"${MOZILLA_FIVE_HOME} &>/dev/null || die
391                 for lib in ../apulse/libpulse{.so{,.0},-simple.so{,.0}} ; do
392                         # a quickpkg rolled by hand will grab symlinks as part of the package,
393                         # so we need to avoid creating them if they already exist.
394                         if ! [ -L ${lib##*/} ]; then
395                                 ln -s "${lib}" ${lib##*/} || die
396                         fi
397                 done
398                 popd &>/dev/null || die
399         fi
400 }
401
402 pkg_postinst() {
403         # Update mimedb for the new .desktop file
404         xdg_desktop_database_update
405         xdg_icon_cache_update
406
407         if ! use gmp-autoupdate && ! use eme-free ; then
408                 elog "USE='-gmp-autoupdate' has disabled the following plugins from updating or"
409                 elog "installing into new profiles:"
410                 local plugin
411                 for plugin in "${GMP_PLUGIN_LIST[@]}"; do elog "\t ${plugin}" ; done
412         fi
413
414         if use pulseaudio && has_version ">=media-sound/apulse-0.1.9" ; then
415                 elog "Apulse was detected at merge time on this system and so it will always be"
416                 elog "used for sound.  If you wish to use pulseaudio instead please unmerge"
417                 elog "media-sound/apulse."
418         fi
419 }
420
421 pkg_postrm() {
422         xdg_desktop_database_update
423         xdg_icon_cache_update
424 }