wok-6.x view get-LibreOffice/stuff/get-LibreOffice @ rev 14569
Up xorg-libXp (1.0.2), xorg-libXinerama (1.1.3), xorg-libXi (1.7.2)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri May 24 12:05:11 2013 +0200 (2013-05-24) |
parents | f5d346b5ac28 |
children | bf97de07272f |
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 WEB_SITE="http://www.libreoffice.org"
11 CATEGORY="office"
12 SHORT_DESC="Productivity suite."
13 DEPENDS="java6-jre cups"
14 ROOT="$1"
15 DIR="stable"
16 PREFIX="LibreOffice"
17 SUFFIX="Linux_x86_rpm.tar.gz"
18 WGET_URL="http://download.documentfoundation.org/libreoffice/$DIR"
20 VERSION="$(basename $(wget -O - $WGET_URL/ 2> /dev/null | \
21 sed '/href=\"[0-9]/!d;s/.*href=\"//;s/[/\">].*//' | tail -1))"
22 if [ -z "$VERSION" ]; then
23 echo "Can't detect an appropriate version. The version numbering or URL may have changed. Aborted."
24 exit 0
25 fi
26 VER="${VERSION/\-/}" # without hyphens
29 TARBALL="${PREFIX}_${VER}_${SUFFIX}"
31 for LOC in ${LANG/_/-} ${LANG%_*}; do
32 L_SUFFIX="Linux_x86_rpm_langpack_$LOC.tar.gz"
33 L_TARBALL="${PREFIX}_${VER}_${L_SUFFIX}"
34 LANG_URL="$WGET_URL/${VERSION}/rpm/x86/${L_TARBALL}"
35 busybox wget -s $LANG_URL 2> /dev/null || continue
36 echo "Added $LANG ($LOC)."
37 break
38 done
39 WGET_URL="$WGET_URL/${VERSION}/rpm/x86/${TARBALL}"
41 CUR_DIR=$(pwd)
42 TEMP_DIR="/tmp/$PACKAGE.$$"
43 SOURCE_DIR="/tmp/src.$$"
44 EXCLUDE="kde|gnome|test"
45 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 be 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 LibreOffice 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 if [ -n $L_TARBALL ] ; then # Are we localised?
109 wget -c $LANG_URL -O $SOURCE_DIR/$L_TARBALL
110 fi
111 status
112 fi
113 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
114 rm -rf $SOURCE_DIR
115 echo "Could not download $TARBALL. Exiting."
116 exit 1
117 fi
119 echo -n "Extracting files (this may take a while): "
121 # Creates TEMP_DIR and extract tarball
122 mkdir -p $TEMP_DIR
123 for TB in $TARBALL $L_TARBALL ; do
124 tar xvzf $SOURCE_DIR/$TB -C $TEMP_DIR > $LOG 2>&1 || \
125 (echo "Failed to extract $TB" ; exit 1)
126 done
128 # Get version found in archive (often directory is still RC version when final is present)
129 ARCHIVED_VERSION=$(find $TEMP_DIR -type d 2> /dev/null | sed "/$PREFIX/!d;\$!d;s/_/ /g" | awk '{print $2}')
130 echo -n "(found v${ARCHIVED_VERSION})"
132 # Consolidate localisations into main package
133 if [ -n $L_TARBALL ] ; then # Are we localised?
134 TARBALL_NAME="${TARBALL/.tar.gz/}"
135 L_TARBALL_NAME="${L_TARBALL/.tar.gz/}"
136 mv -f $TEMP_DIR/${L_TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS/*.rpm $TEMP_DIR/${TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS/
137 fi
138 status
140 # Extracted pkg can be removed: Save RAM
141 rm -rf $SOURCE_DIR
143 # Extract everything from RPMS
144 cd $TEMP_DIR/${TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS
145 for i in *.rpm
146 do
147 if (! echo $i | egrep -qi $EXCLUDE); then
148 echo -n "."
149 (rpm2cpio $i | cpio -id >> $LOG 2>&1 ) && rm -f $i
150 fi
151 done
152 rpm2cpio desktop-integration/*freedesktop*.rpm | cpio -id >> $LOG 2>&1
154 # extracted pkg can be removed: Save RAM
155 rm -f desktop-integration/*freedesktop*.rpm
157 status
158 echo -n "Preparing package... "
160 # Make the package
161 mkdir -p $PACKAGE-$VERSION/fs/usr/lib $PACKAGE-$VERSION/fs/usr/share
163 # use mv instead of 'cp -a' to save RAM
164 mv opt/libreoffice* $PACKAGE-$VERSION/fs/usr/lib/libreoffice
165 mv usr/share/mime $PACKAGE-$VERSION/fs/usr/share
166 mv usr/share/icons $PACKAGE-$VERSION/fs/usr/share
167 mv usr/bin $PACKAGE-$VERSION/fs/usr
169 # relocalized libexec directory
170 bin=$(echo $PACKAGE-$VERSION/fs/usr/bin/libreoffice${VERSION%.*})
171 if [ -L $bin ]; then
172 target=$(readlink $bin)
173 rm -f $bin
174 ln -s ${target/opt/usr\/lib\/libreoffice} $bin
175 else
176 sed -i 's#/opt/#/usr/lib/libreoffice/#' $bin
177 fi
179 # Create receipt
180 cat > $PACKAGE-$VERSION/receipt <<EOT
181 # SliTaz package receipt.
183 PACKAGE="$PACKAGE"
184 VERSION="$VERSION"
185 CATEGORY="$CATEGORY"
186 SHORT_DESC="$SHORT_DESC"
187 WEB_SITE="$WEB_SITE"
189 DEPENDS="$DEPENDS"
191 post_install()
192 {
193 cd \$1/usr/share/applications
194 ln -s /usr/lib/libreoffice*/share/xdg/base.desktop libreoffice-base.desktop
195 ln -s /usr/lib/libreoffice*/share/xdg/impress.desktop libreoffice-impress.desktop
196 ln -s /usr/lib/libreoffice*/share/xdg/writer.desktop libreoffice-writer.desktop
197 ln -s /usr/lib/libreoffice*/share/xdg/calc.desktop libreoffice-calc.desktop
198 ln -s /usr/lib/libreoffice*/share/xdg/math.desktop libreoffice-math.desktop
199 ln -s /usr/lib/libreoffice*/share/xdg/draw.desktop libreoffice-draw.desktop
200 ln -s /usr/lib/libreoffice*/share/xdg/printeradmin.desktop libreoffice-printeradmin.desktop
201 chmod +x /usr/lib/libreoffice*/share/xdg/*.desktop
203 cd \$1/usr/bin
204 ln -sf /usr/lib/libreoffice/program/soffice
205 }
207 post_remove()
208 {
209 rm -f \$1/usr/share/applications/libreoffice-*
210 }
212 EOT
213 status
215 # Pack
216 tazpkg pack $PACKAGE-$VERSION
218 # Clean to save RAM memory
219 rm -rf $PACKAGE-$VERSION
221 # Install pseudo package
222 tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
223 case " $@ " in
224 *\ --k*) mv $PACKAGE-$VERSION.tazpkg $CUR_DIR ;;
225 esac
227 # Clean
228 cd $CUR_DIR
229 rm -rf $TEMP_DIR