Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 | 2 |
| 3 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # Running Chromium via this script makes it possible to set Chromium as the | 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. | 8 # default browser directly out of a compile, without needing to package it. |
| 9 | 9 |
| 10 DESKTOP="chromium-devel" | 10 DESKTOP="chromium-devel" |
| 11 TITLE="Chromium" | 11 TITLE="Chromium" |
| 12 | 12 |
| 13 # Check to see if there is a desktop file of the given name | 13 # Check to see if there is a desktop file of the given name. |
| 14 exists_desktop_file() { | 14 exists_desktop_file() { |
| 15 # Build a search list from $XDG_DATA_HOME and $XDG_DATA_DIRS, the latter | 15 # Build a search list from $XDG_DATA_HOME and $XDG_DATA_DIRS, the latter |
| 16 # of which can itself be a colon-separated list of directories to search. | 16 # of which can itself be a colon-separated list of directories to search. |
| 17 search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/sha re:/usr/share}" | 17 search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/sha re:/usr/share}" |
| 18 IFS=: | 18 IFS=: |
| 19 for dir in $search; do | 19 for dir in $search; do |
| 20 unset IFS | 20 unset IFS |
| 21 [ "$dir" -a -d "$dir/applications" ] || continue | 21 [ "$dir" -a -d "$dir/applications" ] || continue |
| 22 [ -r "$dir/applications/$DESKTOP.desktop" ] && return | 22 [ -r "$dir/applications/$DESKTOP.desktop" ] && return |
| 23 done | 23 done |
| 24 # Didn't find it in the search path | 24 # Didn't find it in the search path. |
| 25 return 1 | 25 return 1 |
| 26 } | 26 } |
| 27 | 27 |
| 28 # Checks a file to see if it's a 32 or 64-bit | 28 # Checks a file to see if it's a 32 or 64-bit. |
| 29 check_executable() { | 29 check_executable() { |
| 30 out=$(file $(readlink -f $1) 2> /dev/null) | 30 out=$(file $(readlink -f $1) 2> /dev/null) |
| 31 echo $out | grep -qs "ELF 32-bit LSB" | 31 echo $out | grep -qs "ELF 32-bit LSB" |
| 32 if [ $? = 0 ]; then | 32 if [ $? = 0 ]; then |
| 33 echo 32 | 33 echo 32 |
| 34 return | 34 return |
| 35 fi | 35 fi |
| 36 echo $out | grep -qs "ELF 64-bit LSB" | 36 echo $out | grep -qs "ELF 64-bit LSB" |
| 37 if [ $? = 0 ]; then | 37 if [ $? = 0 ]; then |
| 38 echo 64 | 38 echo 64 |
| 39 return | 39 return |
| 40 fi | 40 fi |
| 41 echo neither | 41 echo neither |
| 42 } | 42 } |
| 43 | 43 |
| 44 # Generate a desktop file that will run this script | 44 # Generate a desktop file that will run this script. |
| 45 generate_desktop_file() { | 45 generate_desktop_file() { |
| 46 apps="${XDG_DATA_HOME:-$HOME/.local/share}/applications" | 46 apps="${XDG_DATA_HOME:-$HOME/.local/share}/applications" |
| 47 mkdir -p "$apps" | 47 mkdir -p "$apps" |
| 48 cat > "$apps/$DESKTOP.desktop" << EOF | 48 cat > "$apps/$DESKTOP.desktop" << EOF |
| 49 [Desktop Entry] | 49 [Desktop Entry] |
| 50 Version=1.0 | 50 Version=1.0 |
| 51 Encoding=UTF-8 | 51 Encoding=UTF-8 |
| 52 Name=$TITLE | 52 Name=$TITLE |
| 53 Exec=$CHROME_WRAPPER %U | 53 Exec=$CHROME_WRAPPER %U |
| 54 Terminal=false | 54 Terminal=false |
| 55 Icon=$HERE/product_logo_48.png | 55 Icon=$HERE/product_logo_48.png |
| 56 Type=Application | 56 Type=Application |
| 57 Categories=Application;Network;WebBrowser; | 57 Categories=Application;Network;WebBrowser; |
| 58 MimeType=text/html;text/xml;application/xhtml_xml; | 58 MimeType=text/html;text/xml;application/xhtml_xml; |
| 59 EOF | 59 EOF |
| 60 } | 60 } |
| 61 | 61 |
| 62 # Let the wrapped binary know that it has been run through the wrapper | 62 # Let the wrapped binary know that it has been run through the wrapper. |
| 63 export CHROME_WRAPPER="`readlink -f "$0"`" | 63 export CHROME_WRAPPER="`readlink -f "$0"`" |
| 64 export CHROME_DESKTOP="$DESKTOP.desktop" | 64 export CHROME_DESKTOP="$DESKTOP.desktop" |
| 65 | 65 |
| 66 HERE="`dirname "$CHROME_WRAPPER"`" | 66 HERE="`dirname "$CHROME_WRAPPER"`" |
| 67 | 67 |
| 68 # We include some xdg utilities next to the binary, and we want to prefer them | |
| 69 # over the system versions because we know they work correctly for us. But if | |
| 70 # our path already exists, we leave it where it is, to allow overriding this. | |
|
Lei Zhang
2010/08/31 20:50:59
Can you add a note to say we'll flip the ordering
| |
| 68 case ":$PATH:" in | 71 case ":$PATH:" in |
| 69 *:$HERE:*) | 72 *:$HERE:*) |
| 70 # $PATH already contains $HERE | 73 # $PATH already contains $HERE, leave it where it is. |
| 71 ;; | 74 ;; |
| 72 *) | 75 *) |
| 73 # Append $HERE to $PATH | 76 # Prepend $HERE to $PATH. |
| 74 export PATH="$PATH:$HERE" | 77 export PATH="$HERE:$PATH" |
| 75 ;; | 78 ;; |
| 76 esac | 79 esac |
| 77 | 80 |
| 78 # Always use our ffmpeg and other shared libs. | 81 # Always use our ffmpeg and other shared libs. |
| 79 export LD_LIBRARY_PATH="$HERE:$HERE/lib:$HERE/lib.target:$LD_LIBRARY_PATH" | 82 export LD_LIBRARY_PATH="$HERE:$HERE/lib:$HERE/lib.target:$LD_LIBRARY_PATH" |
| 80 | 83 |
| 81 MISSING_LIBS=$(ldd "$HERE/chrome" 2> /dev/null |grep "not found$" | cut -d" " -f 1|sed 's/\t//') | 84 MISSING_LIBS=$(ldd "$HERE/chrome" 2> /dev/null |grep "not found$" | cut -d" " -f 1|sed 's/\t//') |
| 82 CHROME_ARCH=$(check_executable "$HERE/chrome") | 85 CHROME_ARCH=$(check_executable "$HERE/chrome") |
| 83 uname -m | grep -qs x86_64 | 86 uname -m | grep -qs x86_64 |
| 84 if [ $? = 1 ]; then | 87 if [ $? = 1 ]; then |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 fi | 122 fi |
| 120 done | 123 done |
| 121 | 124 |
| 122 # Custom version string for this release. This can be used to add a downstream | 125 # Custom version string for this release. This can be used to add a downstream |
| 123 # vendor string or release channel information. | 126 # vendor string or release channel information. |
| 124 export CHROME_VERSION_EXTRA="custom" | 127 export CHROME_VERSION_EXTRA="custom" |
| 125 | 128 |
| 126 exists_desktop_file || generate_desktop_file | 129 exists_desktop_file || generate_desktop_file |
| 127 | 130 |
| 128 exec "$HERE/chrome" "$@" | 131 exec "$HERE/chrome" "$@" |
| OLD | NEW |