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