wok-current view get-OpenOffice3/stuff/get-OpenOffice3 @ rev 4862
xz: typo
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Feb 03 22:36:55 2010 +0100 (2010-02-03) |
parents | 50e1de79fccc |
children | 041af50bcc91 |
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 cd $TEMP_DIR/*/RPMS
113 # Extract everything from RPMS
114 for i in *.rpm
115 do
116 if (! echo $i | egrep -qi $EXCLUDE); then
117 rpm2cpio $i | cpio -id >> $LOG 2>&1
118 fi
119 done
120 rpm2cpio desktop-integration/*freedesktop*.rpm | cpio -id >> $LOG 2>&1
122 # Make the package
123 mkdir -p $PACKAGE-$VERSION/fs/usr/lib/openoffice \
124 $PACKAGE-$VERSION/fs/usr/share
126 cp -a opt/openoffice* $PACKAGE-$VERSION/fs/usr/lib/openoffice
127 cp -a usr/share/mime $PACKAGE-$VERSION/fs/usr/share
128 cp -a usr/share/icons $PACKAGE-$VERSION/fs/usr/share
129 cp -a usr/bin $PACKAGE-$VERSION/fs/usr
131 # relocalized OOo libexec directory
132 sed -i 's#/opt/#/usr/lib/openoffice/#' $PACKAGE-$VERSION/fs/usr/bin/openoffice*
134 # Create receipt
135 cat > $PACKAGE-$VERSION/receipt <<EOT
136 # SliTaz package receipt.
138 PACKAGE="$PACKAGE"
139 VERSION="$VERSION"
140 CATEGORY="office"
141 SHORT_DESC="Productivity suite."
142 DEPENDS=""
143 WEB_SITE="$URL"
145 post_install()
146 {
147 cd /usr/share/applications
148 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/base.desktop openoffice.org3-base.desktop
149 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/impress.desktop openoffice.org3-impress.desktop
150 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/writer.desktop openoffice.org3-writer.desktop
151 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/calc.desktop openoffice.org3-calc.desktop
152 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/math.desktop openoffice.org3-math.desktop
153 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/draw.desktop openoffice.org3-draw.desktop
154 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/printeradmin.desktop openoffice.org3-printeradmin.desktop
156 cd /usr/bin
157 ln -sf /usr/lib/openoffice/openoffice.org3/program/soffice
158 }
160 post_remove()
161 {
162 rm -f /usr/share/applications/openoffice.org3-*
163 }
165 EOT
167 # Pack
168 tazpkg pack $PACKAGE-$VERSION
170 # Install pseudo package
171 tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
173 # Clean
174 rm -rf $SOURCE_DIR
175 rm -rf $TEMP_DIR
176 rm -rf $PACKAGE-$VERSION