#!/bin/bash

#
# OpenOffice.org QA script for GNU/Linux
#
# Supported versions: OOO680_m3 (OpenOffice.org 2.0 RC3)
#
# (c) Pavel Jan�k <Pavel@Janik.cz>, 2005
#

#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#

INSTSET=/disk2/OpenOffice.org/OOO680_m3/Build-1/OOo_OOO680_m3_LinuxIntel_install_en-US_rpm.tar.gz
DESTDIR=/tmp/QA

SOFFICE=${DESTDIR}/ROOT/program/soffice
TESTTOOL=${DESTDIR}/ROOT/program/testtool.bin

TESTSCRIPT=${DESTDIR}/qa/qatesttool/script/unix/OOoTestRun_unix.sh

PrepareInstallation () {

    echo -n "Installing $INSTSET ... "

    [ ! -f ${INSTSET} ] && {
	echo "ERROR: The file ${INSTSET} doesn't exist!  Please set INSTSET properly."
	exit
    }

    rm -rf ${DESTDIR}

    mkdir -p ${DESTDIR}
    (
	cd ${DESTDIR}

	tar xfz ${INSTSET}
	./install RPMS ${DESTDIR}/ROOT >/dev/null 2>&1
	rm -rf RPMS install uninstall
    )

    [ -x ${SOFFICE} ] || {
	echo "ERROR: The file ${SOFFICE} doesn't exist!"
	exit 1
    }

    echo "OK"
}

PrepareTestingScripts () {

    echo -n "Prepare testing environment ..."

    (
	cd ${DESTDIR}

	[ ! -f tt_env_OOo_2.0.0.tar.gz ] && wget http://qa.openoffice.org/qatesttool/src680/tt_env_OOo_2.0.0.tar.gz
	tar xfz tt_env_OOo_2.0.0.tar.gz
    )

    [ -x ${TESTSCRIPT} ] || {
	echo "ERROR: The file ${TESTSCRIPT} doesnt exist!"
	exit 1
    }

    echo "OK"

}

PrepareInstallation

PrepareTestingScripts

[ -f Files/tt_env_OOo_2.0.0.tar.gz ] && cp Files/tt_env_OOo_2.0.0.tar.gz ${DESTDIR}

cp Files/testtoolrc ~/.testtoolrc

cp Files/OOoTestRun_unix.sh ${TESTSCRIPT}

echo "Now you can run ${TESTSCRIPT} or ${TESTTOOL} for first and topten tests."