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
175 # Do not install gnome-integration package on systems without GNOME
176 pkginfo
-q SUNWgnome-vfs
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" ]
198 printf "\n$0: No packages found in $PACKAGE_PATH\n"
202 echo "Packages found:"
203 for i
in $PKG_LIST ; do
209 if [ "$UPDATE" = "yes" ]
211 if [ ! -d ${INSTALL_ROOT}/var
/sadm
/install
/admin
]
213 printf "\n$0: No package database in ${INSTALL_ROOT}.\n"
219 rmdir ${INSTALL_ROOT} 2>/dev
/null
220 if [ -d ${INSTALL_ROOT} ]
222 printf "\n$0: ${INSTALL_ROOT} exists and is not empty.\n"
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
]
232 cat > ${INSTALL_ROOT}/var
/sadm
/install
/admin
/default
<< EOF
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
252 if [ -x /usr
/bin
/mktemp
]
254 CMD
=`/usr/bin/mktemp /tmp/userinstall.XXXXXX`
256 CMD
=/tmp
/userinstall.$$
; echo "" > $CMD
259 sed -e 's|/opt/|${PKG_INSTALL_ROOT}/opt/|g' > $CMD
263 chmod +x
${INSTALL_ROOT}/usr
/lib
/postrun
2>/dev
/null
265 # create local tmp directory to install on S10
267 if [ -x /usr
/bin
/mktemp
]
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.$$
281 tail +$linenum $0 > $GETUID_SO
284 # Perform the installation
286 if [ "$UPDATE" = "yes" ]
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' {} \
;
294 # copy INST_RELEASE file
295 if [ ! -f ${INSTALL_ROOT}/var
/sadm
/system
/admin
/INST_RELEASE
]
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}" ]
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
309 LD_PRELOAD_32
=$GETUID_SO /usr
/sbin
/pkgadd
-d ${PACKAGE_PATH} -R ${INSTALL_ROOT} ${PKG_LIST} >/dev
/null || pkg_error
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
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 "####################################################################"
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
334 rm -f /tmp
/.ai.pkg.zone.lock
*
336 # remove local tmp directory
337 if [ ! -z ${LOCAL_TMP} ]
339 rm -f ${LOCAL_TMP}/.ai.pkg.zone.lock
*
341 rm -f ${INSTALL_ROOT}/tmp
342 mkdir
${INSTALL_ROOT}/tmp
346 # Create a link into the users home directory
349 if [ "$LINK" = "yes" ]
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"' {} \
;
361 # if an unpack directory exists, it can be removed now
362 if [ ! -z "$UNPACKDIR" ]
364 # for i in ${PKG_LIST}; do
365 # cd $UNPACKDIR; rm -rf $i
370 echo "Removed temporary directory $UNPACKDIR"
374 echo "Installation done ..."