summaryrefslogtreecommitdiff
path: root/solenv/bin/cwscheckapi
blob: 357a40a20ee56d8cef568b7512ca0054618544d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#!/bin/bash
#*************************************************************************
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# 
# Copyright 2008 by Sun Microsystems, Inc.
#
# OpenOffice.org - a multi-platform office productivity suite
#
# $RCSfile: cwscheckapi,v $
#
# $Revision: 1.5 $
#
# This file is part of OpenOffice.org.
#
# OpenOffice.org is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# only, as published by the Free Software Foundation.
#
# OpenOffice.org 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 version 3 for more details
# (a copy is included in the LICENSE file that accompanied this code).
#
# You should have received a copy of the GNU Lesser General Public License
# version 3 along with OpenOffice.org.  If not, see
# <http://www.openoffice.org/license.html>
# for a copy of the LGPLv3 License.
#***********************************************************************/


EXIT_SUCCESS=0
EXIT_FAILURE=1
EXIT_ERROR=2
EXIT_BUG=10

usage() {
        echo "Usage: $SCRIPTNAME [-m MODULE1[,MODULEn]] [-k] [-o] [-h] [-d] [-i] [-t] [-s] [-a]" >&2
        echo "" >&2
        echo "[-m] list of modules to test like: '-m sw,sc,sd' or '-m all' for all modules" >&2
        echo "" >&2
        echo "[-k] keep Office installation, otherwise it will be removed after test" >&2
        echo "" >&2
        echo "[-o] force OpenOffice.org installation instead of StarOffice" >&2
        echo "" >&2
        echo "[-d] debug installation and UnoAPI-Tests" >&2
        echo "" >&2
        echo "[-i] debug installation" >&2
        echo "" >&2
        echo "[-t] debug UnoAPI-Tests" >&2
        echo "" >&2
        echo "[-s] skip installation of Office" >&2
        echo "" >&2
        echo "[-a] NoCwsAttach: do not attach UnoAPI-Test result to EIS database" >&2
        echo "" >&2
        echo "further informations: http://wiki.services.openoffice.org/wiki/Cwscheckapi" >&2
        echo "" >&2
        exit $EXIT_FAILURE
}

if [ "$PROEXT" != ".pro" ]; then
    echo "ERROR: cwscheckapi works only on pro-versions" >&2
    exit $EXIT_FAILURE
fi

if [ x${USER}x = xx ]; then
    if [ x${LOGNAME}x = xx ]; then
        echo "ERROR: could not determine username. Please export variable USER" >&2
        exit $EXIT_FAILURE
    else 
        USER=$LOGNAME
        export USER
    fi
fi
     


DEBUG_I=false
DEBUG_T=false
INSTALL=true
ATTACH=ture
MODULES="auto"
OOO=false
KEEPOFFICE=false

while getopts ':m:dkitsaho' OPTION ; do
        case $OPTION in
        d)        DEBUG_I=true
                  DEBUG_T=true
                ;;
        m)        MODULES="$OPTARG"
                ;;
        k)        KEEPOFFICE=true
                ;;
        o)        OOO=true
                ;;
        i)        DEBUG_I=true
                ;;
        t)        DEBUG_T=true
                ;;
        s)        INSTALL=false
                ;;
        a)        ATTACH=false
                ;;
        h)        usage $EXIT_SUCCESS
                ;;
        \?)        echo "unkown option \"-$OPTARG\"." >&2
                usage $EXIT_ERROR
                ;;
        *)        echo "this is not possible...">&2
                usage $EXIT_BUG
                ;;
        esac
done

shift `expr $OPTIND - 1`

if [ -d /export/home/$USER ]; then
    CWSCHECKAPIPATH=/export/home/$USER/cwscheckapi
else
    if [ -w /export/home ]; then
        mkdir /export/home/$USER
        CWSCHECKAPIPATH=/export/home/$USER/cwscheckapi
    else
        CWSCHECKAPIPATH=/tmp/$USER/cwscheckapi
    fi
fi

# the following line is to cleanup old cwscheckapi-installations. It results form the first version of cwscheckapi
# The disk space on /tmp is limited. If a lot of users run cwscheckapi a lot of installed offices are in /tmp
# The new concept is to remove the offices after test. But old unused installations should be removed...
if [ $CWSCHECKAPIPATH != /tmp/$USER/cwscheckapi ]; then
    rm -rf /tmp/$USER/cwscheckapi
fi

LOCALINSTALLDIR=$CWSCHECKAPIPATH/office
LOCALUNPACKDIR=$CWSCHECKAPIPATH/unpack
export LOCALINSTALLDIR
export LOCALUNPACKDIR

unset FORCE2ARCHIVE

date 2>&1

if [ $INSTALL = true ]; then
	
    
	if [ $DEBUG_I = true ]; then
        echo "start installation: `date`"
		echo call "$SOLARENV/bin/installoffice.pl -cwscheckapi true -dest $LOCALINSTALLDIR -debug $DEBUG_I"
    fi
    perl -w $SOLARENV/bin/installoffice.pl -cwscheckapi true -dest $LOCALINSTALLDIR -ooo $OOO -debug $DEBUG_I

    EXITVAL=$?
    
    if [ $EXITVAL -ne 0 ]; then
        echo "ERROR: could not install office"
        exit $EXITVAL
    fi
	echo "`date` installation successfull, start testing...." 
fi

SOFFICE="soffice"
PS=":"
CYGWIN=""

SHELL="/bin/bash"
# cygwin:
if [ "$GUI" = "WNT" ]; then
    SOFFICE="soffice.exe"
    PS=";"
    CYGWIN="-Cygwin true"
    SHELL=`which bash`
    SHELL=`cygpath -w $SHELL`
    if [ ! -f $SHELL ]; then
        echo "could not determine bash shell" 
        exit 1
    fi
fi

if [ $DEBUG_T = true ]; then
    echo find $LOCALINSTALLDIR -name $SOFFICE
fi

OFFICEBIN=`find $LOCALINSTALLDIR -name $SOFFICE`

if [ ! -f "$OFFICEBIN" ]; then
    echo "could not find 'soffice' in subfolders of $LOCALINSTALLDIR"
    exit 1
fi

if [ "$GUI" = "WNT" ]; then
    # transform /tmp/... -> c:\tmp\...
    OFFICEBIN=`cygpath -w $OFFICEBIN`
fi

JARFOLDER=$SOLARVERSION/$INPATH/bin$UPDMINOREXT
SOLVER_LIB=$SOLARVERSION/$INPATH/lib$UPDMINOREXT
myCLASSPATH=${PS}${JARFOLDER}/ridl.jar${PS}${JARFOLDER}/unoil.jar${PS}${JARFOLDER}/jurt.jar${PS}${JARFOLDER}/juh.jar${PS}${JARFOLDER}/java_uno.jar
myCLASSPATH=$myCLASSPATH${PS}${JARFOLDER}/OOoRunner.jar
myCLASSPATH=$myCLASSPATH${PS}/net/unoapi/export/unoapi/bin/mysql.jar${PS}$SOLVER_LIB
PARAM=""
if [ -n "$JAVAI" ]; then
        JAVABIN=$JAVAI
elif [ -n "$JAVA_HOME" ]; then
    if [ "$OS$CPUNAME$CPU" = SOLARISSPARCU ]; then
        JAVABIN=$JAVA_HOME/bin/sparcv9/java
    else
        JAVABIN=$JAVA_HOME/bin/java
    fi
else
        echo "please set environment variable JAVA_HOME"
        exit 1
fi

if [ -n "$WORK_STAMP" ]; then
	if [ -n "$CWS_WORK_STAMP" ]; then
        PARAM="$PARAM -Version cws_${CWS_WORK_STAMP}"
	else
	    echo "######"
	    echo CAUTION! You are working on the MWS
	    echo "######"
        PARAM="$PARAM -Version ${WORK_STAMP}_${UPDMINOR}"
	fi
fi

PARAM="$PARAM -cmd '$OFFICEBIN -nofirststartwizard -accept=pipe,name=$USER;urp; -norestore -nocrashreport -nolockcheck -enableautomation'"
PARAM="$PARAM -cs pipe,name=$USER"
PARAM="$PARAM -NoOffice true"
PARAM="$PARAM -SRC_ROOT $SRC_ROOT"
PARAM="$PARAM -COMP_ENV $OUTPATH"
PARAM="$PARAM -Shell $SHELL"
PARAM="$PARAM $CYGWIN"
PARAM="$PARAM -tb java_complex"
PARAM="$PARAM -TimeOut 90000"
PARAM="$PARAM -o complex.unoapi.CheckModuleAPI::module($MODULES)"
if [ $ATTACH = false ]; then
    PARAM="$PARAM -nca true"
fi
if [ $DEBUG_T = true ]; then
    PARAM="$PARAM -debug true -log true"
fi

#XDEBUG=" -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8001 " 
COMMAND="$JAVABIN -Xmx120m $XDEBUG -cp $myCLASSPATH org.openoffice.Runner $PARAM $*"
echo "$COMMAND"

LOGFILE=$CWSCHECKAPIPATH/cwscheckapi.log
$COMMAND | tee $LOGFILE

if [ $KEEPOFFICE = false ]; then
    echo "remove office instrallation in $LOCALINSTALLDIR..."
    rm -rf $LOCALINSTALLDIR
fi

echo
echo A logfile could be found here: $LOGFILE

date 2>&1