wok-current view get-google-chrome/stuff/get-google-chrome @ rev 12182

Up: tazweb (1.6.1) - Fix missing incon
author Christophe Lincoln <pankso@slitaz.org>
date Sat Mar 24 17:05:26 2012 +0100 (2012-03-24)
parents 66e68cc95aa8
children e2fcb326c3a5
line source
1 #!/bin/sh
2 # Google Chrome is built with open source code from Chromium.
4 PACKAGE="google-chrome-unstable"
5 DEBPKG="${PACKAGE}_current_i386.deb"
6 URL="http://dl.google.com/linux/direct/$DEBPKG"
7 CUR_DIR=$(pwd)
8 TEMP_DIR=/tmp/$PACKAGE-$$
9 ROOT=
10 FORCED=
12 while getopts "hfr:" option; do
13 case $option in
14 h) echo -e "Usage: $(basename $0) [-f|-r path]\n -f: force install.\n -r path: root directory."; exit 1 ;;
15 f) FORCED="--forced" ;;
16 r) ROOT=$OPTARG ;;
17 \?) echo "Wrong argument, Exit ...."; exit 1 ;;
18 esac
19 done
21 # Check if we are root
22 if test $(id -u) != 0 ; then
23 echo -e "\nYou must be root to run `basename $0`."
24 echo -e "Please type 'su' and root password to become super-user.\n"
25 exit 1
26 fi
28 # Avoid reinstall
29 if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ] && [ -z $FORCED ]; then
30 echo -e "\n$PACKAGE package is already installed, add '-f' option to force install.\n"
31 exit 1
32 fi
34 # Create a TEMP_DIR
35 mkdir $TEMP_DIR
36 cd $TEMP_DIR
38 # Download the file
39 wget $URL
40 if [ ! -f $DEBPKG ]; then
41 cd $CUR_DIR
42 rm -rf $TEMP_DIR
43 echo "Could not download $DEBPKG. Exiting."
44 exit 1
45 fi
47 dpkg-deb -e $DEBPKG .
48 VERSION=`sed -n 's/Version:\ *//p' control`
50 mkdir $PACKAGE-$VERSION
52 dpkg-deb -x $DEBPKG $PACKAGE-$VERSION/fs
53 rm -rf $PACKAGE-$VERSION/fs/usr/share
54 rm -rf $PACKAGE-$VERSION/fs/etc
56 # extracted pkg can be removed: Save RAM
57 rm -rf $DEBPKG
59 cat > $PACKAGE-$VERSION/receipt << EOT
60 PACKAGE="$PACKAGE"
61 VERSION="$VERSION"
62 CATEGORY="non-free"
63 SHORT_DESC="The web browser from Google."
64 DEPENDS="gtk+ GConf lzma flash-plugin bash xdg-utils xorg-libXss cups libjpeg62"
65 WEB_SITE="http://www.google.com/chrome/"
67 post_install()
68 {
69 local root
70 root=$1
71 ln -s /usr/lib/libnspr4.so $root/usr/lib/libnspr4.so.0d 2> /dev/null
72 ln -s /usr/lib/libnss3.so $root/usr/lib/libnss3.so.1d 2> /dev/null
73 ln -s /usr/lib/libnssutil3.so $root/usr/lib/libnssutil3.so.1d 2> /dev/null
74 ln -s /usr/lib/libplc4.so $root/usr/lib/libplc4.so.0d 2> /dev/null
75 ln -s /usr/lib/libplds4.so $root/usr/lib/libplds4.so.0d 2> /dev/null
76 ln -s /usr/lib/libsmime3.so $root/usr/lib/libsmime3.so.1d 2> /dev/null
77 ln -s /usr/lib/libssl3.so $root/usr/lib/libssl3.so.1d 2> /dev/nul
78 sed -i 's/exec -a "$0"/exec /' $root/usr/bin/google-chrome 2> /dev/null
80 # Add icons to the system icons
81 XDG_ICON_RESOURCE="\`which xdg-icon-resource 2> /dev/null\`"
82 if [ ! -x "\$XDG_ICON_RESOURCE" ]; then
83 echo "Error: Could not find xdg-icon-resource" >&2
84 return 1
85 fi
86 for icon in "/opt/google/chrome/product_logo_"*.png; do
87 size="\${icon##*/product_logo_}"
88 "\$XDG_ICON_RESOURCE" install --size "\${size%.png}" "\$icon" "google-chrome"
89 done
91 # Add an entry to the system menu
92 XDG_DESKTOP_MENU="\`which xdg-desktop-menu 2> /dev/null\`"
93 UPDATE_MENUS="\`which update-menus 2> /dev/null\`"
94 if [ ! -x "\$XDG_DESKTOP_MENU" ]; then
95 echo "Error: Could not find xdg-desktop-menu" >&2
96 return 1
97 fi
98 "\$XDG_DESKTOP_MENU" install /opt/google/chrome/google-chrome.desktop
100 if [ -x "\$UPDATE_MENUS" ]; then
101 update-menus
102 fi
103 }
104 pre_remove()
105 {
106 rm -f /usr/lib/libnspr4.so.0d \
107 /usr/lib/libnss3.so.1d \
108 /usr/lib/libnssutil3.so.1d \
109 /usr/lib/libplc4.so.0d \
110 /usr/lib/libplds4.so.0d \
111 /usr/lib/libsmime3.so.1d \
112 /usr/lib/libssl3.so.1d 2> /dev/nul
114 # Remove icons from the system icons
115 XDG_ICON_RESOURCE="\`which xdg-icon-resource 2> /dev/null\`"
116 if [ ! -x "\$XDG_ICON_RESOURCE" ]; then
117 echo "Error: Could not find xdg-icon-resource" >&2
118 return 1
119 fi
120 for icon in "/opt/google/chrome/product_logo_"*.png; do
121 size="\${icon##*/product_logo_}"
122 "\$XDG_ICON_RESOURCE" uninstall --size "\${size%.png}" "google-chrome"
123 done
125 # Remove the entry from the system menu
126 XDG_DESKTOP_MENU="\`which xdg-desktop-menu 2> /dev/null\`"
127 UPDATE_MENUS="\`which update-menus 2> /dev/null\`"
128 if [ ! -x "\$XDG_DESKTOP_MENU" ]; then
129 echo "Error: Could not find xdg-desktop-menu" >&2
130 return 1
131 fi
132 "\$XDG_DESKTOP_MENU" uninstall /opt/google/chrome/google-chrome.desktop
134 if [ -x "\$UPDATE_MENUS" ]; then
135 update-menus
136 fi
137 }
138 EOT
140 # Pack
141 tazpkg pack $PACKAGE-$VERSION
143 # Clean to save RAM memory
144 rm -rf $PACKAGE-$VERSION
146 # Install pseudo package
147 yes y | tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT $FORCED
149 # Clean
150 cd $CUR_DIR
151 rm -rf $TEMP_DIR