User:Wope/parallel installation

From The Document Foundation Wiki
Jump to: navigation, search

Mit dieser Shell installiere ich parallele Versionen. Konnte, mangels Möglichkeiten, nur den rpm-Zweig testen.

#!/bin/bash
#*************************************************************************
#*
#*  LibreOffice.org - a multi-platform office productivity suite
#*
#*  $RCSfile: load_LO.sh,v $
#*
#*  $Revision: 1.02 $
#*
#*  last change: $Author: wolfgang pechlaner $ $Date: 2016/10/01 20:50:00 $
#*
#*  The Contents of this file are made available subject to
#*  the terms of GNU Lesser General Public License Version 2.1.
#*
#*
#*    GNU Lesser General Public License Version 2.1
#*    =============================================
#*    Copyright 2005 by Sun Microsystems, Inc.
#*    901 San Antonio Road, Palo Alto, CA 94303, USA
#*
#*    This library is free software; you can redistribute it and/or
#*    modify it under the terms of the GNU Lesser General Public
#*    License version 2.1, as published by the Free Software Foundation.
#*
#*    This library is distributed in the hope that it will be useful,
#*    but WITHOUT ANY WARRANTY; without even the implied warranty of
#*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#*    Lesser General Public License for more details.
#*
#*    You should have received a copy of the GNU Lesser General Public
#*    License along with this library; if not, write to the Free Software
#*    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
#*    MA  02111-1307  USA
#*
#########################################################################
#
# Owner : wolfgang@pechlaner.at
#
# short description :   download the installationfiles from 
#                 http://downloadarchive.documentfoundation.org/libreoffice/old/
#                       prepares a 2nd Installation for testing
# # it is assumed, that
#                      - the installationfiles are temporaly in $DOWNLOADDIR, 
#                      - the opt-directory shall be expanded to $OPTDIR, 
#                      - the prefix of the tar.gz files is $PREFIXTAR 
#              - the langid is in $LANGID
#                     input :1 parameters (Version)
#
#########################################################################
DOWNLOADDIR=$HOME/LO
OPTDIR=no
PREFIXTAR=LibreOffice
LANGID=de
TYP=x86-64
# TYP=LinuxIntel
UNIXTYP=rpm
# UNIXTYP=deb
#########################################################################
usage() {
   echo "### Usage: $0 <Version>" 
   echo "### [-o OPTDIR] [-d DOWNLOADDIR] [-l LANGID]"
   echo "### [-p PREFIXTAR] [-t TYP]"
 }

paramvalues() {
   echo "Downloaddir : $DOWNLOADDIR"
   echo "Optdir      : $OPTDIR"
   echo "Langid      : $LANGID"
   echo "Prefixtar   : $PREFIXTAR"
   echo "Unixtyp     : $UNIXTYP"
   echo "TYP         : $TYP"
}



if [ $# -lt  1 ]
then
        usage;
        paramvalues;
        exit -1
else
        echo "*** $1 would be installed ***"
fi;

export VERSION="$1"
echo "$VERSION"

shift;           # further parameters
 
while [ $# -ge 2 ]
        do
        case $1 in
                -d)      DOWNLODDIR=$2;;
                -o)      OPTDIR=$2;;
                -l)      LANGID=$2;;
                -p)      PREFIXTAR=$2;;
                -u)      UNIXTYP=$2;;
                *)       echo "*** invalid parameter ***"
                        usage;
                        paramvalues;
                        exit -1;;
        esac
        shift; shift
done

case $UNIXTYP in
        rpm)     ;;
        deb)     ;;
        *)               echo "*** invalid UNIXTYP  ***"
                        paramvalues;
                        exit -1;;
esac

case $TYP in
        x86-64) UT=x86_64;;
        x86)    UT=x86;;
        *)              echo "*** invalid TYP  ***"
                        paramvalues;
                        exit -1;;
esac

if [ $OPTDIR = "no" ]
then
    OPTDIR=${DOWNLOADDIR}/$VERSION
fi

URL=http://downloadarchive.documentfoundation.org/libreoffice/old/
URL=${URL}${VERSION}/${UNIXTYP}/${UT}/

FIL=${PREFIXTAR}_${VERSION}_Linux_${TYP}_${UNIXTYP}

F1=${FIL}.tar.gz
FH=${FIL}_helppack_${LANGID}.tar.gz
FL=${FIL}_langpack_${LANGID}.tar.gz

SAVEPWD=$PWD
cd $DOWNLOADDIR

echo "*** download files ***"
echo ${URL}$F1
wget ${URL}$F1
if [ $? != 0 ]
then
        echo "*** can't download " ${URL}$F1 " ***"
        exit $?
fi
echo ${URL}$FH
wget ${URL}$FH
if [ $? != 0 ]
then
        echo "*** can't download " ${URL}$FH " ***"
        exit $?
fi
echo ${URL}$Fl
wget ${URL}$FL
if [ $? != 0 ]
then
        echo "*** can't download " ${URL}$FL " ***"
        exit $?
fi

TYP=Linux_$TYP


if [ ! -f ${DOWNLOADDIR}/${PREFIXTAR}_${VERSION}_${TYP}_${UNIXTYP}.tar.gz ] 
then
        echo "**1 file ${DOWNLOADDIR}/${PREFIXTAR}_${VERSION}_${TYP}_${UNIXTYP}.tar.gz not found **"
        paramvalues;
        exit 1 
fi
if [ ! -f ${DOWNLOADDIR}/${PREFIXTAR}_${VERSION}_${TYP}_${UNIXTYP}_langpack_${LANGID}.tar.gz ]
then
        echo "**2 file ${DOWNLOADDIR}/${PREFIXTAR}_${VERSION}_${TYP}_${UNIXTYP}_langpack_${LANGID}.tar.gz not found **"
        paramvalues;
        exit 1
fi
if [ ! -f ${DOWNLOADDIR}/${PREFIXTAR}_${VERSION}_${TYP}_${UNIXTYP}_helppack_${LANGID}.tar.gz ]
then
        echo "**3 file ${DOWNLOADDIR}/${PREFIXTAR}_${VERSION}_${TYP}_${UNIXTYP}_helppack_${LANGID}.tar.gz not found **"
        paramvalues;
        exit 1
fi
if [ ! -d $OPTDIR ]
then
        mkdir $OPTDIR
        echo "*** directory $OPTDIR created ***"
fi 
                
paramvalues;

if [ -d $OPTDIR/opt ]  ;then
        echo "******* delete the old files    *******"
        rm -rf $OPTDIR/opt
fi

echo "******* unpack the tar.gz files *******"

cd $DOWNLOADDIR
tar -xzvf ${PREFIXTAR}_${VERSION}_${TYP}_${UNIXTYP}.tar.gz                      >${VERSION}_install.log
tar -xzvf ${PREFIXTAR}_${VERSION}_${TYP}_${UNIXTYP}_langpack_$LANGID.*tar.gz    >>${VERSION}_install.log
tar -xzvf ${PREFIXTAR}_${VERSION}_${TYP}_${UNIXTYP}_helppack_$LANGID.*tar.gz    >>${VERSION}_install.log

echo "******* install $UNIXTYP files       *******" 

cd $OPTDIR
case $UNIXTYP in
  rpm)
    for i in $DOWNLOADDIR/${PREFIXTAR}_${VERSION}_${TYP}_${UNIXTYP}/RPMS/l*.$UNIXTYP
        do   rpm2cpio $i | cpio -id                                               2>>$DOWNLOADDIR/${VERSION}_install.log
    done
    for i in $DOWNLOADDIR/${PREFIXTAR}_${VERSION}_${TYP}_${UNIXTYP}_langpack_$LANGID/RPMS/l*.$UNIXTYP
        do   rpm2cpio $i | cpio -id                                               2>>$DOWNLOADDIR/${VERSION}_install.log
    done
    for i in $DOWNLOADDIR/${PREFIXTAR}_${VERSION}_${TYP}_${UNIXTYP}_helppack_$LANGID/RPMS/l*.$UNIXTYP
        do   rpm2cpio $i | cpio -id                                               2>>$DOWNLOADDIR/${VERSION}_install.log
    done
  ;;
  deb)
    for i in $DOWNLOADDIR/${PREFIXTAR}_${VERSION}_${TYP}_${UNIXTYP}/DEBS/l*.$UNIXTYP
        do   dpkg-deb -x $i .         2>>${VERSION}_install.log
    done
    for i in $DOWNLOADDIR/${PREFIXTAR}_${VERSION}_${TYP}_${UNIXTYP}_langpack_$LANGID/DEBS/l*.$UNIXTYP
        do   dpkg-deb -x $i .         2>>${VERSION}_install.log
    done
    for i in $DOWNLOADDIR/${PREFIXTAR}_${VERSION}_${TYP}_${UNIXTYP}_helppack_$LANGID/DEBS/l*.$UNIXTYP
        do   dpkg-deb -x $i .         2>>${VERSION}_install.log
    done

  ;;
esac

echo "******* test start $VERSION    *******"
li=`ls opt`
./opt/$li/program/soffice
echo "******* logfile ${VERSION}_install.log ******"
echo "******* delete installation files *******"
cd $DOWNLOADDIR
rm -rf ${FIL}*
cd $SAVEPWD