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
=/var
/tmp
/install_$$
71 # UNPACKDIR=`mktemp -d`
72 tail -n +$TAILLINE $FILENAME | gunzip |
(cd $UNPACKDIR; tar xvf
-)
74 # Setting the new package path, in which the packages exist
75 PACKAGE_PATH
=$UNPACKDIR
77 # Setting variable UPDATE, because an Office installation has to exist, if a language pack shall be installed
82 # this script is for userland not for root
87 printf "\nThis script is for installation without administrative rights only\nPlease use rpm to install as root\n"
92 set -- `getopt -u -o 'alhU' -l 'add,link,help,update' -- $*`
103 -a|
--add) ADD
="yes"; shift;;
104 -h|
--help) help; exit 0;;
105 -l|
--link) LINK
="yes"; shift;;
106 -U|
--update) UPDATE
="yes"; shift;;
114 echo "Example: $0 . ~/libreoffice"
121 # If the first parameter is a shell script (download installation set), the packages have to
122 # be unpacked into temp directory
125 if [ -f "$PACKAGE_PATH" ]
127 try_to_unpack_languagepack_file
131 # Check and get the list of packages to install
134 RPMLIST
=`find $PACKAGE_PATH -maxdepth 2 -type f -name "*.rpm" ! -name "*-menus-*" ! -name "*-desktop-integration-*" ! -name "jre*" ! -name "*-userland-*" -print`
138 printf "\n$0: No packages found in $PACKAGE_PATH\n"
142 # #163256# check if we are on a debian system...
143 if rpm
--help |
grep debian
>/dev
/null
;
145 DEBIAN_FLAGS
="--force-debian --nodeps"
151 # Determine whether this should be an update or a fresh install
155 RPM_DB_PATH
=${INSTALLDIR}/.RPM_OFFICE_DATABASE
157 # Check for versionrc
158 if [ -f ${INSTALLDIR}/program
/versionrc
]; then VERSIONRC
=versionrc
; fi
160 if [ "$UPDATE" = "ask" ]
162 PRODUCT
=`sed --silent -e "
164 s/buildid=\(.*\)/ [\1]/
171 }" ${INSTALLDIR}/program/${VERSIONRC:-bootstraprc} 2>/dev/null | tr -d "\012"`
173 if [ ! -z "$PRODUCT" ]
176 echo "Found an installation of $PRODUCT in $INSTALLDIR"
178 while [ "$UPDATE" != "yes" ]
180 read -a UPDATE
-p "Do you want to update this installation (yes/no)? "
181 if [ "$UPDATE" = "no" ]
186 elif [ -d $RPM_DB_PATH -a "$ADD" = "no" ]
189 echo "The following packages are already installed in $INSTALLDIR"
191 rpm
--dbpath `cd $RPM_DB_PATH; pwd` --query --all
193 while [ "$UPDATE" != "yes" ]
195 read -a UPDATE
-p "Do you want to continue with this installation (yes/no)? "
196 if [ "$UPDATE" = "no" ]
207 # Check/Create installation directory
210 if [ "$UPDATE" = "yes" ]
212 # restore original bootstraprc
213 mv -f ${INSTALLDIR}/program
/bootstraprc.orig
${INSTALLDIR}/program
/bootstraprc
2>/dev
/null
215 # the RPM_DB_PATH must be absolute
216 if [ ! "${RPM_DB_PATH:0:1}" = "/" ]; then
217 RPM_DB_PATH
=`cd ${RPM_DB_PATH}; pwd`
220 # we should use --freshen for updates to not add languages with patches, but this will break
221 # language packs, so leave it for now ..
225 rmdir ${INSTALLDIR} 2>/dev
/null
227 mkdir
-p $RPM_DB_PATH ||
exit 2
229 chmod 700 $RPM_DB_PATH
231 # the RPM_DB_PATH must be absolute
232 if [ ! "${RPM_DB_PATH:0:1}" = "/" ]; then
233 RPM_DB_PATH
=`cd ${RPM_DB_PATH}; pwd`
236 # Creating RPM database and initializing
237 if [ "$ADD" = "no" ]; then
238 rpm
--initdb --dbpath $RPM_DB_PATH
241 # Default install command
245 # populate the private rpm database with the dependencies needed
246 FAKEDBRPM
=/tmp
/fake-db-1.0
-$$.noarch.rpm
248 tail -n +$linenum $0 > $FAKEDBRPM
250 rpm
${DEBIAN_FLAGS} --upgrade --ignoresize --dbpath $RPM_DB_PATH $FAKEDBRPM
254 echo "Packages found:"
255 for i
in $RPMLIST ; do
260 # Perform the installation
264 echo "####################################################################"
265 echo "# Installation of the found packages #"
266 echo "####################################################################"
268 echo "Path to the database: " $RPM_DB_PATH
269 echo "Path to the packages: " $PACKAGE_PATH
270 echo "Path to the installation: " $INSTALLDIR
272 echo "Installing the RPMs"
274 ABSROOT
=`cd ${INSTALLDIR}; pwd`
275 RELOCATIONS
=`rpm -qp --qf "--relocate %{PREFIXES}=${ABSROOT}%{PREFIXES} \n" $RPMLIST | sort -u | tr -d "\012"`
276 UserInstallation
=\
$BRAND_BASE_DIR/..
/UserInstallation rpm
${DEBIAN_FLAGS} --nodeps $RPMCMD --ignoresize -vh $RELOCATIONS --dbpath $RPM_DB_PATH $RPMLIST
279 # Create a link into the users home directory
282 if [ "$LINK" = "yes" ]
284 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"' {} \
;
287 if [ "$UPDATE" = "yes" -a ! -f $INSTALLDIR/program
/bootstraprc
]
290 echo "Update failed due to a bug in RPM, uninstalling .."
291 rpm
${DEBIAN_FLAGS} --erase -v --nodeps --dbpath $RPM_DB_PATH `rpm --query --queryformat "%{NAME} " --package $RPMLIST --dbpath $RPM_DB_PATH`
293 echo "Now re-installing new packages .."
295 rpm
${DEBIAN_FLAGS} --install --nodeps --ignoresize -vh $RELOCATIONS --dbpath $RPM_DB_PATH $RPMLIST
299 # patch the "bootstraprc" to create a self-containing installation
300 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"' {} \
;
302 # if an unpack directory exists, it can be removed now
303 if [ ! -z "$UNPACKDIR" ]
307 echo "Removed temporary directory $UNPACKDIR"
311 echo "Installation done ..."