merge the formfield patch from ooo-build
[ooovba.git] / setup_native / scripts / install_solaris.sh
blob7c4cc754054050995a9353e1b880a86f19811398
1 #!/bin/bash
3 ADD="no"
4 LINK="no"
5 UPDATE="no"
6 USAGE="Usage: $0 [-a] [-l] [-h] <pkg-source-dir> <office-installation-dir>"
8 help()
10 echo
11 echo "User Mode Installation script for developer and knowledgeable early access tester"
12 echo
13 echo "This installation method is not intended for use in a production environment!"
14 echo "Using this script is unsupported and completely at your own risk"
15 echo
16 echo "Usage:" $0 "<pkg-source-dir> <office-installation-dir> [-l]"
17 echo " <pkg-source-dir>: directory *only* containing the Solaris pkg packages to be installed"
18 echo " or language pack shell script containing the Solaris pkg packages"
19 echo " <office-installation-dir>: directory to where the office and the pkg database will get installed into"
20 echo
21 echo "Optional Parameter:"
22 echo " -a : add to an existing <office-installation-dir>"
23 echo " -l : create a link \"soffice\" in $HOME"
24 echo " -h : output this help"
27 try_to_unpack_languagepack_file()
29 FILENAME=$PACKAGE_PATH
31 # Checking, if $FILENAME is a language pack.
32 # String "language package" has to exist in the shell script file.
33 # If this is no language pack, the installation is not supported
35 SEARCHSTRING=`head -n 10 $FILENAME | grep "language package"`
37 if [ ! -z "$SEARCHSTRING" ]
38 then
39 echo "First parameter $FILENAME is a language pack";
40 else
41 printf "\nERROR: First parameter $FILENAME is a file, but no language pack shell script.\n"
42 echo $USAGE
43 exit 2
46 echo "Unpacking shell script $FILENAME"
47 # TAILLINE=`head -n 20 $FILENAME | sed --quiet 's/linenum=//p'`
48 TAILLINE=`head -n 20 $FILENAME | sed -n 's/linenum=//p'`
50 if [ -x "/usr/bin/mktemp" ] # available in Solaris 10
51 then
52 UNPACKDIR=`mktemp -d`
53 else
54 UNPACKDIR=/var/tmp/install_$$
55 mkdir $UNPACKDIR
58 echo $UNPACKDIR
59 tail +$TAILLINE $FILENAME | gunzip | (cd $UNPACKDIR; tar xvf -)
61 # Setting the new package path, in which the packages exist
62 PACKAGE_PATH=$UNPACKDIR
64 # Setting variable UPDATE, because an Office installation has to exist, if a language pack shall be installed
65 UPDATE="yes"
68 pkg_error()
70 # pkg command failed, check for admin log and report help
71 if [ -f /tmp/.ai.pkg.zone.lock-afdb66cf-1dd1-11b2-a049-000d560ddc3e ]
72 then
73 echo "####################################################################"
74 echo "# Installation failed due to stale administrative lock #"
75 echo "####################################################################"
76 printf "\nERROR: please remove the following file first:\n"
77 ls -l /tmp/.ai.pkg.zone.lock-afdb66cf-1dd1-11b2-a049-000d560ddc3e
79 rm -f $GETUID_SO
80 exit 1
83 get_pkg_list()
85 cd $1; ls -1
89 # this script is for userland not for root
92 if [ $UID -eq 0 ]
93 then
94 printf "\nThis script is for installation without administrative rights only\nPlease use pkgadd/patchadd to install as root\n"
95 help
96 exit 2
99 while getopts "alh" VALUE
101 echo $VALUE
102 case $VALUE in
103 a) ADD="yes"; break;;
104 h) help; exit 0;;
105 l) LINK="yes"; break;;
106 ?) echo $USAGE; exit 2;;
107 esac
108 done
109 shift `expr $OPTIND - 1`
111 if [ $# != 2 ]
112 then
113 echo $USAGE
114 exit 2
117 # Determine whether this is a patch or a regular install set ..
118 /bin/bash -c "ls $1/*/patchinfo >/dev/null 2>&1"
119 if [ "$?" = 0 ]
120 then
121 UPDATE="yes"
122 PATCH_PATH="$1"
123 PATCH_INFO_LIST=`/bin/bash -c "cd $1; ls */patchinfo"`
124 PATCH_LIST=`for i in ${PATCH_INFO_LIST}; do dirname $i; done`
125 elif [ -f "$1/patchinfo" ]
126 then
127 UPDATE="yes"
128 PATCH_PATH=`dirname "$1"`
129 PATCH_LIST=`basename "$1"`
130 else
131 if [ -d "$1/packages" ]
132 then
133 PACKAGE_PATH="$1/packages"
134 else
135 PACKAGE_PATH=$1
139 # If the first parameter is a shell script (download installation set), the packages have to
140 # be unpacked into temp directory
142 if [ -f "$PACKAGE_PATH" ]
143 then
144 try_to_unpack_languagepack_file
148 # Create sed filter script for unwanted packages
151 cat > /tmp/userinstall_filer.$$ << EOF
152 /SUNWadabas/d
153 /^SUNWj[0-9]/d
154 /-desktop-int/d
155 /-shared-mime-info/d
156 /-cde/d
159 # Do not install gnome-integration package on systems without GNOME
160 pkginfo -q SUNWgnome-vfs
161 if [ $? -ne 0 ]
162 then
164 echo '/-gnome/d' >> /tmp/userinstall_filer.$$
167 # pkgdep sorts the packages based on their dependencies
168 PKGDEP="`dirname $0`/pkgdep"
169 if [ ! -x $PKGDEP ]; then
170 PKGDEP="get_pkg_list"
174 # Get the list of packages to install
177 PKG_LIST=`$PKGDEP $PACKAGE_PATH | sed -f /tmp/userinstall_filer.$$`
178 rm -f /tmp/userinstall_filer.$$
180 if [ -z "$PKG_LIST" ]
181 then
182 printf "\n$0: No packages found in $PACKAGE_PATH\n"
183 exit 2
186 echo "Packages found:"
187 for i in $PKG_LIST ; do
188 echo $i
189 done
192 INSTALL_ROOT=$2
193 if [ "$UPDATE" = "yes" ]
194 then
195 if [ ! -d ${INSTALL_ROOT}/var/sadm/install/admin ]
196 then
197 printf "\n$0: No package database in ${INSTALL_ROOT}.\n"
198 exit 2
200 else
201 if [ "$ADD" = "no" ]
202 then
203 rmdir ${INSTALL_ROOT} 2>/dev/null
204 if [ -d ${INSTALL_ROOT} ]
205 then
206 printf "\n$0: ${INSTALL_ROOT} exists and is not empty.\n"
207 exit 2
210 mkdir -p ${INSTALL_ROOT}/var/sadm/install/admin
213 # Previous versions of this script did not write this file
214 if [ ! -f ${INSTALL_ROOT}/var/sadm/install/admin/default ]
215 then
216 cat > ${INSTALL_ROOT}/var/sadm/install/admin/default << EOF
217 action=nocheck
218 conflict=nocheck
219 setuid=nocheck
220 idepend=nocheck
221 mail=
225 if [ ! "${INSTALL_ROOT:0:1}" = "/" ]; then
226 INSTALL_ROOT=`cd ${INSTALL_ROOT}; pwd`
229 # This script must exist to make extension registration work
230 # always overwrite to get the latest version.
231 mkdir -p ${INSTALL_ROOT}/usr/lib
232 cat > ${INSTALL_ROOT}/usr/lib/postrun << \EOF
233 #!/bin/sh
234 set -e
236 # Override UserInstallation in bootstraprc for unopkg ..
237 UserInstallation='$BRAND_BASE_DIR/../UserInstallation'
238 export UserInstallation
240 if [ -x /usr/bin/mktemp ]
241 then
242 CMD=`/usr/bin/mktemp /tmp/userinstall.XXXXXX`
243 else
244 CMD=/tmp/userinstall.$$; echo "" > $CMD
247 sed -e 's|"/|"${PKG_INSTALL_ROOT}/|g' > $CMD
248 /bin/sh -e $CMD
249 rm -f $CMD
251 chmod +x ${INSTALL_ROOT}/usr/lib/postrun 2>/dev/null
253 # create local tmp directory to install on S10
254 LOCAL_TMP=
255 if [ -x /usr/bin/mktemp ]
256 then
257 LOCAL_TMP=`mktemp -d`
258 rmdir ${INSTALL_ROOT}/tmp 2>/dev/null
259 ln -s ${LOCAL_TMP} ${INSTALL_ROOT}/tmp
263 # the tail of the script contains a shared object for overloading the getuid()
264 # and a few other calls
267 GETUID_SO=/tmp/getuid.so.$$
268 linenum=???
269 tail +$linenum $0 > $GETUID_SO
272 # Perform the installation
274 if [ "$UPDATE" = "yes" ]
275 then
276 # restore original "bootstraprc" prior to patching
277 for i in ${PKG_LIST}; do
278 my_dir=${INSTALL_ROOT}`pkgparam -d ${PACKAGE_PATH} "$i" BASEDIR`
279 find "$my_dir" -type f -name bootstraprc.orig -exec sh -ce 'mv "$0" `dirname "$0"`/bootstraprc' {} \;
280 done
282 # copy INST_RELEASE file
283 if [ ! -f ${INSTALL_ROOT}/var/sadm/system/admin/INST_RELEASE ]
284 then
285 mkdir -p ${INSTALL_ROOT}/var/sadm/system/admin 2>/dev/null
286 cp -f /var/sadm/system/admin/INST_RELEASE ${INSTALL_ROOT}/var/sadm/system/admin/INST_RELEASE
289 # The case UPDATE="yes" is valid for patch installation and for language packs.
290 # For patches the variable PKG_LIST is empty, for language packs it is not empty.
291 # Patches have to be installed with patchadd, language packs with pkgadd
293 if [ -z "${PKG_LIST}" ]
294 then
295 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
296 else
297 LD_PRELOAD_32=$GETUID_SO /usr/sbin/pkgadd -d ${PACKAGE_PATH} -R ${INSTALL_ROOT} ${PKG_LIST} >/dev/null || pkg_error
300 else
302 # Create BASEDIR directories to avoid manual user interaction
303 for i in ${PKG_LIST}; do
304 mkdir -m 0755 -p ${INSTALL_ROOT}`pkgparam -d ${PACKAGE_PATH} $i BASEDIR` 2>/dev/null
305 done
307 if [ ! "${INSTALL_ROOT:0:1}" = "/" ]; then
308 INSTALL_ROOT=`cd ${INSTALL_ROOT}; pwd`
311 echo "####################################################################"
312 echo "# Installation of the found packages #"
313 echo "####################################################################"
314 echo
315 echo "Path to the packages : " $PACKAGE_PATH
316 echo "Path to the installation : " $INSTALL_ROOT
318 LD_PRELOAD_32=$GETUID_SO /usr/sbin/pkgadd -d ${PACKAGE_PATH} -R ${INSTALL_ROOT} ${PKG_LIST} >/dev/null || pkg_error
321 rm -f $GETUID_SO
322 rm -f /tmp/.ai.pkg.zone.lock*
324 # remove local tmp directory
325 if [ ! -z ${LOCAL_TMP} ]
326 then
327 rm -f ${LOCAL_TMP}/.ai.pkg.zone.lock*
328 rmdir ${LOCAL_TMP}
329 rm -f ${INSTALL_ROOT}/tmp
330 mkdir ${INSTALL_ROOT}/tmp
334 # Create a link into the users home directory
337 if [ "$LINK" = "yes" ]
338 then
339 rm -f $HOME/soffice 2>/dev/null
340 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"' {} \;
343 # patch the "bootstraprc" to create a self-containing installation
344 for i in ${PKG_LIST}; do
345 my_dir=${INSTALL_ROOT}`pkgparam -d ${PACKAGE_PATH} "$i" BASEDIR`
346 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"' {} \;
347 done
349 # if an unpack directory exists, it can be removed now
350 if [ ! -z "$UNPACKDIR" ]
351 then
352 # for i in ${PKG_LIST}; do
353 # cd $UNPACKDIR; rm -rf $i
354 # done
355 # rmdir $UNPACKDIR
357 rm -rf $UNPACKDIR
358 echo "Removed temporary directory $UNPACKDIR"
361 echo
362 echo "Installation done ..."
363 exit 0