Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: www-client/firefox/files/, www-client/firefox/
Date: Mon, 30 Mar 2020 11:46:16
Message-Id: 1585568710.de3255e329bf23cd3e8247e475e75b374e53aec9.whissi@gentoo
1 commit: de3255e329bf23cd3e8247e475e75b374e53aec9
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Sun Mar 29 00:46:42 2020 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Mon Mar 30 11:45:10 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=de3255e3
7
8 www-client/firefox: use wrapper
9
10 This change will replace /usr/bin/firefox symlink with a
11 wrapper script:
12
13 - Using a wrapper will allow us to set additional variables
14 more easily.
15
16 - The wrapper will address an issue that prevented external applications
17 from opening links when a Firefox instance was already running.
18
19 - In general, the wrapper will allow user to execute 'firefox' from
20 wherever and whenever they like without getting an error that an
21 instance is already running.
22
23 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
24
25 www-client/firefox/files/firefox-wayland.sh | 7 ++
26 www-client/firefox/files/firefox-x11.sh | 7 ++
27 www-client/firefox/files/firefox.sh | 105 ++++++++++++++++++++++++++++
28 www-client/firefox/firefox-74.0-r2.ebuild | 62 ++++++++++++++--
29 4 files changed, 174 insertions(+), 7 deletions(-)
30
31 diff --git a/www-client/firefox/files/firefox-wayland.sh b/www-client/firefox/files/firefox-wayland.sh
32 new file mode 100644
33 index 00000000000..44280250fb9
34 --- /dev/null
35 +++ b/www-client/firefox/files/firefox-wayland.sh
36 @@ -0,0 +1,7 @@
37 +#!/bin/sh
38 +
39 +#
40 +# Run Mozilla Firefox under Wayland
41 +#
42 +export MOZ_ENABLE_WAYLAND=1
43 +exec @PREFIX@/bin/firefox "$@"
44
45 diff --git a/www-client/firefox/files/firefox-x11.sh b/www-client/firefox/files/firefox-x11.sh
46 new file mode 100644
47 index 00000000000..756556690cf
48 --- /dev/null
49 +++ b/www-client/firefox/files/firefox-x11.sh
50 @@ -0,0 +1,7 @@
51 +#!/bin/sh
52 +
53 +#
54 +# Run Mozilla Firefox on X11
55 +#
56 +export MOZ_DISABLE_WAYLAND=1
57 +exec @PREFIX@/bin/firefox "$@"
58
59 diff --git a/www-client/firefox/files/firefox.sh b/www-client/firefox/files/firefox.sh
60 new file mode 100644
61 index 00000000000..d942087ffa8
62 --- /dev/null
63 +++ b/www-client/firefox/files/firefox.sh
64 @@ -0,0 +1,105 @@
65 +#!/bin/bash
66 +
67 +##
68 +## Usage:
69 +##
70 +## $ firefox
71 +##
72 +## This script is meant to run Mozilla Firefox in Gentoo.
73 +
74 +cmdname=$(basename "$0")
75 +
76 +##
77 +## Variables
78 +##
79 +MOZ_ARCH=$(uname -m)
80 +case ${MOZ_ARCH} in
81 + x86_64|s390x|sparc64)
82 + MOZ_LIB_DIR="@PREFIX@/lib64"
83 + SECONDARY_LIB_DIR="@PREFIX@/lib"
84 + ;;
85 + *)
86 + MOZ_LIB_DIR="@PREFIX@/lib"
87 + SECONDARY_LIB_DIR="@PREFIX@/lib64"
88 + ;;
89 +esac
90 +
91 +MOZ_FIREFOX_FILE="firefox"
92 +
93 +if [[ ! -r ${MOZ_LIB_DIR}/firefox/${MOZ_FIREFOX_FILE} ]]; then
94 + if [[ ! -r ${SECONDARY_LIB_DIR}/firefox/${MOZ_FIREFOX_FILE} ]]; then
95 + echo "Error: ${MOZ_LIB_DIR}/firefox/${MOZ_FIREFOX_FILE} not found" >&2
96 + if [[ -d $SECONDARY_LIB_DIR ]]; then
97 + echo " ${SECONDARY_LIB_DIR}/firefox/${MOZ_FIREFOX_FILE} not found" >&2
98 + fi
99 + exit 1
100 + fi
101 + MOZ_LIB_DIR="$SECONDARY_LIB_DIR"
102 +fi
103 +MOZILLA_FIVE_HOME="${MOZ_LIB_DIR}/firefox"
104 +MOZ_EXTENSIONS_PROFILE_DIR="${HOME}/.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
105 +MOZ_PROGRAM="${MOZILLA_FIVE_HOME}/${MOZ_FIREFOX_FILE}"
106 +DESKTOP_FILE="firefox"
107 +
108 +##
109 +## Enable Wayland backend?
110 +##
111 +if @DEFAULT_WAYLAND@ && [[ -z ${MOZ_DISABLE_WAYLAND} ]]; then
112 + if [[ -n "$WAYLAND_DISPLAY" ]]; then
113 + DESKTOP_FILE="firefox-wayland"
114 + export MOZ_ENABLE_WAYLAND=1
115 + fi
116 +elif [[ -n ${MOZ_DISABLE_WAYLAND} ]]; then
117 + DESKTOP_FILE="firefox-x11"
118 +fi
119 +
120 +##
121 +## Use D-Bus remote exclusively when there's Wayland display.
122 +##
123 +if [[ -n "${WAYLAND_DISPLAY}" ]]; then
124 + export MOZ_DBUS_REMOTE=1
125 +fi
126 +
127 +##
128 +## Make sure that we set the plugin path
129 +##
130 +MOZ_PLUGIN_DIR="plugins"
131 +
132 +if [[ -n "${MOZ_PLUGIN_PATH}" ]]; then
133 + MOZ_PLUGIN_PATH=${MOZ_PLUGIN_PATH}:${MOZ_LIB_DIR}/mozilla/${MOZ_PLUGIN_DIR}
134 +else
135 + MOZ_PLUGIN_PATH=${MOZ_LIB_DIR}/mozilla/${MOZ_PLUGIN_DIR}
136 +fi
137 +
138 +if [[ -d "${SECONDARY_LIB_DIR}/mozilla/${MOZ_PLUGIN_DIR}" ]]; then
139 + MOZ_PLUGIN_PATH=${MOZ_PLUGIN_PATH}:${SECONDARY_LIB_DIR}/mozilla/${MOZ_PLUGIN_DIR}
140 +fi
141 +
142 +export MOZ_PLUGIN_PATH
143 +
144 +##
145 +## Set MOZ_APP_LAUNCHER for gnome-session
146 +##
147 +export MOZ_APP_LAUNCHER="@PREFIX@/bin/${cmdname}"
148 +
149 +##
150 +## Disable the GNOME crash dialog, Moz has it's own
151 +##
152 +if [[ "$XDG_CURRENT_DESKTOP" == "GNOME" ]]; then
153 + GNOME_DISABLE_CRASH_DIALOG=1
154 + export GNOME_DISABLE_CRASH_DIALOG
155 +fi
156 +
157 +# Don't throw "old profile" dialog box.
158 +export MOZ_ALLOW_DOWNGRADE=1
159 +
160 +##
161 +## Route to the correct .desktop file to get proper
162 +## names and contect menus
163 +##
164 +if [[ $@ != *"--name "* ]]; then
165 + set -- "--name ${DESKTOP_FILE}" "$@"
166 +fi
167 +
168 +# Run the browser
169 +exec ${MOZ_PROGRAM} $@
170
171 diff --git a/www-client/firefox/firefox-74.0-r2.ebuild b/www-client/firefox/firefox-74.0-r2.ebuild
172 index f59e1224f9f..bd04eca22ba 100644
173 --- a/www-client/firefox/firefox-74.0-r2.ebuild
174 +++ b/www-client/firefox/firefox-74.0-r2.ebuild
175 @@ -757,7 +757,6 @@ PROFILE_EOF
176 done
177 # Install a 48x48 icon into /usr/share/pixmaps for legacy DEs
178 newicon "${icon_path}/default48.png" "${icon}.png"
179 - newmenu "${FILESDIR}/icon/${PN}-r1.desktop" "${PN}.desktop"
180
181 # Add StartupNotify=true bug 237317
182 local startup_notify="false"
183 @@ -765,12 +764,61 @@ PROFILE_EOF
184 startup_notify="true"
185 fi
186
187 - sed -i \
188 - -e "s:@NAME@:${name}:" \
189 - -e "s:@EXEC@:firefox:" \
190 - -e "s:@ICON@:${icon}:" \
191 - -e "s:@STARTUP_NOTIFY@:${startup_notify}:" \
192 - "${ED%/}/usr/share/applications/${PN}.desktop" || die
193 + local display_protocols="auto X11" use_wayland="false"
194 + if use wayland ; then
195 + display_protocols+=" Wayland"
196 + use_wayland="true"
197 + fi
198 +
199 + local app_name desktop_filename display_protocol exec_command
200 + for display_protocol in ${display_protocols} ; do
201 + app_name="${name} on ${display_protocol}"
202 + desktop_filename="${PN}-${display_protocol,,}.desktop"
203 +
204 + case ${display_protocol} in
205 + Wayland)
206 + exec_command='firefox-wayland --name firefox-wayland'
207 + newbin "${FILESDIR}"/firefox-wayland.sh firefox-wayland
208 + ;;
209 + X11)
210 + exec_command='firefox-x11 --name firefox-x11'
211 + if use wayland ; then
212 + # Only needed when there's actually a choice
213 + newbin "${FILESDIR}"/firefox-x11.sh firefox-x11
214 + fi
215 + ;;
216 + *)
217 + app_name="${name}"
218 + desktop_filename="${PN}.desktop"
219 + exec_command='firefox'
220 + ;;
221 + esac
222 +
223 + newmenu "${FILESDIR}/icon/${PN}-r1.desktop" "${desktop_filename}"
224 + sed -i \
225 + -e "s:@NAME@:${app_name}:" \
226 + -e "s:@EXEC@:${exec_command}:" \
227 + -e "s:@ICON@:${icon}:" \
228 + -e "s:@STARTUP_NOTIFY@:${startup_notify}:" \
229 + "${ED%/}/usr/share/applications/${desktop_filename}" || die
230 + done
231 +
232 + rm "${ED%/}"/usr/bin/firefox || die
233 + newbin "${FILESDIR}"/firefox.sh firefox
234 +
235 + local wrapper
236 + for wrapper in \
237 + "${ED%/}"/usr/bin/firefox \
238 + "${ED%/}"/usr/bin/firefox-x11 \
239 + "${ED%/}"/usr/bin/firefox-wayland \
240 + ; do
241 + [[ ! -f "${wrapper}" ]] && continue
242 +
243 + sed -i \
244 + -e "s:@PREFIX@:${EPREFIX%/}/usr:" \
245 + -e "s:@DEFAULT_WAYLAND@:${use_wayland}:" \
246 + "${wrapper}" || die
247 + done
248
249 # Don't install llvm-symbolizer from sys-devel/llvm package
250 [[ -f "${ED%/}${MOZILLA_FIVE_HOME}/llvm-symbolizer" ]] && \