Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / installer / linux / common / wrapper
blobb4537e840cab087a68692196c7569063e7e57cc9
1 #!/bin/bash
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 # Let the wrapped binary know that it has been run through the wrapper.
8 export CHROME_WRAPPER="`readlink -f "$0"`"
10 HERE="`dirname "$CHROME_WRAPPER"`"
12 # Check if the CPU supports SSE2. If not, try to pop up a dialog to explain the
13 # problem and exit. Otherwise the browser will just crash with a SIGILL.
14 # http://crbug.com/348761
15 grep ^flags /proc/cpuinfo|grep -qs sse2
16 if [ $? != 0 ]; then
17 SSE2_DEPRECATION_MSG="This computer can no longer run Google Chrome because \
18 its hardware is no longer supported."
19 if which zenity &> /dev/null; then
20 zenity --warning --text="$SSE2_DEPRECATION_MSG"
21 elif which gmessage &> /dev/null; then
22 gmessage "$SSE2_DEPRECATION_MSG"
23 elif which xmessage &> /dev/null; then
24 xmessage "$SSE2_DEPRECATION_MSG"
25 else
26 echo "$SSE2_DEPRECATION_MSG" 1>&2
28 exit 1
31 # We include some xdg utilities next to the binary, and we want to prefer them
32 # over the system versions when we know the system versions are very old. We
33 # detect whether the system xdg utilities are sufficiently new to be likely to
34 # work for us by looking for xdg-settings. If we find it, we leave $PATH alone,
35 # so that the system xdg utilities (including any distro patches) will be used.
36 if ! which xdg-settings &> /dev/null; then
37 # Old xdg utilities. Prepend $HERE to $PATH to use ours instead.
38 export PATH="$HERE:$PATH"
39 else
40 # Use system xdg utilities. But first create mimeapps.list if it doesn't
41 # exist; some systems have bugs in xdg-mime that make it fail without it.
42 xdg_app_dir="${XDG_DATA_HOME:-$HOME/.local/share/applications}"
43 mkdir -p "$xdg_app_dir"
44 [ -f "$xdg_app_dir/mimeapps.list" ] || touch "$xdg_app_dir/mimeapps.list"
47 # Always use our versions of ffmpeg libs.
48 # This also makes RPMs find the compatibly-named library symlinks.
49 if [[ -n "$LD_LIBRARY_PATH" ]]; then
50 LD_LIBRARY_PATH="$HERE:$HERE/lib:$LD_LIBRARY_PATH"
51 else
52 LD_LIBRARY_PATH="$HERE:$HERE/lib"
54 export LD_LIBRARY_PATH
56 export CHROME_VERSION_EXTRA="@@CHANNEL@@"
58 # We don't want bug-buddy intercepting our crashes. http://crbug.com/24120
59 export GNOME_DISABLE_CRASH_DIALOG=SET_BY_GOOGLE_CHROME
61 # Automagically migrate user data directory.
62 # TODO(phajdan.jr): Remove along with migration code in the browser for M33.
63 if [[ -n "@@SXS_USER_DATA_DIR@@" ]]; then
64 if [[ ! -d "@@SXS_USER_DATA_DIR@@" ]]; then
65 "$HERE/@@PROGNAME@@" "--migrate-data-dir-for-sxs=@@SXS_USER_DATA_DIR@@" \
66 --enable-logging=stderr --log-level=0
70 # Sanitize std{in,out,err} because they'll be shared with untrusted child
71 # processes (http://crbug.com/376567).
72 exec < /dev/null
73 exec > >(exec cat)
74 exec 2> >(exec cat >&2)
76 # Make sure that the profile directory specified in the environment, if any,
77 # overrides the default.
78 if [[ -n "$CHROME_USER_DATA_DIR" ]]; then
79 # Note: exec -a below is a bashism.
80 exec -a "$0" "$HERE/@@PROGNAME@@" @@DEFAULT_FLAGS@@ \
81 --user-data-dir="$CHROME_USER_DATA_DIR" "$@"
82 else
83 exec -a "$0" "$HERE/@@PROGNAME@@" @@DEFAULT_FLAGS@@ "$@"