wok-6.x view get-OpenOffice3/stuff/get-OpenOffice3 @ rev 8639
Up: slitaz-menus to 1.8. Added Education directory for menu. Also add applications-engineering and applications-science icons from gnome-icon-theme. Both 16 and 32 sizes.
author | Christopher Rogers <slaxemulator@gmail.com> |
---|---|
date | Tue Feb 15 03:49:26 2011 +0000 (2011-02-15) |
parents | 22293fc3d544 |
children | 0e12146570e9 |
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"
11 PATTERN="Linux_x86_install-rpm"
13 for MIRROR in \
14 http://mirror.switch.ch/ftp/mirror/OpenOffice \
15 http://openoffice.cict.fr \
16 http://wwwftp.ciril.fr/pub/openoffice \
17 http://artfiles.org/openoffice.org \
18 http://vesta.informatik.rwth-aachen.de/ftp/pub/mirror/OpenOffice \
19 http://ftp.ntua.gr/pub/OpenOffice \
20 http://ftp.iitm.ac.in/openoffice \
21 http://www.ring.gr.jp/archives/misc/openoffice \
22 http://ftp.nluug.nl/pub/office/openoffice \
24 do wget -O - $MIRROR/ 2> /dev/null | grep -q localized && break ; done
26 DIR="stable"
27 LOC=$(wget -O - $MIRROR/localized/ 2> /dev/null \
28 | grep -E ">$LANG/|>${LANG/_/-}/|>${LANG%_*}/" | head -1 | sed 's/.*href=\"\(.*\)\/\".*/\1/')
29 [ -n "$LOC" ] && DIR="localized/$LOC"
31 VERSION="$(basename $(wget -O - $MIRROR/$DIR/ \
32 2> /dev/null | grep href=\"[0-9] | tail -1 | sed 's/.*href=\"\(.*\)\".*/\1/'))"
33 if [ -z "$VERSION" ]; then
34 echo "Can't find VERSION. Abort."
35 exit 0
36 fi
37 echo "Selecting $DIR version $VERSION ..."
38 TARBALL="$(wget -O - $MIRROR/$DIR/$VERSION/ \
39 2> /dev/null | grep $PATTERN | tail -1 | sed 's/.*href=\"\(.*\)\".*/\1/')"
40 echo "Archive is $TARBALL ..."
41 WGET_URL=$MIRROR/$DIR/$VERSION/$TARBALL
43 TEMP_DIR="/tmp/$PACKAGE.$$"
44 SOURCE_DIR="/tmp/src.$$"
45 EXCLUDE="kde|gnome|test"
46 LOG="/tmp/$(basename $0 .sh).log"
48 # Status function with color (supported by Ash).
49 status()
50 {
51 local CHECK=$?
52 echo -en "\\033[70G[ "
53 if [ $CHECK = 0 ]; then
54 echo -en "\\033[1;33mOK"
55 else
56 echo -en "\\033[1;31mFailed"
57 fi
58 echo -e "\\033[0;39m ]"
59 return $CHECK
60 }
62 # Check if user is root to install, or remove packages.
63 check_root()
64 {
65 if test $(id -u) != 0 ; then
66 echo -e "\nYou must be root to run `basename $0` with this option."
67 echo -e "Please use 'su' and root password to become super-user.\n"
68 exit 0
69 fi
70 }
72 check_if_installed()
73 {
74 # Avoid reinstall
75 if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ];then
76 return 0
77 else
78 return 1
79 fi
80 }
82 #We need to bee root
83 check_root
85 #check if package already installed
86 if (check_if_installed $PACKAGE); then
87 echo "$PACKAGE is already installed."
88 [ -n "$ROOT" ] && exit 0
89 echo -n "Would you like to remove and reinstall this package [y/n]? "
90 read answer
91 case "$answer" in
92 y|Y)
93 tazpkg remove $PACKAGE ;;
94 *)
95 exit 0 ;;
96 esac
98 fi
101 # Check if we have the tarball before.
102 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
103 echo "Downloading OppenOffice.org tarball (it's time to have a break)... "
104 #Check if $SOURCE_DIR exist
105 test -d $SOURCE_DIR || mkdir -p $SOURCE_DIR
106 # Get the file.
107 wget -c $WGET_URL -O $SOURCE_DIR/$TARBALL
108 status
109 fi
110 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
111 rm -rf $SOURCE_DIR
112 echo "Could not download $TARBALL. Exiting."
113 exit 1
114 fi
116 # Creates TEMP_DIR and extract tarball
117 mkdir -p $TEMP_DIR
118 echo -n "Extract files from archive..."
119 tar xvzf $SOURCE_DIR/$TARBALL -C $TEMP_DIR > $LOG 2>&1 || \
120 (echo "Failed to extract $TARBALL" ; exit 1)
121 status
123 # extracted pkg can be removed: Save RAM
124 rm -rf $SOURCE_DIR
126 cd $TEMP_DIR/*/RPMS
128 # Extract everything from RPMS
129 for i in *.rpm
130 do
131 if (! echo $i | egrep -qi $EXCLUDE); then
132 (rpm2cpio $i | cpio -id >> $LOG 2>&1 ) && rm -f $i
133 fi
134 done
135 rpm2cpio desktop-integration/*freedesktop*.rpm | cpio -id >> $LOG 2>&1
137 # extracted pkg can be removed: Save RAM
138 rm -f desktop-integration/*freedesktop*.rpm
141 # Make the package
142 mkdir -p $PACKAGE-$VERSION/fs/usr/lib/openoffice \
143 $PACKAGE-$VERSION/fs/usr/share
145 # use mv instead of 'cp -a' to save RAM
146 mv opt/openoffice* $PACKAGE-$VERSION/fs/usr/lib/openoffice
147 mv usr/share/mime $PACKAGE-$VERSION/fs/usr/share
148 mv usr/share/icons $PACKAGE-$VERSION/fs/usr/share
149 mv usr/bin $PACKAGE-$VERSION/fs/usr
151 # relocalized OOo libexec directory
152 sed -i 's#/opt/#/usr/lib/openoffice/#' $PACKAGE-$VERSION/fs/usr/bin/openoffice*
154 # Create receipt
155 cat > $PACKAGE-$VERSION/receipt <<EOT
156 # SliTaz package receipt.
158 PACKAGE="$PACKAGE"
159 VERSION="$VERSION"
160 CATEGORY="office"
161 SHORT_DESC="Productivity suite."
162 DEPENDS=""
163 WEB_SITE="$URL"
165 post_install()
166 {
167 cd /usr/share/applications
168 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/base.desktop openoffice.org3-base.desktop
169 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/impress.desktop openoffice.org3-impress.desktop
170 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/writer.desktop openoffice.org3-writer.desktop
171 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/calc.desktop openoffice.org3-calc.desktop
172 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/math.desktop openoffice.org3-math.desktop
173 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/draw.desktop openoffice.org3-draw.desktop
174 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/printeradmin.desktop openoffice.org3-printeradmin.desktop
176 cd /usr/bin
177 ln -sf /usr/lib/openoffice/openoffice.org3/program/soffice
178 }
180 post_remove()
181 {
182 rm -f /usr/share/applications/openoffice.org3-*
183 }
185 EOT
187 # Pack
188 tazpkg pack $PACKAGE-$VERSION
190 # Clean to save RAM memory
191 rm -rf $PACKAGE-$VERSION
193 # Install pseudo package
194 tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
196 # Clean
197 rm -rf $TEMP_DIR