dev-python/pytest: arm64 stable (bug #723996)
[gentoo.git] / www-client / firefox-bin / firefox-bin-76.0.1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 MOZ_ESR=0
6
7 # Can be updated using scripts/get_langs.sh from mozilla overlay
8 MOZ_LANGS=(ach af an ar ast az be bg bn br bs ca cak cs cy da de dsb el en en-CA
9 en-GB en-US eo es-AR es-CL es-ES es-MX et eu fa ff fi fr fy-NL ga-IE gd gl gn gu-IN
10 he hi-IN hr hsb hu hy-AM ia id is it ja ka kab kk km kn ko lij lt lv mk mr ms my
11 nb-NO nl nn-NO oc pa-IN pl pt-BR pt-PT rm ro ru si sk sl son sq sr sv-SE ta te
12 th tr uk ur uz vi xh zh-CN zh-TW )
13
14 # Convert the ebuild version to the upstream mozilla version, used by mozlinguas
15 MOZ_PV="${PV/_beta/b}" # Handle beta for SRC_URI
16 MOZ_PV="${MOZ_PV/_rc/rc}" # Handle rc for SRC_URI
17 MOZ_PN="${PN/-bin}"
18 if [[ ${MOZ_ESR} == 1 ]]; then
19         # ESR releases have slightly version numbers
20         MOZ_PV="${MOZ_PV}esr"
21 fi
22 MOZ_P="${MOZ_PN}-${MOZ_PV}"
23
24 MOZ_HTTP_URI="https://archive.mozilla.org/pub/mozilla.org/${MOZ_PN}/releases/"
25
26 inherit mozlinguas-v2 nsplugins pax-utils xdg-utils eapi7-ver
27
28 DESCRIPTION="Firefox Web Browser"
29 SRC_URI="${SRC_URI}
30         amd64? ( ${MOZ_HTTP_URI%/}/${MOZ_PV}/linux-x86_64/en-US/${MOZ_P}.tar.bz2 -> ${PN}_x86_64-${PV}.tar.bz2 )
31         x86? ( ${MOZ_HTTP_URI%/}/${MOZ_PV}/linux-i686/en-US/${MOZ_P}.tar.bz2 -> ${PN}_i686-${PV}.tar.bz2 )"
32 HOMEPAGE="https://www.mozilla.org/en-US/firefox/"
33 RESTRICT="strip mirror"
34
35 KEYWORDS="-* amd64 x86"
36 SLOT="0"
37 LICENSE="MPL-2.0 GPL-2 LGPL-2.1"
38 IUSE="+alsa +ffmpeg +pulseaudio selinux startup-notification wayland"
39
40 DEPEND="app-arch/unzip
41         alsa? (
42                 !pulseaudio? (
43                         dev-util/patchelf
44                         media-sound/apulse
45                 )
46         )"
47 RDEPEND="dev-libs/atk
48         >=sys-apps/dbus-0.60
49         >=dev-libs/dbus-glib-0.72
50         >=dev-libs/glib-2.26:2
51         media-libs/fontconfig
52         >=media-libs/freetype-2.4.10
53         >=x11-libs/cairo-1.10[X]
54         x11-libs/gdk-pixbuf
55         >=x11-libs/gtk+-2.18:2
56         >=x11-libs/gtk+-3.4.0:3
57         x11-libs/libX11
58         x11-libs/libXcomposite
59         x11-libs/libXdamage
60         x11-libs/libXext
61         x11-libs/libXfixes
62         x11-libs/libXrender
63         x11-libs/libXt
64         >=x11-libs/pango-1.22.0
65         virtual/freedesktop-icon-theme
66         alsa? (
67                 !pulseaudio? (
68                         media-sound/apulse
69                 )
70         )
71         pulseaudio? ( media-sound/pulseaudio )
72         ffmpeg? ( media-video/ffmpeg )
73         selinux? ( sec-policy/selinux-mozilla )
74 "
75
76 QA_PREBUILT="
77         opt/${MOZ_PN}/*.so
78         opt/${MOZ_PN}/${MOZ_PN}
79         opt/${MOZ_PN}/${PN}
80         opt/${MOZ_PN}/crashreporter
81         opt/${MOZ_PN}/webapprt-stub
82         opt/${MOZ_PN}/plugin-container
83         opt/${MOZ_PN}/mozilla-xremote-client
84         opt/${MOZ_PN}/updater
85         opt/${MOZ_PN}/minidump-analyzer
86         opt/${MOZ_PN}/pingsender
87 "
88
89 S="${WORKDIR}/${MOZ_PN}"
90
91 src_unpack() {
92         unpack ${A}
93
94         # Unpack language packs
95         mozlinguas_src_unpack
96 }
97
98 src_install() {
99         local MOZILLA_FIVE_HOME=/opt/${MOZ_PN}
100
101         # Install firefox in /opt
102         dodir ${MOZILLA_FIVE_HOME%/*}
103         mv "${S}" "${ED%/}"${MOZILLA_FIVE_HOME} || die
104         cd "${WORKDIR}" || die
105
106         # Install language packs
107         MOZEXTENSION_TARGET="distribution/extensions" \
108                 MOZ_INSTALL_L10N_XPIFILE="1" \
109                 mozlinguas_src_install
110
111         # Disable built-in auto-update because we update firefox-bin through package manager
112         insinto ${MOZILLA_FIVE_HOME}/distribution/
113         newins "${FILESDIR}"/disable-auto-update.policy.json policies.json
114
115         # Fix prefs that make no sense for a system-wide install
116         insinto ${MOZILLA_FIVE_HOME}/defaults/pref/
117         doins "${FILESDIR}"/local-settings.js
118         insinto ${MOZILLA_FIVE_HOME}
119         newins "${FILESDIR}"/all-gentoo-3.js all-gentoo.js
120
121         local size sizes icon_path icon name
122         sizes="16 32 48 128"
123         icon_path="${MOZILLA_FIVE_HOME}/browser/chrome/icons/default"
124         icon="${PN}"
125         name="Mozilla Firefox (bin)"
126
127         local apulselib=
128         if use alsa && ! use pulseaudio; then
129                 apulselib="${EPREFIX%/}/usr/$(get_libdir)/apulse"
130                 patchelf --set-rpath "${apulselib}" "${ED%/}"${MOZILLA_FIVE_HOME}/libxul.so || die
131         fi
132
133         # Install icons and .desktop for menu entry
134         for size in ${sizes} ; do
135                 insinto "/usr/share/icons/hicolor/${size}x${size}/apps"
136                 newins "${ED%/}${icon_path}/default${size}.png" "${icon}.png"
137         done
138         # Install a 48x48 icon into /usr/share/pixmaps for legacy DEs
139         newicon "${ED%/}${MOZILLA_FIVE_HOME}/browser/chrome/icons/default/default48.png" ${PN}.png
140
141         # Add StartupNotify=true bug 237317
142         local startup_notify="false"
143         if use startup-notification ; then
144                 startup_notify="true"
145         fi
146
147         local display_protocols="auto X11" use_wayland="false"
148         if use wayland ; then
149                 display_protocols+=" Wayland"
150                 use_wayland="true"
151         fi
152
153         local app_name desktop_filename display_protocol exec_command
154         for display_protocol in ${display_protocols} ; do
155                 app_name="${name} on ${display_protocol}"
156                 desktop_filename="${PN}-${display_protocol,,}.desktop"
157
158                 case ${display_protocol} in
159                         Wayland)
160                                 exec_command="${PN}-wayland --name ${PN}-wayland"
161                                 newbin "${FILESDIR}"/firefox-bin-wayland.sh ${PN}-wayland
162                                 ;;
163                         X11)
164                                 if ! use wayland ; then
165                                         # Exit loop here because there's no choice so
166                                         # we don't need wrapper/.desktop file for X11.
167                                         continue
168                                 fi
169
170                                 exec_command="${PN}-x11 --name ${PN}-x11"
171                                 newbin "${FILESDIR}"/firefox-bin-x11.sh ${PN}-x11
172                                 ;;
173                         *)
174                                 app_name="${name}"
175                                 desktop_filename="${PN}.desktop"
176                                 exec_command='firefox-bin'
177                                 ;;
178                 esac
179
180                 newmenu "${FILESDIR}/${PN}-r1.desktop" "${desktop_filename}"
181                 sed -i \
182                         -e "s:@NAME@:${app_name}:" \
183                         -e "s:@EXEC@:${exec_command}:" \
184                         -e "s:@ICON@:${icon}:" \
185                         -e "s:@STARTUP_NOTIFY@:${startup_notify}:" \
186                         "${ED%/}/usr/share/applications/${desktop_filename}" || die
187         done
188
189         rm -f "${ED%/}"/usr/bin/firefox-bin || die
190         newbin "${FILESDIR}"/firefox-bin.sh firefox-bin
191
192         local wrapper
193         for wrapper in \
194                 "${ED%/}"/usr/bin/firefox-bin \
195                 "${ED%/}"/usr/bin/firefox-bin-x11 \
196                 "${ED%/}"/usr/bin/firefox-bin-wayland \
197         ; do
198                 [[ ! -f "${wrapper}" ]] && continue
199
200                 sed -i \
201                         -e "s:@PREFIX@:${EPREFIX%/}/usr:" \
202                         -e "s:@MOZ_FIVE_HOME@:${MOZILLA_FIVE_HOME}:" \
203                         -e "s:@APULSELIB_DIR@:${apulselib}:" \
204                         -e "s:@DEFAULT_WAYLAND@:${use_wayland}:" \
205                         "${wrapper}" || die
206         done
207
208         # revdep-rebuild entry
209         insinto /etc/revdep-rebuild
210         echo "SEARCH_DIRS_MASK=${MOZILLA_FIVE_HOME}" >> ${T}/10${PN}
211         doins "${T}"/10${PN}
212
213         # Plugins dir, still used for flash
214         share_plugins_dir
215
216         # Required in order to use plugins and even run firefox on hardened.
217         pax-mark mr "${ED%/}"${MOZILLA_FIVE_HOME}/{firefox,firefox-bin,plugin-container}
218 }
219
220 pkg_postinst() {
221         # Update mimedb for the new .desktop file
222         xdg_desktop_database_update
223         xdg_icon_cache_update
224
225         if ! has_version 'gnome-base/gconf' || ! has_version 'gnome-base/orbit' \
226                 || ! has_version 'net-misc/curl'; then
227                 einfo
228                 einfo "For using the crashreporter, you need gnome-base/gconf,"
229                 einfo "gnome-base/orbit and net-misc/curl emerged."
230                 einfo
231         fi
232
233         use ffmpeg || ewarn "USE=-ffmpeg : HTML5 video will not render without media-video/ffmpeg installed"
234
235         local HAS_AUDIO=0
236         if use alsa || use pulseaudio; then
237                 HAS_AUDIO=1
238         fi
239
240         if [[ ${HAS_AUDIO} -eq 0 ]] ; then
241                 ewarn "USE=-pulseaudio & USE=-alsa : For audio please either set USE=pulseaudio or USE=alsa!"
242         fi
243
244         local show_doh_information show_normandy_information
245
246         if [[ -z "${REPLACING_VERSIONS}" ]] ; then
247                 # New install; Tell user that DoH is disabled by default
248                 show_doh_information=yes
249                 show_normandy_information=yes
250         else
251                 local replacing_version
252                 for replacing_version in ${REPLACING_VERSIONS} ; do
253                         if ver_test "${replacing_version}" -lt 70 ; then
254                                 # Tell user only once about our DoH default
255                                 show_doh_information=yes
256                         fi
257
258                         if ver_test "${replacing_version}" -lt 74.0-r1 ; then
259                                 # Tell user only once about our Normandy default
260                                 show_normandy_information=yes
261                         fi
262                 done
263         fi
264
265         if [[ -n "${show_doh_information}" ]] ; then
266                 elog
267                 elog "Note regarding Trusted Recursive Resolver aka DNS-over-HTTPS (DoH):"
268                 elog "Due to privacy concerns (encrypting DNS might be a good thing, sending all"
269                 elog "DNS traffic to Cloudflare by default is not a good idea and applications"
270                 elog "should respect OS configured settings), \"network.trr.mode\" was set to 5"
271                 elog "(\"Off by choice\") by default."
272                 elog "You can enable DNS-over-HTTPS in ${PN^}'s preferences."
273         fi
274
275         # bug 713782
276         if [[ -n "${show_normandy_information}" ]] ; then
277                 elog
278                 elog "Upstream operates a service named Normandy which allows Mozilla to"
279                 elog "push changes for default settings or even install new add-ons remotely."
280                 elog "While this can be useful to address problems like 'Armagadd-on 2.0' or"
281                 elog "revert previous decisions to disable TLS 1.0/1.1, privacy and security"
282                 elog "concerns prevail, which is why we have switched off the use of this"
283                 elog "service by default."
284                 elog
285                 elog "To re-enable this service set"
286                 elog
287                 elog "    app.normandy.enabled=true"
288                 elog
289                 elog "in about:config."
290         fi
291 }
292
293 pkg_postrm() {
294         xdg_desktop_database_update
295         xdg_icon_cache_update
296 }