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 .
23 USAGE
="Usage: $0 [-a] [-l] [-h] <pkg-source-dir> <office-installation-dir>"
28 echo "User Mode Installation script for developer and knowledgeable early access tester"
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"
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"
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" ]
56 echo "First parameter $FILENAME is a language pack";
58 printf "\nERROR: First parameter $FILENAME is a file, but no language pack shell script.\n"
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
71 UNPACKDIR
=/var
/tmp
/install_$$
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
87 # pkg command failed, check for admin log and report help
88 if [ -f /tmp
/.ai.pkg.zone.lock-afdb66cf-1dd1-11b2-a049-000d560ddc3e
]
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
106 # this script is for userland not for root
111 printf "\nThis script is for installation without administrative rights only\nPlease use pkgadd/patchadd to install as root\n"
116 while getopts "alh" VALUE
120 a
) ADD
="yes"; break;;
122 l
) LINK
="yes"; break;;
123 ?
) echo $USAGE; exit 2;;
126 shift `expr $OPTIND - 1`
134 # Determine whether this is a patch or a regular install set ..
135 /bin
/bash
-c "ls $1/*/patchinfo >/dev/null 2>&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" ]
145 PATCH_PATH
=`dirname "$1"`
146 PATCH_LIST
=`basename "$1"`
148 if [ -d "$1/packages" ]
150 PACKAGE_PATH
="$1/packages"
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" ]
161 try_to_unpack_languagepack_file
165 # Create sed filter script for unwanted packages
168 cat > /tmp
/userinstall_filer.$$
<< EOF
176 # Do not install gnome-integration package on systems without GNOME
177 pkginfo
-q SUNWgnome-vfs
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" ]
199 printf "\n$0: No packages found in $PACKAGE_PATH\n"
203 echo "Packages found:"
204 for i
in $PKG_LIST ; do
210 if [ "$UPDATE" = "yes" ]
212 if [ ! -d ${INSTALL_ROOT}/var
/sadm
/install
/admin
]
214 printf "\n$0: No package database in ${INSTALL_ROOT}.\n"
220 rmdir ${INSTALL_ROOT} 2>/dev
/null
221 if [ -d ${INSTALL_ROOT} ]
223 printf "\n$0: ${INSTALL_ROOT} exists and is not empty.\n"
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
]
233 cat > ${INSTALL_ROOT}/var
/sadm
/install
/admin
/default
<< EOF
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
253 if [ -x /usr
/bin
/mktemp
]
255 CMD
=`/usr/bin/mktemp /tmp/userinstall.XXXXXX`
257 CMD
=/tmp
/userinstall.$$
; echo "" > $CMD
260 sed -e 's|/opt/|${PKG_INSTALL_ROOT}/opt/|g' > $CMD
264 chmod +x
${INSTALL_ROOT}/usr
/lib
/postrun
2>/dev
/null
266 # create local tmp directory to install on S10
268 if [ -x /usr
/bin
/mktemp
]
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.$$
282 tail +$linenum $0 > $GETUID_SO
285 # Perform the installation
287 if [ "$UPDATE" = "yes" ]
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' {} \
;
295 # copy INST_RELEASE file
296 if [ ! -f ${INSTALL_ROOT}/var
/sadm
/system
/admin
/INST_RELEASE
]
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}" ]
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
310 LD_PRELOAD_32
=$GETUID_SO /usr
/sbin
/pkgadd
-d ${PACKAGE_PATH} -R ${INSTALL_ROOT} ${PKG_LIST} >/dev
/null || pkg_error
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
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 "####################################################################"
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
335 rm -f /tmp
/.ai.pkg.zone.lock
*
337 # remove local tmp directory
338 if [ ! -z ${LOCAL_TMP} ]
340 rm -f ${LOCAL_TMP}/.ai.pkg.zone.lock
*
342 rm -f ${INSTALL_ROOT}/tmp
343 mkdir
${INSTALL_ROOT}/tmp
347 # Create a link into the users home directory
350 if [ "$LINK" = "yes" ]
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"' {} \
;
362 # if an unpack directory exists, it can be removed now
363 if [ ! -z "$UNPACKDIR" ]
365 # for i in ${PKG_LIST}; do
366 # cd $UNPACKDIR; rm -rf $i
371 echo "Removed temporary directory $UNPACKDIR"
375 echo "Installation done ..."