wok view get-OpenOffice3/stuff/get-OpenOffice3 @ rev 13710

get-OpenOffice3: small fixes
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Dec 17 20:32:43 2012 +0100 (2012-12-17)
parents 05c57ff37237
children c07aaa614a02
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
25 wget -O - $MIRROR/ 2> /dev/null | grep -q localized || continue
26 DIR="stable"
27 LOC=$(wget -O - $MIRROR/localized/ 2> /dev/null | \
28 grep -E ">$LANG/|>${LANG/_/-}/|>${LANG%_*}/" | \
29 head -1 | sed 's/.*href=\"\(.*\)\/\".*/\1/')
30 [ -n "$LOC" ] && DIR="localized/$LOC"
31 VERSION="$(basename $(wget -O - $MIRROR/$DIR/ 2> /dev/null | grep \
32 href=\"[0-9] | tail -1 | sed 's/.*href=\"\(.*\)\".*/\1/') 2> /dev/null)"
33 [ -n "$VERSION" ] && break
34 done
36 if [ -z "$VERSION" ]; then
37 echo "Can't find VERSION. Abort."
38 exit 0
39 fi
40 echo "Selecting $DIR version $VERSION ..."
41 TARBALL="$(wget -O - $MIRROR/$DIR/$VERSION/ \
42 2> /dev/null | grep $PATTERN | tail -1 | sed 's/.*href=\"\(.*\)\".*/\1/')"
43 echo "Archive is $TARBALL ..."
44 WGET_URL=$MIRROR/$DIR/$VERSION/$TARBALL
46 TEMP_DIR="/tmp/$PACKAGE.$$"
47 CUR_DIR=$(pwd)
48 SOURCE_DIR="/tmp/src.$$"
49 EXCLUDE="kde|gnome|test"
50 LOG="/tmp/$(basename $0 .sh).log"
52 # Status function with color (supported by Ash).
53 status()
54 {
55 local CHECK=$?
56 echo -en "\\033[70G[ "
57 if [ $CHECK = 0 ]; then
58 echo -en "\\033[1;33mOK"
59 else
60 echo -en "\\033[1;31mFailed"
61 fi
62 echo -e "\\033[0;39m ]"
63 return $CHECK
64 }
66 # Check if user is root to install, or remove packages.
67 check_root()
68 {
69 if test $(id -u) != 0 ; then
70 echo -e "\nYou must be root to run `basename $0` with this option."
71 echo -e "Please use 'su' and root password to become super-user.\n"
72 exit 0
73 fi
74 }
76 check_if_installed()
77 {
78 # Avoid reinstall
79 if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ];then
80 return 0
81 else
82 return 1
83 fi
84 }
86 #We need to bee root
87 check_root
89 #check if package already installed
90 if (check_if_installed $PACKAGE); then
91 echo "$PACKAGE is already installed."
92 [ -n "$ROOT" ] && exit 0
93 echo -n "Would you like to remove and reinstall this package [y/n]? "
94 read answer
95 case "$answer" in
96 y|Y)
97 tazpkg remove $PACKAGE ;;
98 *)
99 exit 0 ;;
100 esac
102 fi
105 # Check if we have the tarball before.
106 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
107 echo "Downloading OppenOffice.org tarball (it's time to have a break)... "
108 #Check if $SOURCE_DIR exist
109 test -d $SOURCE_DIR || mkdir -p $SOURCE_DIR
110 # Get the file.
111 wget -c $WGET_URL -O $SOURCE_DIR/$TARBALL
112 status
113 fi
114 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
115 rm -rf $SOURCE_DIR
116 echo "Could not download $TARBALL. Exiting."
117 exit 1
118 fi
120 # Creates TEMP_DIR and extract tarball
121 mkdir -p $TEMP_DIR
122 echo -n "Extract files from archive..."
123 tar xvzf $SOURCE_DIR/$TARBALL -C $TEMP_DIR > $LOG 2>&1 || \
124 (echo "Failed to extract $TARBALL" ; exit 1)
125 status
127 # extracted pkg can be removed: Save RAM
128 rm -rf $SOURCE_DIR
130 cd $TEMP_DIR/*/RPMS
132 # Extract everything from RPMS
133 for i in *.rpm
134 do
135 if (! echo $i | egrep -qi $EXCLUDE); then
136 (rpm2cpio $i | cpio -id >> $LOG 2>&1 ) && rm -f $i
137 fi
138 done
139 rpm2cpio desktop-integration/*freedesktop*.rpm | cpio -id >> $LOG 2>&1
141 # extracted pkg can be removed: Save RAM
142 rm -f desktop-integration/*freedesktop*.rpm
145 # Make the package
146 mkdir -p $PACKAGE-$VERSION/fs/usr/lib/openoffice \
147 $PACKAGE-$VERSION/fs/usr/share
149 # use mv instead of 'cp -a' to save RAM
150 mv opt/openoffice* $PACKAGE-$VERSION/fs/usr/lib/openoffice
151 mv usr/share/mime $PACKAGE-$VERSION/fs/usr/share
152 mv usr/share/icons $PACKAGE-$VERSION/fs/usr/share
153 mv usr/bin $PACKAGE-$VERSION/fs/usr
155 # relocalized OOo libexec directory
156 sed -i 's#/opt/#/usr/lib/openoffice/#' $PACKAGE-$VERSION/fs/usr/bin/openoffice*
158 # Create receipt
159 cat > $PACKAGE-$VERSION/receipt <<EOT
160 # SliTaz package receipt.
162 PACKAGE="$PACKAGE"
163 VERSION="$VERSION"
164 CATEGORY="office"
165 SHORT_DESC="Productivity suite."
166 DEPENDS="java-jre"
167 WEB_SITE="$URL"
169 post_install()
170 {
171 cd \$1/usr/share/applications
172 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/base.desktop openoffice.org3-base.desktop
173 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/impress.desktop openoffice.org3-impress.desktop
174 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/writer.desktop openoffice.org3-writer.desktop
175 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/calc.desktop openoffice.org3-calc.desktop
176 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/math.desktop openoffice.org3-math.desktop
177 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/draw.desktop openoffice.org3-draw.desktop
178 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/printeradmin.desktop openoffice.org3-printeradmin.desktop
180 cd \$1/usr/bin
181 ln -sf /usr/lib/openoffice/openoffice.org3/program/soffice
182 }
184 post_remove()
185 {
186 rm -f \$1/usr/share/applications/openoffice.org3-*
187 }
189 EOT
191 fake_install()
192 {
193 mkdir -p $ROOT/var/lib/tazpkg/installed/$PACKAGE
194 echo "00000000000000000000000000000000 $PACKAGE-$VERSION.tazpkg" >> \
195 $ROOT/var/lib/tazpkg/installed.md5
196 [ -s $1/description.txt $ROOT/var/lib/tazpkg/installed/$PACKAGE
197 ( cd fs ; find *) | sed 's|^|/|' > \
198 $ROOT/var/lib/tazpkg/installed/$PACKAGE/files.list
199 if grep -q ^CONFIG_FILES= $1/receipt ; then
200 cd fs
201 find $( . ./receipt ; echo " $CONFIG_FILES" | sed 's| /| |g') |\
202 cpio -o -H newc | gzip -9 > \
203 $ROOT/var/lib/tazpkg/installed/$PACKAGE/volatile.cpio.gz
204 for i in $( . ./receipt ; echo $CONFIG_FILES) ; do
205 [ -e $ROOT$i ] && rm -rf .$i
206 done
207 cd ..
208 fi
209 sed -i "s/^PACKAGE=/UNPACKED_SIZE=\"$(du -chs $1 | sed '$!d;s/.total//')\"\n&/" \
210 $1/receipt
211 cp $1/receipt $ROOT/var/lib/tazpkg/installed/$PACKAGE
212 echo "Compute md5sum..."
213 find fs -type f | xargs md5sum | sed 's| fs/| /|' > \
214 $ROOT/var/lib/tazpkg/installed/$PACKAGE/md5sum
215 echo "Move files..."
216 ( cd $1/fs ; find ) | while read file ; do
217 [ -e $1/fs/$file -a ! -e $ROOT/$file ] &&
218 mv $1/fs/$file $(dirname $ROOT/$file)
219 done
220 }
222 case " $@ " in
223 *\ --q*) # --quick
224 fake_install $PACKAGE-$VERSION ;;
225 *)
226 # Pack
227 tazpkg pack $PACKAGE-$VERSION
229 # Clean to save RAM memory
230 rm -rf $PACKAGE-$VERSION
232 # Install pseudo package
233 tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
235 echo " $@ " | grep -q ' --k' &&
236 mv $PACKAGE-$VERSION.tazpkg $CUR_DIR
237 ;;
238 esac
240 cd $CUR_DIR
242 # Clean
243 rm -rf $TEMP_DIR