wok-4.x rev 7832
Add get-LibreOffice (v1.0) - script (based on get-OpenOffice3) to download and package LibreOffice w/out lang. packs
author | Ben Arnold <ben@seawolfsanctuary.com> |
---|---|
date | Sun Dec 26 22:00:38 2010 +0000 (2010-12-26) |
parents | adf1e2623e66 |
children | 50289f6c8ce3 |
files | get-LibreOffice/receipt get-LibreOffice/stuff/get-LibreOffice |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/get-LibreOffice/receipt Sun Dec 26 22:00:38 2010 +0000 1.3 @@ -0,0 +1,16 @@ 1.4 +# SliTaz package receipt. 1.5 + 1.6 +PACKAGE="get-LibreOffice" 1.7 +VERSION="1.0" 1.8 +CATEGORY="office" 1.9 +SHORT_DESC="Productivity suite." 1.10 +MAINTAINER="ben@seawolfsanctuary.com" 1.11 +WEB_SITE="http://www.documentfoundation.org" 1.12 +TAGS="office word excel ppt openoffice libreoffice" 1.13 + 1.14 +# Rules to gen a SliTaz package suitable for Tazpkg. 1.15 +genpkg_rules() 1.16 +{ 1.17 + mkdir -p $fs/usr/bin 1.18 + install -o root -g root -m755 stuff/get-LibreOffice $fs/usr/bin 1.19 +} 1.20 \ No newline at end of file
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/get-LibreOffice/stuff/get-LibreOffice Sun Dec 26 22:00:38 2010 +0000 2.3 @@ -0,0 +1,186 @@ 2.4 +#!/bin/sh 2.5 +# get-LibreOffice - install LibreOffice excl. KDE/Gnome integration & test suite. 2.6 +# 2.7 +# (C) 2010 SliTaz - GNU General Public License v3. 2.8 +# Author : Ben Arnold <ben@seawolfsanctuary.com> 2.9 +# via : get-OpenOffice3 (Eric Joseph-Alexandre <erjo@slitaz.org>) 2.10 +# 2.11 + 2.12 +PACKAGE="LibreOffice" 2.13 +URL="http://www.libreoffice.org" 2.14 +ROOT="$1" 2.15 + 2.16 +DIR="testing" 2.17 +SUFFIX="Linux_x86_install-rpm_en-US.tar.gz" 2.18 + 2.19 +VERSION="$(basename $(wget -O - http://download.documentfoundation.org/libreoffice/$DIR/ \ 2.20 + 2> /dev/null | grep href=\"[0-9] | tail -1 | sed 's/.*href=\"//;s/[/\">].*//'))" 2.21 +if [ -z "$VERSION" ]; then 2.22 + echo "Can't detect an appropriate version. The version numbering or URL may have changed. 2.23 + Aborted." 2.24 + exit 0 2.25 +fi 2.26 +VER="${VERSION/\-/}" # without hyphens 2.27 + 2.28 +TARBALL="LibO_${VER}_${SUFFIX}" 2.29 +WGET_URL="http://download.documentfoundation.org/libreoffice/${DIR}/${VERSION}/rpm/x86/${TARBALL}" 2.30 +TEMP_DIR="/tmp/$PACKAGE.$$" 2.31 +SOURCE_DIR="/tmp/src.$$" 2.32 +EXCLUDE="kde|gnome|test" 2.33 +LOG="/tmp/$(basename $0 .sh).log" 2.34 + 2.35 +# Status function with color (supported by Ash). 2.36 +status() 2.37 +{ 2.38 + local CHECK=$? 2.39 + echo -en "\\033[70G[ " 2.40 + if [ $CHECK = 0 ]; then 2.41 + echo -en "\\033[1;33mOK" 2.42 + else 2.43 + echo -en "\\033[1;31mFailed" 2.44 + fi 2.45 + echo -e "\\033[0;39m ]" 2.46 + return $CHECK 2.47 +} 2.48 + 2.49 +# Check if user is root to install, or remove packages. 2.50 +check_root() 2.51 +{ 2.52 + if test $(id -u) != 0 ; then 2.53 + echo -e "\nYou must be root to run `basename $0` with this option." 2.54 + echo -e "Please use 'su' and root password to become super-user.\n" 2.55 + exit 0 2.56 + fi 2.57 +} 2.58 + 2.59 +check_if_installed() 2.60 +{ 2.61 + # Avoid reinstall 2.62 + if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ];then 2.63 + return 0 2.64 + else 2.65 + return 1 2.66 + fi 2.67 +} 2.68 + 2.69 +#We need to bee root 2.70 +check_root 2.71 + 2.72 +#check if package already installed 2.73 +if (check_if_installed $PACKAGE); then 2.74 + echo "$PACKAGE is already installed." 2.75 + [ -n "$ROOT" ] && exit 0 2.76 + echo -n "Would you like to remove and reinstall this package [y/n]? " 2.77 + read answer 2.78 + case "$answer" in 2.79 + y|Y) 2.80 + tazpkg remove $PACKAGE ;; 2.81 + *) 2.82 + exit 0 ;; 2.83 + esac 2.84 + 2.85 +fi 2.86 + 2.87 + 2.88 +# Check if we have the tarball before. 2.89 +if [ ! -f $SOURCE_DIR/$TARBALL ]; then 2.90 + echo "Downloading LibreOffice tarball (it's time to have a break)... " 2.91 + #Check if $SOURCE_DIR exist 2.92 + test -d $SOURCE_DIR || mkdir -p $SOURCE_DIR 2.93 + # Get the file. 2.94 + wget -c $WGET_URL -O $SOURCE_DIR/$TARBALL 2.95 + status 2.96 +fi 2.97 +if [ ! -f $SOURCE_DIR/$TARBALL ]; then 2.98 + rm -rf $SOURCE_DIR 2.99 + echo "Could not download $TARBALL. Exiting." 2.100 + exit 1 2.101 +fi 2.102 + 2.103 +# Creates TEMP_DIR and extract tarball 2.104 +mkdir -p $TEMP_DIR 2.105 +echo -n "Extract files from archive..." 2.106 +tar xvzf $SOURCE_DIR/$TARBALL -C $TEMP_DIR > $LOG 2>&1 || \ 2.107 + (echo "Failed to extract $TARBALL" ; exit 1) 2.108 +status 2.109 + 2.110 +# extracted pkg can be removed: Save RAM 2.111 +rm -rf $SOURCE_DIR 2.112 + 2.113 +cd $TEMP_DIR/*/RPMS 2.114 + 2.115 +# Extract everything from RPMS 2.116 +echo -n "Extracting files" 2.117 +for i in *.rpm 2.118 +do 2.119 + if (! echo $i | egrep -qi $EXCLUDE); then 2.120 + echo -n "." 2.121 + (rpm2cpio $i | cpio -id >> $LOG 2>&1 ) && rm -f $i 2.122 + fi 2.123 +done 2.124 +rpm2cpio desktop-integration/*freedesktop*.rpm | cpio -id >> $LOG 2>&1 2.125 + 2.126 +# extracted pkg can be removed: Save RAM 2.127 +rm -f desktop-integration/*freedesktop*.rpm 2.128 + 2.129 +status 2.130 +echo -n "Preparing package... " 2.131 + 2.132 +# Make the package 2.133 +mkdir -p $PACKAGE-$VERSION/fs/usr/lib/libreoffice \ 2.134 + $PACKAGE-$VERSION/fs/usr/share 2.135 + 2.136 +# use mv instead of 'cp -a' to save RAM 2.137 +mv opt/libreoffice* $PACKAGE-$VERSION/fs/usr/lib 2.138 +mv usr/share/mime $PACKAGE-$VERSION/fs/usr/share 2.139 +mv usr/share/icons $PACKAGE-$VERSION/fs/usr/share 2.140 +mv usr/bin $PACKAGE-$VERSION/fs/usr 2.141 + 2.142 +# relocalized OOo libexec directory 2.143 +sed -i 's#/opt/#/usr/lib/libreoffice/#' $PACKAGE-$VERSION/fs/usr/bin/libreoffice* 2.144 + 2.145 +# Create receipt 2.146 +cat > $PACKAGE-$VERSION/receipt <<EOT 2.147 +# SliTaz package receipt. 2.148 + 2.149 +PACKAGE="$PACKAGE" 2.150 +VERSION="$VERSION" 2.151 +CATEGORY="office" 2.152 +SHORT_DESC="Productivity suite." 2.153 +DEPENDS="" 2.154 +WEB_SITE="$URL" 2.155 + 2.156 +post_install() 2.157 +{ 2.158 + cd /usr/share/applications 2.159 + ln -s /usr/lib/libreoffice/share/xdg/base.desktop libreoffice-base.desktop 2.160 + ln -s /usr/lib/libreoffice/share/xdg/impress.desktop libreoffice-impress.desktop 2.161 + ln -s /usr/lib/libreoffice/share/xdg/writer.desktop libreoffice-writer.desktop 2.162 + ln -s /usr/lib/libreoffice/share/xdg/calc.desktop libreoffice-calc.desktop 2.163 + ln -s /usr/lib/libreoffice/share/xdg/math.desktop libreoffice-math.desktop 2.164 + ln -s /usr/lib/libreoffice/share/xdg/draw.desktop libreoffice-draw.desktop 2.165 + ln -s /usr/lib/libreoffice/share/xdg/printeradmin.desktop libreoffice-printeradmin.desktop 2.166 + 2.167 + cd /usr/bin 2.168 + ln -sf /usr/lib/libreoffice/program/soffice 2.169 +} 2.170 + 2.171 +post_remove() 2.172 +{ 2.173 + rm -f /usr/share/applications/libreoffice-* 2.174 +} 2.175 + 2.176 +EOT 2.177 +status 2.178 + 2.179 +# Pack 2.180 +tazpkg pack $PACKAGE-$VERSION 2.181 + 2.182 +# Clean to save RAM memory 2.183 +rm -rf $PACKAGE-$VERSION 2.184 + 2.185 +# Install pseudo package 2.186 +tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT 2.187 + 2.188 +# Clean 2.189 +rm -rf $TEMP_DIR