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 # Running Chromium via this script makes it possible to set Chromium as the
8 # default browser directly out of a compile, without needing to package it.
10 DESKTOP
="chromium-devel"
14 echo "$0 [--gdb] [--help] [--man-page] [--] [chrome-options]"
16 echo " --gdb Start within gdb"
17 echo " --help This help screen"
18 echo " --man-page Open the man page in the tree"
21 # Check to see if there is a desktop file of the given name.
22 exists_desktop_file
() {
23 # Build a search list from $XDG_DATA_HOME and $XDG_DATA_DIRS, the latter
24 # of which can itself be a colon-separated list of directories to search.
25 search
="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
27 for dir
in $search; do
29 [ "$dir" -a -d "$dir/applications" ] ||
continue
30 [ -r "$dir/applications/$DESKTOP.desktop" ] && return
32 # Didn't find it in the search path.
36 # Checks a file to see if it's a 32 or 64-bit.
38 out
=$
(file $
(readlink
-f $1) 2> /dev
/null
)
39 echo $out |
grep -qs "ELF 32-bit LSB"
44 echo $out |
grep -qs "ELF 64-bit LSB"
52 # Generate a desktop file that will run this script.
53 generate_desktop_file
() {
54 apps
="${XDG_DATA_HOME:-$HOME/.local/share}/applications"
56 cat > "$apps/$DESKTOP.desktop" << EOF
61 Exec=$CHROME_WRAPPER %U
63 Icon=$HERE/product_logo_48.png
65 Categories=Application;Network;WebBrowser;
66 MimeType=text/html;text/xml;application/xhtml_xml;
70 # Let the wrapped binary know that it has been run through the wrapper.
71 export CHROME_WRAPPER
="`readlink -f "$0"`"
72 export CHROME_DESKTOP
="$DESKTOP.desktop"
74 HERE
="`dirname "$CHROME_WRAPPER"`"
76 # We include some xdg utilities next to the binary, and we want to prefer them
77 # over the system versions when we know the system versions are very old. We
78 # detect whether the system xdg utilities are sufficiently new to be likely to
79 # work for us by looking for xdg-settings. If we find it, we leave $PATH alone,
80 # so that the system xdg utilities (including any distro patches) will be used.
81 if ! which xdg-settings
&> /dev
/null
; then
82 # Old xdg utilities. Prepend $HERE to $PATH to use ours instead.
83 export PATH
="$HERE:$PATH"
85 # Use system xdg utilities. But first create mimeapps.list if it doesn't
86 # exist; some systems have bugs in xdg-mime that make it fail without it.
87 xdg_app_dir
="${XDG_DATA_HOME:-$HOME/.local/share/applications}"
88 mkdir
-p "$xdg_app_dir"
89 [ -f "$xdg_app_dir/mimeapps.list" ] ||
touch "$xdg_app_dir/mimeapps.list"
92 # Always use our ffmpeg and other shared libs.
93 export LD_LIBRARY_PATH
="$HERE:$HERE/lib:$HERE/lib.target${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
95 MISSING_LIBS
=$
(ldd
"$HERE/chrome" 2> /dev
/null |
grep "not found$" | cut
-d" " -f 1|
sed 's/\t//')
96 CHROME_ARCH
=$
(check_executable
"$HERE/chrome")
97 uname
-m |
grep -qs x86_64
99 LIBDIRS
="/lib /lib32 /usr/lib /usr/lib32"
101 LIBDIRS
="/lib64 /lib /usr/lib64 /usr/lib"
104 echo $MISSING_LIBS |
grep -qs libbz2.so
.1.0
108 if [ -e "$dir/libbz2.so.1" ]; then
109 LIB_ARCH
=$
(check_executable
"$dir/libbz2.so.1")
110 if [ "$CHROME_ARCH" = "$LIB_ARCH" ]; then
111 ln -snf "$dir/libbz2.so.1" "$HERE/libbz2.so.1.0"
118 for lib
in libnspr4.so
.0d libnss3.so
.1d libnssutil3.so
.1d libplc4.so
.0d libplds4.so
.0d libsmime3.so
.1d libssl3.so
.1d
120 echo $MISSING_LIBS |
grep -qs $lib
122 reallib
=$
(echo $lib |
sed 's/\.[01]d$//')
125 if [ -e "$dir/$reallib" ]; then
126 LIB_ARCH
=$
(check_executable
"$dir/$reallib")
127 if [ "$CHROME_ARCH" = "$LIB_ARCH" ]; then
128 ln -snf "$dir/$reallib" "$HERE/$lib"
136 # Custom version string for this release. This can be used to add a downstream
137 # vendor string or release channel information.
138 export CHROME_VERSION_EXTRA
="custom"
140 exists_desktop_file || generate_desktop_file
144 while [ "$#" -gt 0 ]; do
150 CMD_PREFIX
="gdb --args" ;;
155 exec man
"$HERE/../../chrome/app/resources/manpage.1.in" ;;
157 ARGS
=( "${ARGS[@]}" "$1" ) ;;
161 set -- "${ARGS[@]}" "$@"
163 exec $CMD_PREFIX "$HERE/chrome" "$@"