3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 jarfilename
="JavaSetup.jar"
21 tempdir
=/var
/tmp
/install_$$
24 java_runtime_found
="no"
25 java_runtime_sufficient
="no"
26 java_versions_supported
="1.4 1.5 1.6"
31 arch64string2
="64-bit"
32 sunjavahotspot
="HotSpot"
40 echo "Using $java_runtime"
41 echo `$java_runtime -version`
42 echo "Running installer"
44 # looking for environment variables
47 if [ "x" != "x$HOME" ]; then
52 if [ "x" != "x$LOG_MODULE_STATES" ]; then
53 log_module_states
=-DLOG_MODULE_STATES=$LOG_MODULE_STATES
57 if [ "x" != "x$GETUID_PATH" ]; then
58 getuid_path
=-DGETUID_PATH=$GETUID_PATH
61 if [ "x" != "x$jrefile" ]; then
62 jrecopy
=-DJRE_FILE=$jrefile
65 # run the installer class file
66 echo $java_runtime $home $log_module_states $getuid_path $jrecopy -jar $jarfilename
67 $java_runtime $home $log_module_states $getuid_path $jrecopy -jar $jarfilename
72 if [ "x$tempdir" != "x" -a -d "$tempdir" ]; then
80 if [ "x" != "x$errorcode" ]; then
81 exitstring
="$exitstring (exit code $errorcode)"
84 # simply echo the exitstring or open a xterm
85 # -> dependent from tty
93 errorfile
=$tempdir/error
95 cat > $errorfile << EOF
97 echo "Press return to continue ..."
103 # searching for xterm in path
106 for i
in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do
107 if [ -x "$i/$xtermname" -a ! -d "$i/$xtermname" ]; then
108 xtermname
="$i/$xtermname"
114 if [ $xtermfound = "no" -a "`uname -s`" = "SunOS" ]; then
115 if [ -x /usr
/openwin
/bin
/xterm
]; then
116 xtermname
=/usr
/openwin
/bin
/xterm
121 if [ $xtermfound = "yes" ]; then
122 $xtermname -e $errorfile
131 set_jre_for_uninstall
()
133 # if "uninstalldata" exists, this is not required
134 if [ ! -d "uninstalldata" ]; then
136 jrefile
=`find $packagepath -type f -name "jre*.rpm" -print`
137 jrefile
=`basename $jrefile`
138 if [ -z "$jrefile" ]; then
142 # check existence of jre rpm
143 if [ ! -f $packagepath/$jrefile ]; then
144 errortext
="Error: Java Runtime Environment (JRE) not found in directory: $packagepath"
153 # Linux requires usage of rpm2cpio to install JRE with user privileges
154 # 1. --relocate /usr/java=/var/tmp does not work, because not all files are
155 # relocatable. Some are always installed into /etc
156 # 2. --root only works with root privileges. With user privileges only the
157 # database is shifted, but not the files.
159 # On Linux currently rpm2cpio is required (and rpm anyhow)
163 if [ ! "$rpm2cpio_found" = "yes" ]; then
164 errortext
="Error: Did not find rpm2cpio. rpm2cpio is currently required for installations on Linux."
171 if [ ! "$rpm_found" = "yes" ]; then
172 errortext
="Error: Did not find rpm. rpm is currently required for installations on Linux."
177 # jrefile=jre-6-linux-i586.rpm
178 # javahome=usr/java/jre1.6.0
182 # using "uninstalldata" for uninstallation
183 if [ -d "uninstalldata" ]; then
184 packagepath
="uninstalldata/jre"
187 jrefile
=`find $packagepath -type f -name "jre*.rpm" -print`
188 jrefile
=`basename $jrefile`
189 if [ -z "$jrefile" ]; then
193 # check existence of jre rpm
194 if [ ! -f $packagepath/$jrefile ]; then
195 errortext
="Error: Java Runtime Environment (JRE) not found in directory: $packagepath"
200 PACKED_JARS
="lib/rt.jar lib/jsse.jar lib/charsets.jar lib/ext/localedata.jar lib/plugin.jar lib/javaws.jar lib/deploy.jar"
204 trap 'rm -rf $tempdir; exit 1' HUP INT QUIT TERM
206 tempjrefile
=$tempdir/$jrefile
207 cp $packagepath/$jrefile $tempjrefile
209 if [ ! -f "$tempjrefile" ]; then
210 errortext
="Error: Failed to copy Java Runtime Environment (JRE) temporarily."
215 # check if copy was successful
216 if [ -x /usr
/bin
/sum ]; then
218 echo "Checksumming..."
220 sumA
=`/usr/bin/sum $packagepath/$jrefile`
235 sumB
=`/usr/bin/sum $tempjrefile`
250 # echo "Checksum 1: A1: $sumA1 B1: $sumB1"
251 # echo "Checksum 2: A2: $sumA2 B2: $sumB2"
253 if [ $sumA1 -ne $sumB1 ] ||
[ $sumA2 -ne $sumB2 ]; then
254 errortext
="Error: Failed to install Java Runtime Environment (JRE) temporarily."
259 echo "Can't find /usr/bin/sum to do checksum. Continuing anyway."
262 # start to install jre
263 echo "Extracting ..."
266 rpm2cpio
$tempjrefile |
cpio -i --make-directories
267 rm -f $tempjrefile # we do not need it anymore, so conserve discspace
269 javahomeparent
=usr
/java
270 javahomedir
=`find $javahomeparent -maxdepth 1 -type d -name "jre*" -print`
271 javahomedir
=`basename $javahomedir`
272 if [ -z "$javahomedir" ]; then
273 javahomedir
="notfound"
276 javahome
=$javahomeparent/$javahomedir
278 if [ ! -d ${javahome} ]; then
279 errortext
="Error: Failed to extract the Java Runtime Environment (JRE) files."
284 UNPACK_EXE
=$javahome/bin
/unpack200
285 if [ -f $UNPACK_EXE ]; then
288 for i
in $PACKED_JARS; do
289 if [ -f $javahome/`dirname $i`/`basename $i .jar`.pack
]; then
290 # printf "Creating %s\n" $javahome/$i
291 $UNPACK_EXE $javahome/`dirname $i`/`basename $i .jar`.pack
$javahome/$i
292 if [ $?
-ne 0 ] ||
[ ! -f $javahome/$i ]; then
293 printf "ERROR: Failed to unpack JAR file:\n\n\t%s\n\n" $i
294 printf "Installation failed. Please refer to the Troubleshooting Section of\n"
295 printf "the Installation Instructions on the download page.\n"
300 # remove the old pack file
301 rm -f $javahome/`dirname $i`/`basename $i .jar`.pack
304 if [ "$packerror" = "1" ]; then
305 if [ -d $javahome ]; then
306 /bin
/rm -rf $javahome
309 errortext
="Error: Failed to extract the Java Runtime Environment (JRE) files."
315 PREFS_LOCATION
="`echo \"${javahome}\" | sed -e 's/^jdk.*/&\/jre/'`/.systemPrefs"
317 if [ ! -d "${PREFS_LOCATION}" ]; then
318 mkdir
-m 755 "${PREFS_LOCATION}"
320 if [ ! -f "${PREFS_LOCATION}/.system.lock" ]; then
321 touch "${PREFS_LOCATION}/.system.lock"
322 chmod 644 "${PREFS_LOCATION}/.system.lock"
324 if [ ! -f "${PREFS_LOCATION}/.systemRootModFile" ]; then
325 touch "${PREFS_LOCATION}/.systemRootModFile"
326 chmod 644 "${PREFS_LOCATION}/.systemRootModFile"
329 if [ x
$ARCH = "x32" ] && [ -f "$javahome/bin/java" ]; then
330 "$javahome/bin/java" -client -Xshare:dump
> /dev
/null
2>&1
333 java_runtime
=$tempdir/$javahome/bin
/java
335 # Make symbolic links to all TrueType font files installed in the system
336 # to avoid garbles for Japanese, Korean or Chinese
337 language
=`printenv LANG | cut -c 1-3`
338 if [ x
$language = "xja_" -o x
$language = "xko_" -o x
$language = "xzh_" ]; then
339 font_fallback_dir
=$javahome/lib
/fonts
/fallback
340 echo "Making symbolic links to TrueType font files into $font_fallback_dir."
341 mkdir
-p $font_fallback_dir
342 ttf_files
=`locate "*.ttf" | xargs`
343 if [ x
$ttf_files = "x" ]; then
344 ttf_files
=`find /usr/share/fonts/ -name "*ttf"`
345 if [ x
$ttf_files = "x" ]; then
346 ttf_files
=`find /usr/X11R6/lib/ -name "*ttf"`
349 ln -s $ttf_files $font_fallback_dir
358 # searching for rpm2cpio in path
359 for i
in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do
360 if [ -x "$i/rpm2cpio" -a ! -d "$i/$rpm2cpio" ]; then
369 # searching for rpm in path
370 for i
in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do
371 if [ -x "$i/rpm" -a ! -d "$i/$rpm" ]; then
380 # Check, if system and installation set fit together (x86 and sparc).
381 # If not, throw a warning.
382 # Architecture of the installation set is saved in file "installdata/xpd/setup.xpd"
383 # <architecture>sparc</architecture> or <architecture>i386</architecture>
384 # Architecture of system is determined with "uname -p"
386 setupxpdfile
="installdata/xpd/setup.xpd"
388 if [ -f $setupxpdfile ]; then
389 platform
=`uname -p` # valid values are "sparc" or "i386"
390 searchstring
="<architecture>$platform</architecture>"
391 match
=`cat $setupxpdfile | grep $searchstring`
393 if [ -z "$match" ]; then
394 # architecture does not fit, warning required
395 if [ "$platform" = "sparc" ]; then
396 echo "Warning: This is an attempt to install Solaris x86 packages on Solaris Sparc."
398 echo "Warning: This is an attempt to install Solaris Sparc packages on Solaris x86."
406 # searching for java runtime in path
407 for i
in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do
408 if [ -x "$i/$java_runtime" -a ! -d "$i/$java_runtime" ]; then
409 java_runtime
="$i/$java_runtime"
410 java_runtime_found
="yes"
418 # check version of an installed JRE
419 javaoutput
=`$java_runtime -version 2>&1 | tail ${tail_args} -1`
420 hotspot
=`echo $javaoutput | grep $sunjavahotspot`
421 if [ ! -z "$hotspot" ]; then
422 for i
in $java_versions_supported; do
423 versionmatch
=`echo $javaoutput | grep $i`
424 if [ ! -z "$versionmatch" ]; then
425 java_runtime_sufficient
="yes"
430 # check new version format, where version number is not part of line 3 (1.6)
431 if [ ! "$java_runtime_sufficient" = "yes" ]; then
432 javaoutput
=`$java_runtime -version 2>&1 | head ${tail_args} -3`
433 for i
in $java_versions_supported; do
434 versionmatch
=`echo $javaoutput | grep $i`
435 if [ ! -z "$versionmatch" ]; then
436 java_runtime_sufficient
="yes"
444 check_linux_jre_version
()
446 # check version of an installed JRE
447 javaoutput
=`$java_runtime -version 2>&1 | head -1`
449 for i
in $java_versions_supported; do
450 versionmatch
=`echo $javaoutput | grep $i`
451 if [ ! -z "$versionmatch" ]; then
452 java_runtime_sufficient
="yes"
458 check_64bit_architecture
()
460 # check system architecture using "uname -m"
461 # unameoutput=`uname -m 2>&1`
462 # x64str=`echo $unameoutput | grep $arch64string`
464 # check system architecture using "file /usr/bin/file"
465 fileoutput
=`file /usr/bin/file 2>&1`
466 x64str
=`echo $fileoutput | grep $arch64string2`
468 if [ ! -z "$x64str" ]; then
474 # the user might want to specify java runtime on the commandline
475 USAGE
="Usage: $0 [ -j <java_runtime> ]"
476 while getopts hj
: opt
; do
477 echo "Parameter: $opt"
479 j
) java_runtime_set
="yes";
480 java_runtime
="${OPTARG}"
481 if [ ! -f "$java_runtime" ]; then
482 errortext
="Error: Invalid java runtime $java_runtime, file does not exist."
486 if [ ! -x "$java_runtime" ]; then
487 errortext
="Error: Invalid java runtime $java_runtime, not an executable file."
491 java_runtime_found
="yes";
506 # changing into setup directory
509 # prepare jre, if not set on command line
510 if [ "$java_runtime_set" != "yes" ]; then
512 if [ "`uname -s`" = "Linux" ]; then
513 check_64bit_architecture
514 if [ "$is_64bit_arch" = "no" ]; then
518 if [ "$java_runtime_found" = "yes" ]; then
519 check_linux_jre_version
520 if [ ! "$java_runtime_sufficient" = "yes" ]; then
521 errortext
="Error: Did not find a valid Java Runtime Environment (JRE). Required JRE versions: $java_versions_supported"
526 errortext
="Error: Did not find an installed Java Runtime Environment (JRE)."
531 elif [ "`uname -s`" = "SunOS" ]; then
534 if [ "$java_runtime_found" = "yes" ]; then
536 if [ ! "$java_runtime_sufficient" = "yes" ]; then
537 errortext
="Error: Did not find a valid Java Runtime Environment (JRE). Required JRE versions: $java_versions_supported"
542 errortext
="Error: Did not find an installed Java Runtime Environment (JRE)."
547 errortext
="Error: Platform $platform not supported for Java Runtime Environment (JRE) installation."
553 # jre for Linux is also required, if java runtime is set (for uninstallation mode)
554 if [ "$java_runtime_set" = "yes" ]; then
556 if [ "`uname -s`" = "Linux" ]; then
557 set_jre_for_uninstall