OLD | NEW |
1 #!/bin/sh | 1 #!/bin/sh |
2 | 2 |
3 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2006-2009 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 |
| 29 check_executable() { |
| 30 out=$(file $(readlink -f $1) 2> /dev/null) |
| 31 echo $out | grep -qs "ELF 32-bit LSB" |
| 32 if [ $? = 0 ]; then |
| 33 echo 32 |
| 34 return |
| 35 fi |
| 36 echo $out | grep -qs "ELF 64-bit LSB" |
| 37 if [ $? = 0 ]; then |
| 38 echo 64 |
| 39 return |
| 40 fi |
| 41 echo neither |
| 42 } |
| 43 |
28 # Generate a desktop file that will run this script | 44 # Generate a desktop file that will run this script |
29 generate_desktop_file() { | 45 generate_desktop_file() { |
30 apps="${XDG_DATA_HOME:-$HOME/.local/share}/applications" | 46 apps="${XDG_DATA_HOME:-$HOME/.local/share}/applications" |
31 mkdir -p "$apps" | 47 mkdir -p "$apps" |
32 cat > "$apps/$DESKTOP.desktop" << EOF | 48 cat > "$apps/$DESKTOP.desktop" << EOF |
33 [Desktop Entry] | 49 [Desktop Entry] |
34 Version=1.0 | 50 Version=1.0 |
35 Encoding=UTF-8 | 51 Encoding=UTF-8 |
36 Name=$TITLE | 52 Name=$TITLE |
37 Exec=$CHROME_WRAPPER %U | 53 Exec=$CHROME_WRAPPER %U |
(...skipping 17 matching lines...) Expand all Loading... |
55 ;; | 71 ;; |
56 *) | 72 *) |
57 # Append $HERE to $PATH | 73 # Append $HERE to $PATH |
58 export PATH="$PATH:$HERE" | 74 export PATH="$PATH:$HERE" |
59 ;; | 75 ;; |
60 esac | 76 esac |
61 | 77 |
62 # Always use our ffmpeg and other shared libs. | 78 # Always use our ffmpeg and other shared libs. |
63 export LD_LIBRARY_PATH="$HERE:$HERE/lib:$HERE/lib.target:$LD_LIBRARY_PATH" | 79 export LD_LIBRARY_PATH="$HERE:$HERE/lib:$HERE/lib.target:$LD_LIBRARY_PATH" |
64 | 80 |
| 81 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") |
| 83 uname -m | grep -qs x86_64 |
| 84 if [ $? = 1 ]; then |
| 85 LIBDIRS="/lib /lib32 /usr/lib /usr/lib32" |
| 86 else |
| 87 LIBDIRS="/lib64 /lib /usr/lib64 /usr/lib" |
| 88 fi |
| 89 |
| 90 echo $MISSING_LIBS | grep -qs libbz2.so.1.0 |
| 91 if [ $? = 0 ]; then |
| 92 for dir in $LIBDIRS |
| 93 do |
| 94 if [ -e "$dir/libbz2.so.1" ]; then |
| 95 LIB_ARCH=$(check_executable "$dir/libbz2.so.1") |
| 96 if [ "$CHROME_ARCH" = "$LIB_ARCH" ]; then |
| 97 ln -snf "$dir/libbz2.so.1" "$HERE/libbz2.so.1.0" |
| 98 break; |
| 99 fi |
| 100 fi |
| 101 done |
| 102 fi |
| 103 |
| 104 for lib in libnspr4.so.0d libnss3.so.1d libnssutil3.so.1d libplc4.so.0d libplds4
.so.0d libsmime3.so.1d libssl3.so.1d |
| 105 do |
| 106 echo $MISSING_LIBS | grep -qs $lib |
| 107 if [ $? = 0 ]; then |
| 108 reallib=$(echo $lib | sed 's/\.[01]d$//') |
| 109 for dir in $LIBDIRS |
| 110 do |
| 111 if [ -e "$dir/$reallib" ]; then |
| 112 LIB_ARCH=$(check_executable "$dir/$reallib") |
| 113 if [ "$CHROME_ARCH" = "$LIB_ARCH" ]; then |
| 114 ln -snf "$dir/$reallib" "$HERE/$lib" |
| 115 break; |
| 116 fi |
| 117 fi |
| 118 done |
| 119 fi |
| 120 done |
| 121 |
| 122 # Custom version string for this release. This can be used to add a downstream |
| 123 # vendor string or release channel information. |
| 124 export CHROME_VERSION_EXTRA="custom" |
| 125 |
65 exists_desktop_file || generate_desktop_file | 126 exists_desktop_file || generate_desktop_file |
66 | 127 |
67 exec "$HERE/chrome" "$@" | 128 exec "$HERE/chrome" "$@" |
OLD | NEW |