1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
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 )
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
18 if [[ ${MOZ_ESR} == 1 ]]; then
19 # ESR releases have slightly version numbers
22 MOZ_P="${MOZ_PN}-${MOZ_PV}"
24 MOZ_HTTP_URI="https://archive.mozilla.org/pub/mozilla.org/${MOZ_PN}/releases/"
26 inherit mozlinguas-v2 nsplugins pax-utils xdg-utils eapi7-ver
28 DESCRIPTION="Firefox Web Browser"
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"
35 KEYWORDS="-* amd64 x86"
37 LICENSE="MPL-2.0 GPL-2 LGPL-2.1"
38 IUSE="+alsa +ffmpeg +pulseaudio selinux startup-notification wayland"
40 DEPEND="app-arch/unzip
49 >=dev-libs/dbus-glib-0.72
50 >=dev-libs/glib-2.26:2
52 >=media-libs/freetype-2.4.10
53 >=x11-libs/cairo-1.10[X]
55 >=x11-libs/gtk+-2.18:2
56 >=x11-libs/gtk+-3.4.0:3
58 x11-libs/libXcomposite
64 >=x11-libs/pango-1.22.0
65 virtual/freedesktop-icon-theme
71 pulseaudio? ( media-sound/pulseaudio )
72 ffmpeg? ( media-video/ffmpeg )
73 selinux? ( sec-policy/selinux-mozilla )
78 opt/${MOZ_PN}/${MOZ_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
85 opt/${MOZ_PN}/minidump-analyzer
86 opt/${MOZ_PN}/pingsender
89 S="${WORKDIR}/${MOZ_PN}"
94 # Unpack language packs
99 local MOZILLA_FIVE_HOME=/opt/${MOZ_PN}
101 # Install firefox in /opt
102 dodir ${MOZILLA_FIVE_HOME%/*}
103 mv "${S}" "${ED%/}"${MOZILLA_FIVE_HOME} || die
104 cd "${WORKDIR}" || die
106 # Install language packs
107 MOZEXTENSION_TARGET="distribution/extensions" \
108 MOZ_INSTALL_L10N_XPIFILE="1" \
109 mozlinguas_src_install
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
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
121 local size sizes icon_path icon name
123 icon_path="${MOZILLA_FIVE_HOME}/browser/chrome/icons/default"
125 name="Mozilla Firefox (bin)"
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
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"
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
141 # Add StartupNotify=true bug 237317
142 local startup_notify="false"
143 if use startup-notification ; then
144 startup_notify="true"
147 local display_protocols="auto X11" use_wayland="false"
148 if use wayland ; then
149 display_protocols+=" Wayland"
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"
158 case ${display_protocol} in
160 exec_command="${PN}-wayland --name ${PN}-wayland"
161 newbin "${FILESDIR}"/firefox-bin-wayland.sh ${PN}-wayland
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.
170 exec_command="${PN}-x11 --name ${PN}-x11"
171 newbin "${FILESDIR}"/firefox-bin-x11.sh ${PN}-x11
175 desktop_filename="${PN}.desktop"
176 exec_command='firefox-bin'
180 newmenu "${FILESDIR}/${PN}-r1.desktop" "${desktop_filename}"
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
189 rm -f "${ED%/}"/usr/bin/firefox-bin || die
190 newbin "${FILESDIR}"/firefox-bin.sh firefox-bin
194 "${ED%/}"/usr/bin/firefox-bin \
195 "${ED%/}"/usr/bin/firefox-bin-x11 \
196 "${ED%/}"/usr/bin/firefox-bin-wayland \
198 [[ ! -f "${wrapper}" ]] && continue
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}:" \
208 # revdep-rebuild entry
209 insinto /etc/revdep-rebuild
210 echo "SEARCH_DIRS_MASK=${MOZILLA_FIVE_HOME}" >> ${T}/10${PN}
213 # Plugins dir, still used for flash
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}
221 # Update mimedb for the new .desktop file
222 xdg_desktop_database_update
223 xdg_icon_cache_update
225 if ! has_version 'gnome-base/gconf' || ! has_version 'gnome-base/orbit' \
226 || ! has_version 'net-misc/curl'; then
228 einfo "For using the crashreporter, you need gnome-base/gconf,"
229 einfo "gnome-base/orbit and net-misc/curl emerged."
233 use ffmpeg || ewarn "USE=-ffmpeg : HTML5 video will not render without media-video/ffmpeg installed"
236 if use alsa || use pulseaudio; then
240 if [[ ${HAS_AUDIO} -eq 0 ]] ; then
241 ewarn "USE=-pulseaudio & USE=-alsa : For audio please either set USE=pulseaudio or USE=alsa!"
244 local show_doh_information show_normandy_information
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
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
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
265 if [[ -n "${show_doh_information}" ]] ; then
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."
276 if [[ -n "${show_normandy_information}" ]] ; then
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."
285 elog "To re-enable this service set"
287 elog " app.normandy.enabled=true"
289 elog "in about:config."
294 xdg_desktop_database_update
295 xdg_icon_cache_update