wok-next view get-LibreOffice/stuff/get-LibreOffice @ rev 20889
Check Repology info from y* to z* packages: complete
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Sun Jul 15 10:27:39 2018 +0300 (2018-07-15) |
parents | 34b9552c3539 |
children |
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_rpm.tar.gz"
14 WGET_URL="http://download.documentfoundation.org/libreoffice/$DIR"
16 VERSION="$(basename $(wget -O - $WGET_URL/ 2> /dev/null | \
17 sed '/href=\"[0-9]/!d;s/.*href=\"//;s/[/\">].*//' | tail -1))"
18 if [ -z "$VERSION" ]; then
19 echo "Can't detect an appropriate version. The version numbering or URL may have changed. Aborted."
20 exit 0
21 fi
22 VER="${VERSION/\-/}" # without hyphens
25 TARBALL="LibreOffice_${VER}_${SUFFIX}"
27 for LOC in ${LANG/_/-} ${LANG%_*}; do
28 L_SUFFIX="Linux_x86_rpm_langpack_$LOC.tar.gz"
29 L_TARBALL="LibreOffice_${VER}_${L_SUFFIX}"
30 LANG_URL="$WGET_URL/${VERSION}/rpm/x86/${L_TARBALL}"
31 busybox wget -s $LANG_URL 2> /dev/null || continue
32 echo "Added $LANG ($LOC)."
33 break
34 done
35 WGET_URL="$WGET_URL/${VERSION}/rpm/x86/${TARBALL}"
37 CUR_DIR=$(pwd)
38 TEMP_DIR="/tmp/$PACKAGE.$$"
39 SOURCE_DIR="/tmp/src.$$"
40 EXCLUDE="kde|gnome|test"
41 LOG="/tmp/$(basename $0 .sh).log"
44 # Status function with color (supported by Ash).
45 status()
46 {
47 local CHECK=$?
48 echo -en "\\033[70G[ "
49 if [ $CHECK = 0 ]; then
50 echo -en "\\033[1;33mOK"
51 else
52 echo -en "\\033[1;31mFailed"
53 fi
54 echo -e "\\033[0;39m ]"
55 return $CHECK
56 }
58 # Check if user is root to install, or remove packages.
59 check_root()
60 {
61 if test $(id -u) != 0 ; then
62 echo -e "\nYou must be root to run `basename $0` with this option."
63 echo -e "Please use 'su' and root password to become super-user.\n"
64 exit 0
65 fi
66 }
68 check_if_installed()
69 {
70 # Avoid reinstall
71 if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ];then
72 return 0
73 else
74 return 1
75 fi
76 }
78 # We need to be root
79 check_root
81 # Check if package already installed
82 if (check_if_installed $PACKAGE); then
83 echo "$PACKAGE is already installed."
84 [ -n "$ROOT" ] && exit 0
85 echo -n "Would you like to remove and reinstall this package [y/n]? "
86 read answer
87 case "$answer" in
88 y|Y)
89 tazpkg remove $PACKAGE ;;
90 *)
91 exit 0 ;;
92 esac
94 fi
97 # Check if we have the tarball before.
98 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
99 echo "Downloading LibreOffice tarball (it's time to have a break)... "
100 # Check if $SOURCE_DIR exist
101 test -d $SOURCE_DIR || mkdir -p $SOURCE_DIR
102 # Get the file.
103 wget -c $WGET_URL -O $SOURCE_DIR/$TARBALL
104 if [ -n $L_TARBALL ] ; then # Are we localised?
105 wget -c $LANG_URL -O $SOURCE_DIR/$L_TARBALL
106 fi
107 status
109 fi
111 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
112 rm -rf $SOURCE_DIR
113 echo "Could not download $TARBALL. Exiting."
114 exit 1
115 fi
117 echo -n "Extracting files (this may take a while): "
119 # Creates TEMP_DIR and extract tarball
120 mkdir -p $TEMP_DIR
121 for TB in $TARBALL $L_TARBALL ; do
122 tar xvzf $SOURCE_DIR/$TB -C $TEMP_DIR > $LOG 2>&1 || \
123 (echo "Failed to extract $TB" ; exit 1)
124 done
126 # Get version found in archive (often directory is still RC version when final is present)
127 ARCHIVED_VERSION=`cd $TEMP_DIR;find . -type d 2> /dev/null | grep LibreOffice | head -n 1 | sed 's/_/ /g' | awk '{print $2}'`
128 echo -n "(found v${ARCHIVED_VERSION})"
130 # Consolidate localisations into main package
131 if [ -n $L_TARBALL ] ; then # Are we localised?
132 TARBALL_NAME="${TARBALL/.tar.gz/}"
133 L_TARBALL_NAME="${L_TARBALL/.tar.gz/}"
134 mv -f $TEMP_DIR/${L_TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS/*.rpm $TEMP_DIR/${TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS/
135 fi
136 status
138 # Extracted pkg can be removed: Save RAM
139 rm -rf $SOURCE_DIR
141 # Extract everything from RPMS
142 cd $TEMP_DIR/${TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS
143 for i in *.rpm
144 do
145 if (! echo $i | egrep -qi $EXCLUDE); then
146 echo -n "."
147 (rpm2cpio $i | cpio -id >> $LOG 2>&1 ) && rm -f $i
148 fi
149 done
151 #rpm2cpio desktop-integration/*freedesktop*.rpm | cpio -id >> $LOG 2>&1
152 #rpm2cpio *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/libreoffice \
162 $PACKAGE-$VERSION/fs/usr/share
164 # use mv instead of 'cp -a' to save RAM
165 mv opt/libreoffice* $PACKAGE-$VERSION/fs/usr/lib
166 mv usr/share/mime $PACKAGE-$VERSION/fs/usr/share
167 mv usr/share/icons $PACKAGE-$VERSION/fs/usr/share
168 mv usr/bin $PACKAGE-$VERSION/fs/usr
170 # relocalized libexec directory
171 bin=$(echo $PACKAGE-$VERSION/fs/usr/bin/libreoffice???)
172 if [ -L $bin ]; then
173 target=$(readlink $bin)
174 rm -f $bin
175 ln -s ${target/opt/usr\/lib\/libreoffice} $bin
176 else
177 sed -i 's#/opt/#/usr/lib/libreoffice/#' $bin
178 fi
180 # Create receipt
181 cat > $PACKAGE-$VERSION/receipt <<EOT
182 # SliTaz package receipt.
184 PACKAGE="$PACKAGE"
185 VERSION="$VERSION"
186 CATEGORY="office"
187 SHORT_DESC="Productivity suite."
188 DEPENDS="java6-jre cups"
189 WEB_SITE="$URL"
191 post_install()
192 {
193 ln -sf /usr/lib/libreoffice?* /usr/lib/libreoffice
194 path_libreoffice=\$(find /usr/lib/libreoffice -name libreoffice*.*)
196 # Remove links if exist
197 rm -f /usr/share/applications/libreoffice-*
199 # Create links
200 cd /usr/share/applications
201 ln -sf \$path_libreoffice/share/xdg/base.desktop libreoffice-base.desktop
202 ln -sf \$path_libreoffice/share/xdg/impress.desktop libreoffice-impress.desktop
203 ln -sf \$path_libreoffice/share/xdg/writer.desktop libreoffice-writer.desktop
204 ln -sf \$path_libreoffice/share/xdg/calc.desktop libreoffice-calc.desktop
205 ln -sf \$path_libreoffice/share/xdg/math.desktop libreoffice-math.desktop
206 ln -sf \$path_libreoffice/share/xdg/draw.desktop libreoffice-draw.desktop
208 chmod +x \$path_libreoffice/share/xdg/*.desktop
210 # If necessary, recreate links for soffice
211 rm -f /usr/bin/soffice /usr/bin/libreoffice
212 ln -sf \$path_libreoffice/program/soffice /usr/bin/libreoffice
213 ln -sf \$path_libreoffice/program/soffice /usr/bin/soffice
214 }
216 post_remove()
217 {
218 rm -f /usr/share/applications/libreoffice-*
219 }
221 EOT
222 status
224 # Pack
225 tazpkg pack $PACKAGE-$VERSION
227 # Clean to save RAM memory
228 rm -rf $PACKAGE-$VERSION
230 # Install pseudo package
231 tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
232 case " $@ " in
233 *\ --k*) mv $PACKAGE-$VERSION.tazpkg $CUR_DIR ;;
234 esac
236 # Clean
237 cd $CUR_DIR
238 rm -rf $TEMP_DIR