Impress Remote 1.0.5, tag sdremote-1.0.5
[LibreOffice.git] / setup_native / scripts / install_solaris.sh
blobf93fbe6fa42c3d964db9c93b157e00af4911ae4b
1 #!/usr/bin/env bash
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 ADD="no"
21 LINK="no"
22 UPDATE="no"
23 USAGE="Usage: $0 [-a] [-l] [-h] <pkg-source-dir> <office-installation-dir>"
25 help()
27 echo
28 echo "User Mode Installation script for developer and knowledgeable early access tester"
29 echo
30 echo "This installation method is not intended for use in a production environment!"
31 echo "Using this script is unsupported and completely at your own risk"
32 echo
33 echo "Usage:" $0 "<pkg-source-dir> <office-installation-dir> [-l]"
34 echo " <pkg-source-dir>: directory *only* containing the Solaris pkg packages to be installed"
35 echo " or language pack shell script containing the Solaris pkg packages"
36 echo " <office-installation-dir>: directory to where the office and the pkg database will get installed into"
37 echo
38 echo "Optional Parameter:"
39 echo " -a : add to an existing <office-installation-dir>"
40 echo " -l : create a link \"soffice\" in $HOME"
41 echo " -h : output this help"
44 try_to_unpack_languagepack_file()
46 FILENAME=$PACKAGE_PATH
48 # Checking, if $FILENAME is a language pack.
49 # String "language package" has to exist in the shell script file.
50 # If this is no language pack, the installation is not supported
52 SEARCHSTRING=`head -n 10 $FILENAME | grep "language package"`
54 if [ ! -z "$SEARCHSTRING" ]
55 then
56 echo "First parameter $FILENAME is a language pack";
57 else
58 printf "\nERROR: First parameter $FILENAME is a file, but no language pack shell script.\n"
59 echo $USAGE
60 exit 2
63 echo "Unpacking shell script $FILENAME"
64 # TAILLINE=`head -n 20 $FILENAME | sed --quiet 's/linenum=//p'`
65 TAILLINE=`head -n 20 $FILENAME | sed -n 's/linenum=//p'`
67 if [ -x "/usr/bin/mktemp" ] # available in Solaris 10
68 then
69 UNPACKDIR=`mktemp -d`
70 else
71 UNPACKDIR=/var/tmp/install_$$
72 mkdir $UNPACKDIR
75 echo $UNPACKDIR
76 tail +$TAILLINE $FILENAME | gunzip | (cd $UNPACKDIR; tar xvf -)
78 # Setting the new package path, in which the packages exist
79 PACKAGE_PATH=$UNPACKDIR
81 # Setting variable UPDATE, because an Office installation has to exist, if a language pack shall be installed
82 UPDATE="yes"
85 pkg_error()
87 # pkg command failed, check for admin log and report help
88 if [ -f /tmp/.ai.pkg.zone.lock-afdb66cf-1dd1-11b2-a049-000d560ddc3e ]
89 then
90 echo "####################################################################"
91 echo "# Installation failed due to stale administrative lock #"
92 echo "####################################################################"
93 printf "\nERROR: please remove the following file first:\n"
94 ls -l /tmp/.ai.pkg.zone.lock-afdb66cf-1dd1-11b2-a049-000d560ddc3e
96 rm -f $GETUID_SO
97 exit 1
100 get_pkg_list()
102 cd $1; ls -1
106 # this script is for userland not for root
109 if [ $UID -eq 0 ]
110 then
111 printf "\nThis script is for installation without administrative rights only\nPlease use pkgadd/patchadd to install as root\n"
112 help
113 exit 2
116 while getopts "alh" VALUE
118 echo $VALUE
119 case $VALUE in
120 a) ADD="yes"; break;;
121 h) help; exit 0;;
122 l) LINK="yes"; break;;
123 ?) echo $USAGE; exit 2;;
124 esac
125 done
126 shift `expr $OPTIND - 1`
128 if [ $# != 2 ]
129 then
130 echo $USAGE
131 exit 2
134 # Determine whether this is a patch or a regular install set ..
135 /bin/bash -c "ls $1/*/patchinfo >/dev/null 2>&1"
136 if [ "$?" = 0 ]
137 then
138 UPDATE="yes"
139 PATCH_PATH="$1"
140 PATCH_INFO_LIST=`/bin/bash -c "cd $1; ls */patchinfo"`
141 PATCH_LIST=`for i in ${PATCH_INFO_LIST}; do dirname $i; done`
142 elif [ -f "$1/patchinfo" ]
143 then
144 UPDATE="yes"
145 PATCH_PATH=`dirname "$1"`
146 PATCH_LIST=`basename "$1"`
147 else
148 if [ -d "$1/packages" ]
149 then
150 PACKAGE_PATH="$1/packages"
151 else
152 PACKAGE_PATH=$1
156 # If the first parameter is a shell script (download installation set), the packages have to
157 # be unpacked into temp directory
159 if [ -f "$PACKAGE_PATH" ]
160 then
161 try_to_unpack_languagepack_file
165 # Create sed filter script for unwanted packages
168 cat > /tmp/userinstall_filer.$$ << EOF
169 /SUNWadabas/d
170 /^SUNWj[0-9]/d
171 /-desktop-int/d
172 /-shared-mime-info/d
173 /-cde/d
176 # Do not install gnome-integration package on systems without GNOME
177 pkginfo -q SUNWgnome-vfs
178 if [ $? -ne 0 ]
179 then
181 echo '/-gnome/d' >> /tmp/userinstall_filer.$$
184 # pkgdep sorts the packages based on their dependencies
185 PKGDEP="`dirname $0`/pkgdep"
186 if [ ! -x $PKGDEP ]; then
187 PKGDEP="get_pkg_list"
191 # Get the list of packages to install
194 PKG_LIST=`$PKGDEP $PACKAGE_PATH | sed -f /tmp/userinstall_filer.$$`
195 rm -f /tmp/userinstall_filer.$$
197 if [ -z "$PKG_LIST" ]
198 then
199 printf "\n$0: No packages found in $PACKAGE_PATH\n"
200 exit 2
203 echo "Packages found:"
204 for i in $PKG_LIST ; do
205 echo $i
206 done
209 INSTALL_ROOT=$2
210 if [ "$UPDATE" = "yes" ]
211 then
212 if [ ! -d ${INSTALL_ROOT}/var/sadm/install/admin ]
213 then
214 printf "\n$0: No package database in ${INSTALL_ROOT}.\n"
215 exit 2
217 else
218 if [ "$ADD" = "no" ]
219 then
220 rmdir ${INSTALL_ROOT} 2>/dev/null
221 if [ -d ${INSTALL_ROOT} ]
222 then
223 printf "\n$0: ${INSTALL_ROOT} exists and is not empty.\n"
224 exit 2
227 mkdir -p ${INSTALL_ROOT}/var/sadm/install/admin
230 # Previous versions of this script did not write this file
231 if [ ! -f ${INSTALL_ROOT}/var/sadm/install/admin/default ]
232 then
233 cat > ${INSTALL_ROOT}/var/sadm/install/admin/default << EOF
234 action=nocheck
235 conflict=nocheck
236 setuid=nocheck
237 idepend=nocheck
238 mail=
242 if [ ! "${INSTALL_ROOT:0:1}" = "/" ]; then
243 INSTALL_ROOT=`cd ${INSTALL_ROOT}; pwd`
246 # This script must exist to make extension registration work
247 # always overwrite to get the latest version.
248 mkdir -p ${INSTALL_ROOT}/usr/lib
249 cat > ${INSTALL_ROOT}/usr/lib/postrun << \EOF
250 #!/bin/sh
251 set -e
253 if [ -x /usr/bin/mktemp ]
254 then
255 CMD=`/usr/bin/mktemp /tmp/userinstall.XXXXXX`
256 else
257 CMD=/tmp/userinstall.$$; echo "" > $CMD
260 sed -e 's|/opt/|${PKG_INSTALL_ROOT}/opt/|g' > $CMD
261 /bin/sh -e $CMD
262 rm -f $CMD
264 chmod +x ${INSTALL_ROOT}/usr/lib/postrun 2>/dev/null
266 # create local tmp directory to install on S10
267 LOCAL_TMP=
268 if [ -x /usr/bin/mktemp ]
269 then
270 LOCAL_TMP=`mktemp -d`
271 rmdir ${INSTALL_ROOT}/tmp 2>/dev/null
272 ln -s ${LOCAL_TMP} ${INSTALL_ROOT}/tmp
276 # the tail of the script contains a shared object for overloading the getuid()
277 # and a few other calls
280 GETUID_SO=/tmp/getuid.so.$$
281 linenum=???
282 tail +$linenum $0 > $GETUID_SO
285 # Perform the installation
287 if [ "$UPDATE" = "yes" ]
288 then
289 # restore original "bootstraprc" prior to patching
290 for i in ${PKG_LIST}; do
291 my_dir=${INSTALL_ROOT}`pkgparam -d ${PACKAGE_PATH} "$i" BASEDIR`
292 find "$my_dir" -type f -name bootstraprc.orig -exec sh -ce 'mv "$0" `dirname "$0"`/bootstraprc' {} \;
293 done
295 # copy INST_RELEASE file
296 if [ ! -f ${INSTALL_ROOT}/var/sadm/system/admin/INST_RELEASE ]
297 then
298 mkdir -p ${INSTALL_ROOT}/var/sadm/system/admin 2>/dev/null
299 cp -f /var/sadm/system/admin/INST_RELEASE ${INSTALL_ROOT}/var/sadm/system/admin/INST_RELEASE
302 # The case UPDATE="yes" is valid for patch installation and for language packs.
303 # For patches the variable PKG_LIST is empty, for language packs it is not empty.
304 # Patches have to be installed with patchadd, language packs with pkgadd
306 if [ -z "${PKG_LIST}" ]
307 then
308 LD_PRELOAD_32=$GETUID_SO /usr/sbin/patchadd -R ${INSTALL_ROOT} -M ${PATCH_PATH} ${PATCH_LIST} 2>&1 | grep -v '/var/sadm/patch' || pkg_error
309 else
310 LD_PRELOAD_32=$GETUID_SO /usr/sbin/pkgadd -d ${PACKAGE_PATH} -R ${INSTALL_ROOT} ${PKG_LIST} >/dev/null || pkg_error
313 else
315 # Create BASEDIR directories to avoid manual user interaction
316 for i in ${PKG_LIST}; do
317 mkdir -m 0755 -p ${INSTALL_ROOT}`pkgparam -d ${PACKAGE_PATH} $i BASEDIR` 2>/dev/null
318 done
320 if [ ! "${INSTALL_ROOT:0:1}" = "/" ]; then
321 INSTALL_ROOT=`cd ${INSTALL_ROOT}; pwd`
324 echo "####################################################################"
325 echo "# Installation of the found packages #"
326 echo "####################################################################"
327 echo
328 echo "Path to the packages : " $PACKAGE_PATH
329 echo "Path to the installation : " $INSTALL_ROOT
331 LD_PRELOAD_32=$GETUID_SO /usr/sbin/pkgadd -d ${PACKAGE_PATH} -R ${INSTALL_ROOT} ${PKG_LIST} >/dev/null || pkg_error
334 rm -f $GETUID_SO
335 rm -f /tmp/.ai.pkg.zone.lock*
337 # remove local tmp directory
338 if [ ! -z ${LOCAL_TMP} ]
339 then
340 rm -f ${LOCAL_TMP}/.ai.pkg.zone.lock*
341 rmdir ${LOCAL_TMP}
342 rm -f ${INSTALL_ROOT}/tmp
343 mkdir ${INSTALL_ROOT}/tmp
347 # Create a link into the users home directory
350 if [ "$LINK" = "yes" ]
351 then
352 rm -f $HOME/soffice 2>/dev/null
353 find `cd "$INSTALL_ROOT" && pwd` -name soffice -type f -perm -u+x -exec /bin/sh -ce 'ln -sf "$0" "$HOME/soffice" && echo "Creating link from $0 to $HOME/soffice"' {} \;
356 # patch the "bootstraprc" to create a self-containing installation
357 for i in ${PKG_LIST}; do
358 my_dir=${INSTALL_ROOT}`pkgparam -d ${PACKAGE_PATH} "$i" BASEDIR`
359 find "$my_dir" -type f -name bootstraprc -exec sh -ce 'test ! -f "$0".orig && mv "$0" "$0".orig && sed '\''s,^UserInstallation=$SYSUSERCONFIG.*,UserInstallation=$BRAND_BASE_DIR/../UserInstallation,'\'' "$0".orig > "$0"' {} \;
360 done
362 # if an unpack directory exists, it can be removed now
363 if [ ! -z "$UNPACKDIR" ]
364 then
365 # for i in ${PKG_LIST}; do
366 # cd $UNPACKDIR; rm -rf $i
367 # done
368 # rmdir $UNPACKDIR
370 rm -rf $UNPACKDIR
371 echo "Removed temporary directory $UNPACKDIR"
374 echo
375 echo "Installation done ..."
376 exit 0