wok-next view get-OpenOffice3/stuff/get-OpenOffice3 @ rev 5837
Up: xfce4 (4.6.2)
author | Eric Joseph-Alexandre <erjo@slitaz.org> |
---|---|
date | Fri Jul 16 08:11:16 2010 +0200 (2010-07-16) |
parents | e5dde73f1ac9 |
children | 304ad863fbe0 |
line source
1 #!/bin/sh
2 # get-OpenOffice3, install everything for OpenOffice.org exept KDE/Gnome integration and testsuite.
3 #
4 # (C) 2008 SliTaz - GNU General Public License v3.
5 #
6 # Author : Eric Joseph-Alexandre <erjo@slitaz.org>
8 PACKAGE="OpenOffice3"
9 URL="http://www.openoffice.org"
10 ROOT="$1"
12 case "$LANG" in
13 fr_FR|de_DE|es_ES|it_IT|ru_RU)
14 LOC=${LANG%_*}
15 DIR="localized/$LOC"
16 SUFFIX="LinuxIntel_install_$LOC.tar.gz";;
17 *)
18 DIR="stable"
19 SUFFIX="LinuxIntel_install_en-US.tar.gz";;
20 esac
22 VERSION="$(basename $(wget -O - http://openofficeorg.secsup.org/$DIR/ \
23 2> /dev/null | grep href=\"[0-9] | tail -1 | sed 's/.*href=\"\(.*\)\".*/\1/'))"
24 if [ -z "$VERSION" ]; then
25 echo "Can't find VERSION. Abort."
26 exit 0
27 fi
28 TARBALL="OOo_${VERSION}_${SUFFIX}"
29 WGET_URL=ftp://ftp.proxad.net/mirrors/ftp.openoffice.org/$DIR/$VERSION/$TARBALL
31 TEMP_DIR="/tmp/$PACKAGE.$$"
32 SOURCE_DIR="/tmp/src.$$"
33 EXCLUDE="kde|gnome|test"
34 LOG="/tmp/$(basename $0 .sh).log"
36 # Status function with color (supported by Ash).
37 status()
38 {
39 local CHECK=$?
40 echo -en "\\033[70G[ "
41 if [ $CHECK = 0 ]; then
42 echo -en "\\033[1;33mOK"
43 else
44 echo -en "\\033[1;31mFailed"
45 fi
46 echo -e "\\033[0;39m ]"
47 return $CHECK
48 }
50 # Check if user is root to install, or remove packages.
51 check_root()
52 {
53 if test $(id -u) != 0 ; then
54 echo -e "\nYou must be root to run `basename $0` with this option."
55 echo -e "Please use 'su' and root password to become super-user.\n"
56 exit 0
57 fi
58 }
60 check_if_installed()
61 {
62 # Avoid reinstall
63 if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ];then
64 return 0
65 else
66 return 1
67 fi
68 }
70 #We need to bee root
71 check_root
73 #check if package already installed
74 if (check_if_installed $PACKAGE); then
75 echo "$PACKAGE is already installed."
76 [ -n "$ROOT" ] && exit 0
77 echo -n "Would you like to remove and reinstall this package [y/n]? "
78 read answer
79 case "$answer" in
80 y|Y)
81 tazpkg remove $PACKAGE ;;
82 *)
83 exit 0 ;;
84 esac
86 fi
89 # Check if we have the tarball before.
90 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
91 echo "Downloading OppenOffice.org tarball (it's time to have a break)... "
92 #Check if $SOURCE_DIR exist
93 test -d $SOURCE_DIR || mkdir -p $SOURCE_DIR
94 # Get the file.
95 wget -c $WGET_URL -O $SOURCE_DIR/$TARBALL
96 status
97 fi
98 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
99 rm -rf $SOURCE_DIR
100 echo "Could not download $TARBALL. Exiting."
101 exit 1
102 fi
104 # Creates TEMP_DIR and extract tarball
105 mkdir -p $TEMP_DIR
106 echo -n "Extract files from archive..."
107 tar xvzf $SOURCE_DIR/$TARBALL -C $TEMP_DIR > $LOG 2>&1 || \
108 (echo "Failed to extract $TARBALL" ; exit 1)
109 status
111 # extracted pkg can be removed: Save RAM
112 rm -rf $SOURCE_DIR
114 cd $TEMP_DIR/*/RPMS
116 # Extract everything from RPMS
117 for i in *.rpm
118 do
119 if (! echo $i | egrep -qi $EXCLUDE); then
120 (rpm2cpio $i | cpio -id >> $LOG 2>&1 ) && rm -f $i
121 fi
122 done
123 rpm2cpio desktop-integration/*freedesktop*.rpm | cpio -id >> $LOG 2>&1
125 # extracted pkg can be removed: Save RAM
126 rm -f desktop-integration/*freedesktop*.rpm
129 # Make the package
130 mkdir -p $PACKAGE-$VERSION/fs/usr/lib/openoffice \
131 $PACKAGE-$VERSION/fs/usr/share
133 # use mv instead of 'cp -a' to save RAM
134 mv opt/openoffice* $PACKAGE-$VERSION/fs/usr/lib/openoffice
135 mv usr/share/mime $PACKAGE-$VERSION/fs/usr/share
136 mv usr/share/icons $PACKAGE-$VERSION/fs/usr/share
137 mv usr/bin $PACKAGE-$VERSION/fs/usr
139 # relocalized OOo libexec directory
140 sed -i 's#/opt/#/usr/lib/openoffice/#' $PACKAGE-$VERSION/fs/usr/bin/openoffice*
142 # Create receipt
143 cat > $PACKAGE-$VERSION/receipt <<EOT
144 # SliTaz package receipt.
146 PACKAGE="$PACKAGE"
147 VERSION="$VERSION"
148 CATEGORY="office"
149 SHORT_DESC="Productivity suite."
150 DEPENDS=""
151 WEB_SITE="$URL"
153 post_install()
154 {
155 cd /usr/share/applications
156 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/base.desktop openoffice.org3-base.desktop
157 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/impress.desktop openoffice.org3-impress.desktop
158 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/writer.desktop openoffice.org3-writer.desktop
159 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/calc.desktop openoffice.org3-calc.desktop
160 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/math.desktop openoffice.org3-math.desktop
161 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/draw.desktop openoffice.org3-draw.desktop
162 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/printeradmin.desktop openoffice.org3-printeradmin.desktop
164 cd /usr/bin
165 ln -sf /usr/lib/openoffice/openoffice.org3/program/soffice
166 }
168 post_remove()
169 {
170 rm -f /usr/share/applications/openoffice.org3-*
171 }
173 EOT
175 # Pack
176 tazpkg pack $PACKAGE-$VERSION
178 # Clean to save RAM memory
179 rm -rf $PACKAGE-$VERSION
181 # Install pseudo package
182 tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
184 # Clean
185 rm -rf $TEMP_DIR