With the below script I have managed to download and install LibreOffice 4.0.1. There are no errors but nothing will open.
#!/bin/sh
# get-LibreOffice - install LibreOffice excl. KDE/Gnome integration & test suite.
#
# (C) 2010 SliTaz - GNU General Public License v3.
# Author : Ben Arnold <ben@seawolfsanctuary.com>
# via : get-OpenOffice4 (Eric Joseph-Alexandre <erjo@slitaz.org>)
#
PACKAGE="LibreOffice"
URL="http://www.libreoffice.org"
ROOT="$1"
DIR="stable"
SUFFIX="Linux_x86_rpm.tar.gz"
WGET_URL="http://download.documentfoundation.org/libreoffice/$DIR"
VERSION="$(basename $(wget -O - $WGET_URL/ 2> /dev/null | \
sed '/href=\"[0-9]/!d;s/.*href=\"//;s/[/\">].*//' | tail -1))"
if [ -z "$VERSION" ]; then
echo "Can't detect an appropriate version. The version numbering or URL may have changed. Aborted."
exit 0
fi
VER="${VERSION/\-/}" # without hyphens
TARBALL="LibreOffice_${VER}_${SUFFIX}"
for LOC in ${LANG/_/-} ${LANG%_*}; do
L_SUFFIX="Linux_x86_rpm_langpack_$LOC-GB.tar.gz"
L_TARBALL="LibreOffice_${VER}_${L_SUFFIX}"
LANG_URL="$WGET_URL/${VERSION}/rpm/x86/${L_TARBALL}"
busybox wget -s $LANG_URL 2> /dev/null || continue
echo "Added $LANG ($LOC)."
break
done
WGET_URL="$WGET_URL/${VERSION}/rpm/x86/${TARBALL}"
CUR_DIR=$(pwd)
TEMP_DIR="/tmp/$PACKAGE.$$"
SOURCE_DIR="/tmp/src.$$"
EXCLUDE="kde|gnome|test"
LOG="/tmp/$(basename $0 .sh).log"
# Status function with color (supported by Ash).
status()
{
local CHECK=$?
echo -en "\33[70G[ "
if [ $CHECK = 0 ]; then
echo -en "\33[1;33mOK"
else
echo -en "\33[1;31mFailed"
fi
echo -e "\33[0;39m ]"
return $CHECK
}
# Check if user is root to install, or remove packages.
check_root()
{
if test $(id -u) != 0 ; then
echo -e "\nYou must be root to run basename $0
with this option."
echo -e "Please use 'su' and root password to become super-user.\n"
exit 0
fi
}
check_if_installed()
{
# Avoid reinstall
if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ];then
return 0
else
return 1
fi
}
# We need to be root
check_root
# Check if package already installed
if (check_if_installed $PACKAGE); then
echo "$PACKAGE is already installed."
[ -n "$ROOT" ] && exit 0
echo -n "Would you like to remove and reinstall this package [y/n]? "
read answer
case "$answer" in
y|Y)
tazpkg remove $PACKAGE ;;
*)
exit 0 ;;
esac
fi
# Check if we have the tarball before.
if [ ! -f $SOURCE_DIR/$TARBALL ]; then
echo "Downloading LibreOffice tarball (it's time to have a break)... "
# Check if $SOURCE_DIR exist
test -d $SOURCE_DIR || mkdir -p $SOURCE_DIR
# Get the file.
wget -c $WGET_URL -O $SOURCE_DIR/$TARBALL
if [ -n $L_TARBALL ] ; then # Are we localised?
wget -c $LANG_URL -O $SOURCE_DIR/$L_TARBALL
fi
status
fi
if [ ! -f $SOURCE_DIR/$TARBALL ]; then
rm -rf $SOURCE_DIR
echo "Could not download $TARBALL. Exiting."
exit 1
fi
echo -n "Extracting files (this may take a while): "
# Creates TEMP_DIR and extract tarball
mkdir -p $TEMP_DIR
for TB in $TARBALL $L_TARBALL ; do
tar xvzf $SOURCE_DIR/$TB -C $TEMP_DIR > $LOG 2>&1 || \
(echo "Failed to extract $TB" ; exit 1)
done
# Get version found in archive (often directory is still RC version when final is present)
ARCHIVED_VERSION=find $TEMP_DIR -type d 2> /dev/null | grep LibreOffice | head -n 1 | sed 's/_/ /g' | awk '{print $2}'
echo -n "(found v${ARCHIVED_VERSION})"
# Consolidate localisations into main package
if [ -n $L_TARBALL ] ; then # Are we localised?
TARBALL_NAME="${TARBALL/.tar.gz/}"
L_TARBALL_NAME="${L_TARBALL/.tar.gz/}"
mv -f $TEMP_DIR/LibreOffice_4.0.1.2_Linux_x86_rpm_langpack_en-GB/RPMS/*.rpm $TEMP_DIR/LibreOffice_4.0.1.2_Linux_x86_rpm/RPMS/
fi
status
# Extracted pkg can be removed: Save RAM
rm -rf $SOURCE_DIR
# Extract everything from RPMS
cd $TEMP_DIR/LibreOffice_4.0.1.2_Linux_x86_rpm/RPMS
for i in *.rpm
do
if (! echo $i | egrep -qi $EXCLUDE); then
echo -n "."
(rpm2cpio $i | cpio -id >> $LOG 2>&1 ) && rm -f $i
fi
done
rpm2cpio desktop-integration/*freedesktop*.rpm | cpio -id >> $LOG 2>&1
# extracted pkg can be removed: Save RAM
rm -f desktop-integration/*freedesktop*.rpm
status
echo -n "Preparing package... "
# Make the package
mkdir -p $PACKAGE-$VERSION/fs/usr/lib/libreoffice \
$PACKAGE-$VERSION/fs/usr/share
# use mv instead of 'cp -a' to save RAM
mv opt/libreoffice* $PACKAGE-$VERSION/fs/usr/lib
mv usr/share/mime $PACKAGE-$VERSION/fs/usr/share
mv usr/share/icons $PACKAGE-$VERSION/fs/usr/share
mv usr/bin $PACKAGE-$VERSION/fs/usr
# relocalized libexec directory
bin=$(ls $PACKAGE-$VERSION/fs/usr/bin/libreoffice???)
if [ -L $bin ]; then
target=$(readlink $bin)
rm -f $bin
ln -s ${target/opt/usr\/lib\/libreoffice} $bin
else
sed -i 's#/opt/#/usr/lib/libreoffice/#' $bin
fi
# Create receipt
cat > $PACKAGE-$VERSION/receipt <<EOT
# SliTaz package receipt.
PACKAGE="$PACKAGE"
VERSION="$VERSION"
CATEGORY="office"
SHORT_DESC="Productivity suite."
DEPENDS="java6-jre"
WEB_SITE="$URL"
post_install()
{
cd /usr/share/applications
ln -s /usr/lib/libreoffice?*/share/xdg/base.desktop libreoffice-base.desktop
ln -s /usr/lib/libreoffice?*/share/xdg/impress.desktop libreoffice-impress.desktop
ln -s /usr/lib/libreoffice?*/share/xdg/writer.desktop libreoffice-writer.desktop
ln -s /usr/lib/libreoffice?*/share/xdg/calc.desktop libreoffice-calc.desktop
ln -s /usr/lib/libreoffice?*/share/xdg/math.desktop libreoffice-math.desktop
ln -s /usr/lib/libreoffice?*/share/xdg/draw.desktop libreoffice-draw.desktop
ln -s /usr/lib/libreoffice?*/share/xdg/printeradmin.desktop libreoffice-printeradmin.desktop
chmod +x /usr/lib/libreoffice?*/share/xdg/*.desktop
cd /usr/bin
ln -s /usr/lib/libreoffice?* /usr/lib/libreoffice
ln -sf /usr/lib/libreoffice/program/soffice
}
post_remove()
{
rm -f /usr/share/applications/libreoffice-*
}
EOT
status
# Pack
tazpkg pack $PACKAGE-$VERSION
# Clean to save RAM memory
rm -rf $PACKAGE-$VERSION
# Install pseudo package
tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
case " $@ " in
*\ --k*) mv $PACKAGE-$VERSION.tazpkg $CUR_DIR ;;
esac
# Clean
cd $CUR_DIR
rm -rf $TEMP_DIR