cURL: follow redirects
[LibreOffice.git] / setup_native / scripts / install_solaris.sh
blobde60ea92be673570403007e4fc9907d2f18e1cd8
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 /^SUNWj[0-9]/d
170 /-desktop-int/d
171 /-shared-mime-info/d
172 /-cde/d
175 # Do not install gnome-integration package on systems without GNOME
176 pkginfo -q SUNWgnome-vfs
177 if [ $? -ne 0 ]
178 then
180 echo '/-gnome/d' >> /tmp/userinstall_filer.$$
183 # pkgdep sorts the packages based on their dependencies
184 PKGDEP="`dirname $0`/pkgdep"
185 if [ ! -x $PKGDEP ]; then
186 PKGDEP="get_pkg_list"
190 # Get the list of packages to install
193 PKG_LIST=`$PKGDEP $PACKAGE_PATH | sed -f /tmp/userinstall_filer.$$`
194 rm -f /tmp/userinstall_filer.$$
196 if [ -z "$PKG_LIST" ]
197 then
198 printf "\n$0: No packages found in $PACKAGE_PATH\n"
199 exit 2
202 echo "Packages found:"
203 for i in $PKG_LIST ; do
204 echo $i
205 done
208 INSTALL_ROOT=$2
209 if [ "$UPDATE" = "yes" ]
210 then
211 if [ ! -d ${INSTALL_ROOT}/var/sadm/install/admin ]
212 then
213 printf "\n$0: No package database in ${INSTALL_ROOT}.\n"
214 exit 2
216 else
217 if [ "$ADD" = "no" ]
218 then
219 rmdir ${INSTALL_ROOT} 2>/dev/null
220 if [ -d ${INSTALL_ROOT} ]
221 then
222 printf "\n$0: ${INSTALL_ROOT} exists and is not empty.\n"
223 exit 2
226 mkdir -p ${INSTALL_ROOT}/var/sadm/install/admin
229 # Previous versions of this script did not write this file
230 if [ ! -f ${INSTALL_ROOT}/var/sadm/install/admin/default ]
231 then
232 cat > ${INSTALL_ROOT}/var/sadm/install/admin/default << EOF
233 action=nocheck
234 conflict=nocheck
235 setuid=nocheck
236 idepend=nocheck
237 mail=
241 if [ ! "${INSTALL_ROOT:0:1}" = "/" ]; then
242 INSTALL_ROOT=`cd ${INSTALL_ROOT}; pwd`
245 # This script must exist to make extension registration work
246 # always overwrite to get the latest version.
247 mkdir -p ${INSTALL_ROOT}/usr/lib
248 cat > ${INSTALL_ROOT}/usr/lib/postrun << \EOF
249 #!/bin/sh
250 set -e
252 if [ -x /usr/bin/mktemp ]
253 then
254 CMD=`/usr/bin/mktemp /tmp/userinstall.XXXXXX`
255 else
256 CMD=/tmp/userinstall.$$; echo "" > $CMD
259 sed -e 's|/opt/|${PKG_INSTALL_ROOT}/opt/|g' > $CMD
260 /bin/sh -e $CMD
261 rm -f $CMD
263 chmod +x ${INSTALL_ROOT}/usr/lib/postrun 2>/dev/null
265 # create local tmp directory to install on S10
266 LOCAL_TMP=
267 if [ -x /usr/bin/mktemp ]
268 then
269 LOCAL_TMP=`mktemp -d`
270 rmdir ${INSTALL_ROOT}/tmp 2>/dev/null
271 ln -s ${LOCAL_TMP} ${INSTALL_ROOT}/tmp
275 # the tail of the script contains a shared object for overriding the getuid()
276 # and a few other calls
279 GETUID_SO=/tmp/getuid.so.$$
280 linenum=???
281 tail +$linenum $0 > $GETUID_SO
284 # Perform the installation
286 if [ "$UPDATE" = "yes" ]
287 then
288 # restore original "bootstraprc" prior to patching
289 for i in ${PKG_LIST}; do
290 my_dir=${INSTALL_ROOT}`pkgparam -d ${PACKAGE_PATH} "$i" BASEDIR`
291 find "$my_dir" -type f -name bootstraprc.orig -exec sh -ce 'mv "$0" `dirname "$0"`/bootstraprc' {} \;
292 done
294 # copy INST_RELEASE file
295 if [ ! -f ${INSTALL_ROOT}/var/sadm/system/admin/INST_RELEASE ]
296 then
297 mkdir -p ${INSTALL_ROOT}/var/sadm/system/admin 2>/dev/null
298 cp -f /var/sadm/system/admin/INST_RELEASE ${INSTALL_ROOT}/var/sadm/system/admin/INST_RELEASE
301 # The case UPDATE="yes" is valid for patch installation and for language packs.
302 # For patches the variable PKG_LIST is empty, for language packs it is not empty.
303 # Patches have to be installed with patchadd, language packs with pkgadd
305 if [ -z "${PKG_LIST}" ]
306 then
307 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
308 else
309 LD_PRELOAD_32=$GETUID_SO /usr/sbin/pkgadd -d ${PACKAGE_PATH} -R ${INSTALL_ROOT} ${PKG_LIST} >/dev/null || pkg_error
312 else
314 # Create BASEDIR directories to avoid manual user interaction
315 for i in ${PKG_LIST}; do
316 mkdir -m 0755 -p ${INSTALL_ROOT}`pkgparam -d ${PACKAGE_PATH} $i BASEDIR` 2>/dev/null
317 done
319 if [ ! "${INSTALL_ROOT:0:1}" = "/" ]; then
320 INSTALL_ROOT=`cd ${INSTALL_ROOT}; pwd`
323 echo "####################################################################"
324 echo "# Installation of the found packages #"
325 echo "####################################################################"
326 echo
327 echo "Path to the packages : " $PACKAGE_PATH
328 echo "Path to the installation : " $INSTALL_ROOT
330 LD_PRELOAD_32=$GETUID_SO /usr/sbin/pkgadd -d ${PACKAGE_PATH} -R ${INSTALL_ROOT} ${PKG_LIST} >/dev/null || pkg_error
333 rm -f $GETUID_SO
334 rm -f /tmp/.ai.pkg.zone.lock*
336 # remove local tmp directory
337 if [ ! -z ${LOCAL_TMP} ]
338 then
339 rm -f ${LOCAL_TMP}/.ai.pkg.zone.lock*
340 rmdir ${LOCAL_TMP}
341 rm -f ${INSTALL_ROOT}/tmp
342 mkdir ${INSTALL_ROOT}/tmp
346 # Create a link into the users home directory
349 if [ "$LINK" = "yes" ]
350 then
351 rm -f $HOME/soffice 2>/dev/null
352 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"' {} \;
355 # patch the "bootstraprc" to create a self-containing installation
356 for i in ${PKG_LIST}; do
357 my_dir=${INSTALL_ROOT}`pkgparam -d ${PACKAGE_PATH} "$i" BASEDIR`
358 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"' {} \;
359 done
361 # if an unpack directory exists, it can be removed now
362 if [ ! -z "$UNPACKDIR" ]
363 then
364 # for i in ${PKG_LIST}; do
365 # cd $UNPACKDIR; rm -rf $i
366 # done
367 # rmdir $UNPACKDIR
369 rm -rf $UNPACKDIR
370 echo "Removed temporary directory $UNPACKDIR"
373 echo
374 echo "Installation done ..."
375 exit 0