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 .
24 USAGE
="Usage: $0 [-a,--add] [-l,--link] [-U,--update] [-h,--help] <rpm-source-dir> <office-installation-dir>"
29 echo "User Mode Installation script for developer and knowledgeable early access tester"
31 echo "This installation method is not intended for use in a production environment!"
32 echo "Using this script is unsupported and completely at your own risk"
34 echo "Usage:" $0 [-lU] "<rpm-source-dir> <office-installation-dir>"
35 echo " <rpm-source-dir>: directory *only* containing the Linux rpm packages to be installed"
36 echo " or language pack shell script containing the rpm packages"
37 echo " <office-installation-dir>: directory to where the office will get installed into"
39 echo "Optional Parameter:"
40 echo " -a,--add: add to an existing <office-installation-dir>"
41 echo " -l,--link: create a link \"soffice\" in $HOME"
42 echo " -U,--update: update without asking"
43 echo " -h,--help: output this help"
47 try_to_unpack_languagepack_file
()
49 FILENAME
=$PACKAGE_PATH
51 # Checking, if $FILENAME is a language pack.
52 # String "language package" has to exist in the shell script file.
53 # If this is no language pack, the installation is not supported
55 SEARCHSTRING
=`head --lines=10 $FILENAME | grep "language package"`
57 if [ ! -z "$SEARCHSTRING" ]
59 echo "First parameter $FILENAME is a language pack";
61 printf "\nERROR: First parameter $FILENAME is a file, but no language pack shell script.\n"
66 echo "Unpacking shell script $FILENAME"
67 TAILLINE
=`head --lines=20 $FILENAME | sed --quiet 's/linenum=//p'`
69 UNPACKDIR
=`mktemp -d -p /var/tmp`
70 tail -n +$TAILLINE $FILENAME | gunzip |
(cd $UNPACKDIR; tar xvf
-)
72 # Setting the new package path, in which the packages exist
73 PACKAGE_PATH
=$UNPACKDIR
75 # Setting variable UPDATE, because an Office installation has to exist, if a language pack shall be installed
80 # this script is for userland not for root
85 printf "\nThis script is for installation without administrative rights only\nPlease use rpm to install as root\n"
90 set -- `getopt -u -o 'alhU' -l 'add,link,help,update' -- $*`
101 -a|
--add) ADD
="yes"; shift;;
102 -h|
--help) help; exit 0;;
103 -l|
--link) LINK
="yes"; shift;;
104 -U|
--update) UPDATE
="yes"; shift;;
112 echo "Example: $0 . ~/libreoffice"
119 # If the first parameter is a shell script (download installation set), the packages have to
120 # be unpacked into temp directory
123 if [ -f "$PACKAGE_PATH" ]
125 try_to_unpack_languagepack_file
129 # Check and get the list of packages to install
132 RPMLIST
=`find $PACKAGE_PATH -maxdepth 2 -type f -name "*.rpm" ! -name "*-menus-*" ! -name "*-desktop-integration-*" ! -name "jre*" ! -name "*-userland-*" -print`
136 printf "\n$0: No packages found in $PACKAGE_PATH\n"
140 # #163256# check if we are on a debian system...
141 if rpm
--help |
grep debian
>/dev
/null
;
143 DEBIAN_FLAGS
="--force-debian --nodeps"
149 # Determine whether this should be an update or a fresh install
153 RPM_DB_PATH
=${INSTALLDIR}/.RPM_OFFICE_DATABASE
155 # Check for versionrc
156 if [ -f ${INSTALLDIR}/program
/versionrc
]; then VERSIONRC
=versionrc
; fi
158 if [ "$UPDATE" = "ask" ]
160 PRODUCT
=`sed --silent -e "
162 s/buildid=\(.*\)/ [\1]/
169 }" ${INSTALLDIR}/program/${VERSIONRC:-bootstraprc} 2>/dev/null | tr -d "\012"`
171 if [ ! -z "$PRODUCT" ]
174 echo "Found an installation of $PRODUCT in $INSTALLDIR"
176 while [ "$UPDATE" != "yes" ]
178 read -a UPDATE
-p "Do you want to update this installation (yes/no)? "
179 if [ "$UPDATE" = "no" ]
184 elif [ -d $RPM_DB_PATH -a "$ADD" = "no" ]
187 echo "The following packages are already installed in $INSTALLDIR"
189 rpm
--dbpath `cd $RPM_DB_PATH; pwd` --query --all
191 while [ "$UPDATE" != "yes" ]
193 read -a UPDATE
-p "Do you want to continue with this installation (yes/no)? "
194 if [ "$UPDATE" = "no" ]
205 # Check/Create installation directory
208 if [ "$UPDATE" = "yes" ]
210 # restore original bootstraprc
211 mv -f ${INSTALLDIR}/program
/bootstraprc.orig
${INSTALLDIR}/program
/bootstraprc
2>/dev
/null
213 # the RPM_DB_PATH must be absolute
214 if [ ! "${RPM_DB_PATH:0:1}" = "/" ]; then
215 RPM_DB_PATH
=`cd ${RPM_DB_PATH}; pwd`
218 # we should use --freshen for updates to not add languages with patches, but this will break
219 # language packs, so leave it for now ..
223 rmdir ${INSTALLDIR} 2>/dev
/null
225 mkdir
-p $RPM_DB_PATH ||
exit 2
227 chmod 700 $RPM_DB_PATH
229 # the RPM_DB_PATH must be absolute
230 if [ ! "${RPM_DB_PATH:0:1}" = "/" ]; then
231 RPM_DB_PATH
=`cd ${RPM_DB_PATH}; pwd`
234 # Creating RPM database and initializing
235 if [ "$ADD" = "no" ]; then
236 rpm
--initdb --dbpath $RPM_DB_PATH
239 # Default install command
243 # populate the private rpm database with the dependencies needed
244 FAKEDBRPM
=`mktemp -p /tmp fake-db-1.0-XXXXXXXXXX.noarch.rpm`
246 tail -n +$linenum $0 > $FAKEDBRPM
248 rpm
${DEBIAN_FLAGS} --upgrade --ignoresize --dbpath $RPM_DB_PATH $FAKEDBRPM
252 echo "Packages found:"
253 for i
in $RPMLIST ; do
258 # Perform the installation
262 echo "####################################################################"
263 echo "# Installation of the found packages #"
264 echo "####################################################################"
266 echo "Path to the database: " $RPM_DB_PATH
267 echo "Path to the packages: " $PACKAGE_PATH
268 echo "Path to the installation: " $INSTALLDIR
270 echo "Installing the RPMs"
272 ABSROOT
=`cd ${INSTALLDIR}; pwd`
273 RELOCATIONS
=`rpm -qp --qf "--relocate %{PREFIXES}=${ABSROOT}%{PREFIXES} \n" $RPMLIST | sort -u | tr -d "\012"`
274 UserInstallation
=\
$BRAND_BASE_DIR/..
/UserInstallation rpm
${DEBIAN_FLAGS} --nodeps $RPMCMD --ignoresize -vh $RELOCATIONS --dbpath $RPM_DB_PATH $RPMLIST
277 # Create a link into the users home directory
280 if [ "$LINK" = "yes" ]
282 find `cd "$INSTALLDIR" && pwd` -name soffice
-type f
-perm /u
+x
-exec /bin
/bash
-ce 'ln -sf "$0" "$HOME/soffice" && echo "Creating link from $0 to $HOME/soffice"' {} \
;
285 if [ "$UPDATE" = "yes" -a ! -f $INSTALLDIR/program
/bootstraprc
]
288 echo "Update failed due to a bug in RPM, uninstalling .."
289 rpm
${DEBIAN_FLAGS} --erase -v --nodeps --dbpath $RPM_DB_PATH `rpm --query --queryformat "%{NAME} " --package $RPMLIST --dbpath $RPM_DB_PATH`
291 echo "Now re-installing new packages .."
293 rpm
${DEBIAN_FLAGS} --install --nodeps --ignoresize -vh $RELOCATIONS --dbpath $RPM_DB_PATH $RPMLIST
297 # patch the "bootstraprc" to create a self-containing installation
298 find "$INSTALLDIR" -type f
-name bootstraprc
-exec /bin
/bash
-ce 'test ! -e "$0".orig && mv "$0" "$0".orig && sed '\''s,^UserInstallation=$SYSUSERCONFIG.*,UserInstallation=$BRAND_BASE_DIR/../UserInstallation,'\'' "$0".orig > "$0"' {} \
;
300 # if an unpack directory exists, it can be removed now
301 if [ ! -z "$UNPACKDIR" ]
305 echo "Removed temporary directory $UNPACKDIR"
309 echo "Installation done ..."