wok-6.x view get-LibreOffice/stuff/get-LibreOffice @ rev 10159

Up: libcanberra to 0.28.
author Christopher Rogers <slaxemulator@gmail.com>
date Fri May 20 19:41:38 2011 +0000 (2011-05-20)
parents 1e6c96591f33
children da7a3815bacb
line source
1 #!/bin/sh
2 # get-LibreOffice - install LibreOffice excl. KDE/Gnome integration & test suite.
3 #
4 # (C) 2010 SliTaz - GNU General Public License v3.
5 # Author : Ben Arnold <ben@seawolfsanctuary.com>
6 # via : get-OpenOffice3 (Eric Joseph-Alexandre <erjo@slitaz.org>)
7 #
9 PACKAGE="LibreOffice"
10 URL="http://www.libreoffice.org"
11 ROOT="$1"
12 DIR="stable"
13 SUFFIX="Linux_x86_install-rpm_en-US.tar.gz"
15 VERSION="$(basename $(wget -O - http://download.documentfoundation.org/libreoffice/$DIR/ \
16 2> /dev/null | grep href=\"[0-9] | tail -1 | sed 's/.*href=\"//;s/[/\">].*//'))"
17 if [ -z "$VERSION" ]; then
18 echo "Can't detect an appropriate version. The version numbering or URL may have changed. Aborted."
19 exit 0
20 fi
21 VER="${VERSION/\-/}" # without hyphens
24 TARBALL="LibO_${VER}_${SUFFIX}"
25 WGET_URL="http://download.documentfoundation.org/libreoffice/${DIR}/${VERSION}/rpm/x86/${TARBALL}"
27 case "$LANG" in
28 fr_FR|de_DE|es_ES|it_IT|ru_RU)
29 LOC=${LANG%_*} # strip
30 L_SUFFIX="Linux_x86_langpack-rpm_$LOC.tar.gz"
31 L_TARBALL="LibO_${VER}_${L_SUFFIX}"
32 LANG_URL="http://download.documentfoundation.org/libreoffice/${DIR}/${VERSION}/rpm/x86/${L_TARBALL}"
33 echo "Added $LANG ($LOC)." ;;
34 en_GB|pt_BR)
35 LANG=${LANG/_/-} # convert
36 L_SUFFIX="Linux_x86_langpack-rpm_$LANG.tar.gz"
37 L_TARBALL="LibO_${VER}_${L_SUFFIX}"
38 LANG_URL="http://download.documentfoundation.org/libreoffice/${DIR}/${VERSION}/rpm/x86/${L_TARBALL}"
39 echo "Added $LANG." ;;
40 esac
43 TEMP_DIR="/tmp/$PACKAGE.$$"
44 SOURCE_DIR="/tmp/src.$$"
45 EXCLUDE="kde|gnome|test"
46 LOG="/tmp/$(basename $0 .sh).log"
49 # Status function with color (supported by Ash).
50 status()
51 {
52 local CHECK=$?
53 echo -en "\\033[70G[ "
54 if [ $CHECK = 0 ]; then
55 echo -en "\\033[1;33mOK"
56 else
57 echo -en "\\033[1;31mFailed"
58 fi
59 echo -e "\\033[0;39m ]"
60 return $CHECK
61 }
63 # Check if user is root to install, or remove packages.
64 check_root()
65 {
66 if test $(id -u) != 0 ; then
67 echo -e "\nYou must be root to run `basename $0` with this option."
68 echo -e "Please use 'su' and root password to become super-user.\n"
69 exit 0
70 fi
71 }
73 check_if_installed()
74 {
75 # Avoid reinstall
76 if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ];then
77 return 0
78 else
79 return 1
80 fi
81 }
83 # We need to be root
84 check_root
86 # Check if package already installed
87 if (check_if_installed $PACKAGE); then
88 echo "$PACKAGE is already installed."
89 [ -n "$ROOT" ] && exit 0
90 echo -n "Would you like to remove and reinstall this package [y/n]? "
91 read answer
92 case "$answer" in
93 y|Y)
94 tazpkg remove $PACKAGE ;;
95 *)
96 exit 0 ;;
97 esac
99 fi
102 # Check if we have the tarball before.
103 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
104 echo "Downloading LibreOffice tarball (it's time to have a break)... "
105 # Check if $SOURCE_DIR exist
106 test -d $SOURCE_DIR || mkdir -p $SOURCE_DIR
107 # Get the file.
108 wget -c $WGET_URL -O $SOURCE_DIR/$TARBALL
109 if [ -n $L_TARBALL ] ; then # Are we localised?
110 wget -c $LANG_URL -O $SOURCE_DIR/$L_TARBALL
111 fi
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 echo -n "Extracting files (this may take a while): "
122 # Creates TEMP_DIR and extract tarball
123 mkdir -p $TEMP_DIR
124 for TB in $TARBALL $L_TARBALL ; do
125 tar xvzf $SOURCE_DIR/$TB -C $TEMP_DIR > $LOG 2>&1 || \
126 (echo "Failed to extract $TB" ; exit 1)
127 done
129 # Get version found in archive (often directory is still RC version when final is present)
130 ARCHIVED_VERSION=`find $TEMP_DIR -type d 2> /dev/null | grep LibO | head -n 1 | sed 's/_/ /g' | awk '{print $2}'`
131 echo -n "(found v${ARCHIVED_VERSION})"
133 # Consolidate localisations into main package
134 if [ -n $L_TARBALL ] ; then # Are we localised?
135 TARBALL_NAME="${TARBALL/.tar.gz/}"
136 L_TARBALL_NAME="${L_TARBALL/.tar.gz/}"
137 mv -f $TEMP_DIR/${L_TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS/*.rpm $TEMP_DIR/${TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS/
138 fi
139 status
141 # Extracted pkg can be removed: Save RAM
142 rm -rf $SOURCE_DIR
144 # Extract everything from RPMS
145 cd $TEMP_DIR/${TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS
146 for i in *.rpm
147 do
148 if (! echo $i | egrep -qi $EXCLUDE); then
149 echo -n "."
150 (rpm2cpio $i | cpio -id >> $LOG 2>&1 ) && rm -f $i
151 fi
152 done
153 rpm2cpio desktop-integration/*freedesktop*.rpm | cpio -id >> $LOG 2>&1
155 # extracted pkg can be removed: Save RAM
156 rm -f desktop-integration/*freedesktop*.rpm
158 status
159 echo -n "Preparing package... "
161 # Make the package
162 mkdir -p $PACKAGE-$VERSION/fs/usr/lib/libreoffice \
163 $PACKAGE-$VERSION/fs/usr/share
165 # use mv instead of 'cp -a' to save RAM
166 mv opt/libreoffice* $PACKAGE-$VERSION/fs/usr/lib
167 mv usr/share/mime $PACKAGE-$VERSION/fs/usr/share
168 mv usr/share/icons $PACKAGE-$VERSION/fs/usr/share
169 mv usr/bin $PACKAGE-$VERSION/fs/usr
171 # relocalized libexec directory
172 sed -i 's#/opt/#/usr/lib/libreoffice/#' $PACKAGE-$VERSION/fs/usr/bin/libreoffice*
174 # Create receipt
175 cat > $PACKAGE-$VERSION/receipt <<EOT
176 # SliTaz package receipt.
178 PACKAGE="$PACKAGE"
179 VERSION="$VERSION"
180 CATEGORY="office"
181 SHORT_DESC="Productivity suite."
182 DEPENDS=""
183 WEB_SITE="$URL"
185 post_install()
186 {
187 cd /usr/share/applications
188 ln -s /usr/lib/libreoffice/share/xdg/base.desktop libreoffice-base.desktop
189 ln -s /usr/lib/libreoffice/share/xdg/impress.desktop libreoffice-impress.desktop
190 ln -s /usr/lib/libreoffice/share/xdg/writer.desktop libreoffice-writer.desktop
191 ln -s /usr/lib/libreoffice/share/xdg/calc.desktop libreoffice-calc.desktop
192 ln -s /usr/lib/libreoffice/share/xdg/math.desktop libreoffice-math.desktop
193 ln -s /usr/lib/libreoffice/share/xdg/draw.desktop libreoffice-draw.desktop
194 ln -s /usr/lib/libreoffice/share/xdg/printeradmin.desktop libreoffice-printeradmin.desktop
196 cd /usr/bin
197 ln -s /usr/lib/libreoffice /usr/lib/libreoffice/libreoffice
198 ln -sf /usr/lib/libreoffice/program/soffice
199 }
201 post_remove()
202 {
203 rm -f /usr/share/applications/libreoffice-*
204 }
206 EOT
207 status
209 # Pack
210 tazpkg pack $PACKAGE-$VERSION
212 # Clean to save RAM memory
213 rm -rf $PACKAGE-$VERSION
215 # Install pseudo package
216 tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
218 # Clean
219 rm -rf $TEMP_DIR